back.pysim: fix behavior of initial cycle for sync processes.
authorwhitequark <whitequark@whitequark.org>
Tue, 22 Jan 2019 17:51:44 +0000 (17:51 +0000)
committerwhitequark <whitequark@whitequark.org>
Fri, 25 Jan 2019 20:37:56 +0000 (20:37 +0000)
The current behavior was introduced in 65702719, which was a wrong
fix for an issue that was actually fixed in 12e04e4e. This commit
effectively reverts 65702719 and 1782b841.

nmigen/back/pysim.py
nmigen/lib/fifo.py
nmigen/test/test_sim.py

index a19905d757ccbbe28f9864437d81eedfbccf82d1..21885a8b36252dc910e751c6d6ced3f2affc34ca 100644 (file)
@@ -414,13 +414,13 @@ class Simulator:
         process = self._check_process(process)
         def sync_process():
             try:
-                result = None
+                cmd = None
                 while True:
-                    self._process_loc[sync_process] = self._name_process(process)
-                    cmd = process.send(result)
                     if cmd is None:
                         cmd = Tick(domain)
                     result = yield cmd
+                    self._process_loc[sync_process] = self._name_process(process)
+                    cmd = process.send(result)
             except StopIteration:
                 pass
         sync_process = sync_process()
index 6e8e67926b4bfaeaaaf7c57b0f27069952cdec44..e26d3d43becf1bc7e65134baa2ae723f882a01d5 100644 (file)
@@ -72,9 +72,9 @@ class FIFOInterface:
 
     def read(self):
         """Read method for simulation."""
+        assert (yield self.readable)
         yield self.re.eq(1)
         yield
-        assert (yield self.readable)
         value = (yield self.dout)
         yield self.re.eq(0)
         return value
index d1f769e58784e4d1a04848a196c416416e192005..20f6fa10acf316a87403593ac8af40fe7fe6e996 100644 (file)
@@ -279,9 +279,6 @@ class SimulatorIntegrationTestCase(FHDLTestCase):
         with self.assertSimulation(self.m) as sim:
             sim.add_clock(1e-6, domain="sync")
             def process():
-                self.assertEqual((yield self.count), 4)
-                self.assertEqual((yield self.sync.clk), 0)
-                yield
                 self.assertEqual((yield self.count), 4)
                 self.assertEqual((yield self.sync.clk), 1)
                 yield