fix SimActor TB terminations

This commit is contained in:
Sebastien Bourdeauducq 2014-01-28 00:03:56 +01:00
parent 90f0dfad63
commit 2ab939e69d
2 changed files with 8 additions and 0 deletions

View file

@ -34,5 +34,9 @@ class TB(Module):
g.add_connection(self.source, self.sink) g.add_connection(self.source, self.sink)
self.submodules.comp = CompositeActor(g) self.submodules.comp = CompositeActor(g)
def do_simulation(self, selfp):
if self.source.token_exchanger.done:
raise StopSimulation
if __name__ == "__main__": if __name__ == "__main__":
run_simulation(TB()) run_simulation(TB())

View file

@ -33,6 +33,7 @@ class TokenExchanger(Module):
self.actor = actor self.actor = actor
self.active = set() self.active = set()
self.busy = True self.busy = True
self.done = False
def _process_transactions(self, selfp): def _process_transactions(self, selfp):
completed = set() completed = set()
@ -69,6 +70,7 @@ class TokenExchanger(Module):
transactions = next(self.generator) transactions = next(self.generator)
except StopIteration: except StopIteration:
self.busy = False self.busy = False
self.done = True
raise StopSimulation raise StopSimulation
if isinstance(transactions, Token): if isinstance(transactions, Token):
self.active = {transactions} self.active = {transactions}
@ -87,6 +89,7 @@ class TokenExchanger(Module):
if not self.active: if not self.active:
self._next_transactions() self._next_transactions()
self._update_control_signals(selfp) self._update_control_signals(selfp)
do_simulation.passive = True
class SimActor(Module): class SimActor(Module):
def __init__(self, generator): def __init__(self, generator):
@ -95,6 +98,7 @@ class SimActor(Module):
def do_simulation(self, selfp): def do_simulation(self, selfp):
selfp.busy = self.token_exchanger.busy selfp.busy = self.token_exchanger.busy
do_simulation.passive = True
def _dumper_gen(prefix): def _dumper_gen(prefix):
while True: while True: