From 48acb1bcfd09121bc1df307d4c6eff3a9a3fd5cd Mon Sep 17 00:00:00 2001 From: Sebastien Bourdeauducq Date: Sat, 10 Nov 2012 21:51:19 +0100 Subject: [PATCH] pytholite: introduce io module --- migen/pytholite/compiler.py | 8 ++++++-- migen/pytholite/io.py | 15 +++++++++++++++ 2 files changed, 21 insertions(+), 2 deletions(-) create mode 100644 migen/pytholite/io.py diff --git a/migen/pytholite/compiler.py b/migen/pytholite/compiler.py index c98ae331..24089535 100644 --- a/migen/pytholite/compiler.py +++ b/migen/pytholite/compiler.py @@ -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 index 00000000..d0ace1db --- /dev/null +++ b/migen/pytholite/io.py @@ -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) + -- 2.30.2