sim: support clock domains without sync

This commit is contained in:
Sebastien Bourdeauducq 2015-09-12 15:12:57 +08:00
parent fd986210f8
commit 7bd72a16df

View file

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