fhdl: also take into account object attributes in _make_signal_name. Get rid of declare_signal

This commit is contained in:
Sebastien Bourdeauducq 2011-12-18 21:47:29 +01:00
parent 41e2430e2b
commit dd42b2daff
1 changed files with 3 additions and 10 deletions

View File

@ -128,9 +128,11 @@ def _cst(x):
def _make_signal_name(): def _make_signal_name():
frame = inspect.currentframe().f_back.f_back frame = inspect.currentframe().f_back.f_back
line = inspect.getframeinfo(frame).code_context[0] line = inspect.getframeinfo(frame).code_context[0]
m = re.match('[\t ]*([0-9A-Za-z_]+) =', line) m = re.match('[\t ]*([0-9A-Za-z_\.]+) =', line)
if m is None: return None if m is None: return None
name = m.group(1) name = m.group(1)
name = name.split('.')
name = name[len(name)-1]
modules = frame.f_globals["__name__"] modules = frame.f_globals["__name__"]
if modules != "__main__": if modules != "__main__":
modules = modules.split('.') modules = modules.split('.')
@ -151,15 +153,6 @@ class Signal(Value):
def __hash__(self): def __hash__(self):
return id(self) return id(self)
def declare_signal(parent, name, bv=BV(), variable=False, reset=0):
# try to find a meaningful prefix
if parent.__module__ == "__main__":
prefix = parent.__class__.__name__
else:
modules = parent.__module__.split('.')
prefix = modules[len(modules)-1]
setattr(parent, name, Signal(bv, prefix + "_" + name, variable, reset))
# statements # statements
class Assign: class Assign: