From: Sebastien Bourdeauducq Date: Sat, 12 Sep 2015 07:12:57 +0000 (+0800) Subject: sim: support clock domains without sync X-Git-Tag: 24jan2021_ls180~2099^2~3^2~104 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=7bd72a16df03b621d6a6ee1f09cd5361441edfab;p=litex.git sim: support clock domains without sync --- 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():