fhdl: add simulation functions in fragment
authorSebastien Bourdeauducq <sebastien@milkymist.org>
Tue, 6 Mar 2012 12:58:22 +0000 (13:58 +0100)
committerSebastien Bourdeauducq <sebastien@milkymist.org>
Tue, 6 Mar 2012 12:58:22 +0000 (13:58 +0100)
migen/fhdl/structure.py

index 0ca04b13c29e16b3a0eae4baad814ad9de81e2d5..45f97705e433431a2759a273442bc3f0883d68d4 100644 (file)
@@ -255,20 +255,27 @@ class Memory:
                self.init = init
 
 class Fragment:
-       def __init__(self, comb=None, sync=None, instances=None, memories=None, pads=set()):
+       def __init__(self, comb=None, sync=None, instances=None, memories=None, pads=set(), sim=None):
                if comb is None: comb = []
                if sync is None: sync = []
                if instances is None: instances = []
                if memories is None: memories = []
+               if sim is None: sim = []
                self.comb = _sl(comb)
                self.sync = _sl(sync)
                self.instances = instances
                self.memories = memories
                self.pads = pads
+               self.sim = sim
        
        def __add__(self, other):
                return Fragment(self.comb.l + other.comb.l,
                        self.sync.l + other.sync.l,
                        self.instances + other.instances,
                        self.memories + other.memories,
-                       self.pads | other.pads)
+                       self.pads | other.pads,
+                       self.sim + other.sim)
+
+       def call_sim(self, simulator, cycle):
+               for s in self.sim:
+                       s(simulator, cycle)