From 7bd72a16df03b621d6a6ee1f09cd5361441edfab Mon Sep 17 00:00:00 2001 From: Sebastien Bourdeauducq Date: Sat, 12 Sep 2015 15:12:57 +0800 Subject: [PATCH] sim: support clock domains without sync --- migen/sim.py | 41 +++++++++++++++++++++-------------------- 1 file changed, 21 insertions(+), 20 deletions(-) diff --git a/migen/sim.py b/migen/sim.py index 863cd184..36bbcfe3 100644 --- a/migen/sim.py +++ b/migen/sim.py @@ -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(): -- 2.30.2