pytholite: introduce io module
authorSebastien Bourdeauducq <sebastien@milkymist.org>
Sat, 10 Nov 2012 20:51:19 +0000 (21:51 +0100)
committerSebastien Bourdeauducq <sebastien@milkymist.org>
Sat, 10 Nov 2012 20:51:19 +0000 (21:51 +0100)
migen/pytholite/compiler.py
migen/pytholite/io.py [new file with mode: 0644]

index c98ae33144ce8ecbd927f6587772e096fbef7b62..240895353577aaf521302c07560091f425eb1c6c 100644 (file)
@@ -7,6 +7,7 @@ from migen.fhdl.structure import _Slice
 from migen.fhdl import visit as fhdl
 from migen.corelogic.fsm import FSM
 from migen.pytholite import transel
+from migen.pytholite.io import *
 
 class FinalizeError(Exception):
        pass
@@ -319,7 +320,9 @@ def _create_fsm(states):
                fsm.act(getattr(fsm, stnames[i]), *actions)
        return fsm
 
-def make_pytholite(func):
+def make_pytholite(func, **ioresources):
+       pl = make_io_object(**ioresources)
+       
        tree = ast.parse(inspect.getsource(func))
        symdict = func.__globals__.copy()
        registers = []
@@ -334,4 +337,5 @@ def make_pytholite(func):
        fsm = _create_fsm(states)
        fsmf = _LowerAbstractLoad().visit(fsm.get_fragment())
        
-       return regf + fsmf
+       pl.fragment = regf + fsmf
+       return pl
diff --git a/migen/pytholite/io.py b/migen/pytholite/io.py
new file mode 100644 (file)
index 0000000..d0ace1d
--- /dev/null
@@ -0,0 +1,15 @@
+from migen.flow.actor import *
+
+class Pytholite:
+       def get_fragment(self):
+               return self.fragment
+
+class DFPytholite(Pytholite, Actor):
+       pass
+
+def make_io_object(dataflow=None):
+       if dataflow is None:
+               return Pytholite()
+       else:
+               return DFPytholite(dataflow)
+