2011-12-10 14:47:21 -05:00
|
|
|
import inspect
|
|
|
|
|
2011-12-16 10:02:55 -05:00
|
|
|
from migen.fhdl.structure import *
|
|
|
|
|
|
|
|
def from_local():
|
2011-12-10 14:47:21 -05:00
|
|
|
f = Fragment()
|
|
|
|
frame = inspect.currentframe().f_back
|
|
|
|
ns = frame.f_locals
|
|
|
|
for x in ns:
|
|
|
|
obj = ns[x]
|
2011-12-16 10:02:55 -05:00
|
|
|
if hasattr(obj, "get_fragment"):
|
|
|
|
f += obj.get_fragment()
|
2011-12-10 14:47:21 -05:00
|
|
|
return f
|
2013-02-11 12:34:01 -05:00
|
|
|
|
|
|
|
def from_attributes(obj):
|
|
|
|
f = Fragment()
|
|
|
|
for x in obj.__dict__.values():
|
|
|
|
if hasattr(x, "get_fragment"):
|
|
|
|
f += x.get_fragment()
|
|
|
|
return f
|