fhdl: improve automatic signal naming

This commit is contained in:
Sebastien Bourdeauducq 2011-12-08 21:28:20 +01:00
parent 5034af3038
commit 512655c108
1 changed files with 7 additions and 1 deletions

View File

@ -120,7 +120,13 @@ class Signal(Value):
return id(self)
def Declare(parent, name, bv=BV(), variable=False, reset=0):
setattr(parent, name, Signal(bv, parent.__class__.__name__ + "_" + name, variable, reset))
# 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