From: Sebastien Bourdeauducq Date: Thu, 8 Dec 2011 20:28:20 +0000 (+0100) Subject: fhdl: improve automatic signal naming X-Git-Tag: 24jan2021_ls180~2099^2~1162 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=512655c108a072773fb910193261c03844300b08;p=litex.git fhdl: improve automatic signal naming --- diff --git a/migen/fhdl/structure.py b/migen/fhdl/structure.py index 6097c243..f1ecb0e4 100644 --- a/migen/fhdl/structure.py +++ b/migen/fhdl/structure.py @@ -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