sim: support clock domains without sync
authorSebastien Bourdeauducq <sb@m-labs.hk>
Sat, 12 Sep 2015 07:12:57 +0000 (15:12 +0800)
committerSebastien Bourdeauducq <sb@m-labs.hk>
Sat, 12 Sep 2015 07:12:57 +0000 (15:12 +0800)
migen/sim.py

index 863cd18432852220b83f7cfc701010d86d037fb8..36bbcfe31c7abbb42b2a022d550ec9a2eb59d8aa 100644 (file)
@@ -148,24 +148,23 @@ class Simulator:
             modified = self.evaluator.commit()
 
     def _process_generators(self, cd):
-        if cd in self.generators:
-            exhausted = []
-            for generator in self.generators[cd]:
-                reply = None
-                while True:
-                    try:
-                        request = generator.send(reply)
-                        if request is None:
-                            break  # next cycle
-                        elif isinstance(request, tuple):
-                            self.evaluator.assign(*request)
-                        else:
-                            reply = self.evaluator.eval(request)
-                    except StopIteration:
-                        exhausted.append(generator)
-                        break
-            for generator in exhausted:
-                self.generators[cd].remove(generator)
+        exhausted = []
+        for generator in self.generators[cd]:
+            reply = None
+            while True:
+                try:
+                    request = generator.send(reply)
+                    if request is None:
+                        break  # next cycle
+                    elif isinstance(request, tuple):
+                        self.evaluator.assign(*request)
+                    else:
+                        reply = self.evaluator.eval(request)
+                except StopIteration:
+                    exhausted.append(generator)
+                    break
+        for generator in exhausted:
+            self.generators[cd].remove(generator)
 
     def _continue_simulation(self):
         # TODO: passive generators
@@ -178,8 +177,10 @@ class Simulator:
         while True:
             cds = self.time.tick()
             for cd in cds:
-                self.evaluator.execute(self.fragment.sync[cd])
-                self._process_generators(cd)
+                if cd in self.fragment.sync:
+                    self.evaluator.execute(self.fragment.sync[cd])
+                if cd in self.generators:
+                    self._process_generators(cd)
             self._comb_propagate(self.evaluator.commit())
 
             if not self._continue_simulation():