pytholite: introduce io module

This commit is contained in:
Sebastien Bourdeauducq 2012-11-10 21:51:19 +01:00
parent 6776f06a42
commit 48acb1bcfd
2 changed files with 21 additions and 2 deletions

View 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

15
migen/pytholite/io.py Normal file
View File

@ -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)