fix SimActor TB terminations
authorSebastien Bourdeauducq <sebastien@milkymist.org>
Mon, 27 Jan 2014 23:03:56 +0000 (00:03 +0100)
committerSebastien Bourdeauducq <sebastien@milkymist.org>
Mon, 27 Jan 2014 23:03:56 +0000 (00:03 +0100)
examples/sim/dataflow.py
migen/actorlib/sim.py

index 5a325440af14afaa23eff499ebd04973d47e6e59..bc8c6b3ddaa242ebe784dbc205baef1b42de9432 100644 (file)
@@ -34,5 +34,9 @@ class TB(Module):
                g.add_connection(self.source, self.sink)
                self.submodules.comp = CompositeActor(g)
 
+       def do_simulation(self, selfp):
+               if self.source.token_exchanger.done:
+                       raise StopSimulation
+
 if __name__ == "__main__":
        run_simulation(TB())
index 37dc1c319efe5441271cfa51c96e66098352c973..dffe12f2a6bf5354831bc3d6fbc9ecc9c2b853a6 100644 (file)
@@ -33,6 +33,7 @@ class TokenExchanger(Module):
                self.actor = actor
                self.active = set()
                self.busy = True
+               self.done = False
 
        def _process_transactions(self, selfp):
                completed = set()
@@ -69,6 +70,7 @@ class TokenExchanger(Module):
                        transactions = next(self.generator)
                except StopIteration:
                        self.busy = False
+                       self.done = True
                        raise StopSimulation
                if isinstance(transactions, Token):
                        self.active = {transactions}
@@ -87,6 +89,7 @@ class TokenExchanger(Module):
                if not self.active:
                        self._next_transactions()
                        self._update_control_signals(selfp)
+       do_simulation.passive = True
 
 class SimActor(Module):
        def __init__(self, generator):
@@ -95,6 +98,7 @@ class SimActor(Module):
        
        def do_simulation(self, selfp):
                selfp.busy = self.token_exchanger.busy
+       do_simulation.passive = True
 
 def _dumper_gen(prefix):
        while True: