uio: support memories
authorSebastien Bourdeauducq <sebastien@milkymist.org>
Fri, 23 Nov 2012 15:23:24 +0000 (16:23 +0100)
committerSebastien Bourdeauducq <sebastien@milkymist.org>
Fri, 23 Nov 2012 15:23:24 +0000 (16:23 +0100)
migen/pytholite/io.py
migen/uio/ioo.py

index bf40a70d307667f772d196a0b38214817ded22c1..766f8a2b3f07ffd4c96a19cbc5076af0bccb8b4b 100644 (file)
@@ -11,7 +11,7 @@ from migen.pytholite.expr import ExprCompiler
 
 class Pytholite(UnifiedIOObject):
        def get_fragment(self):
-               return self.fragment
+               return super().get_fragment() + self.fragment
 
 class _TokenPullExprCompiler(ExprCompiler):
        def __init__(self, symdict, modelname, ep):
index 67472e21a37205b1aea4768c93aa3cdb7b9782dc..907d85e9027d9f54117a4bfaec5929693a1c3ae9 100644 (file)
@@ -1,7 +1,7 @@
 from migen.fhdl.structure import *
 from migen.flow.actor import *
 from migen.actorlib.sim import TokenExchanger, Token
-from migen.bus import wishbone
+from migen.bus import wishbone, memory
 from migen.bus.transactions import *
 from migen.uio.trampoline import Trampoline
 
@@ -10,6 +10,11 @@ class UnifiedIOObject(Actor):
                if dataflow is not None:
                        super().__init__(*dataflow)
                self.buses = buses
+               
+               self._memories = set(v for v in self.buses.values() if isinstance(v, Memory))
+       
+       def get_fragment(self):
+               return Fragment(memories=list(self._memories))
 
 (_WAIT_COMPLETE, _WAIT_POLL) = range(2)
 
@@ -28,6 +33,8 @@ class UnifiedIOSimulation(UnifiedIOObject):
                        g = self.dispatch_g(caller_id)
                        if isinstance(v, wishbone.Interface):
                                caller = wishbone.Initiator(g, v)
+                       elif isinstance(v, Memory):
+                               caller = memory.Initiator(g, v)
                        else:
                                raise NotImplementedError
                        self.callers.append(caller)
@@ -69,4 +76,5 @@ class UnifiedIOSimulation(UnifiedIOObject):
                                yield None
        
        def get_fragment(self):
-               return sum([c.get_fragment() for c in self.callers], Fragment())
+               f = super().get_fragment()
+               return sum([c.get_fragment() for c in self.callers], f)