From 512655c108a072773fb910193261c03844300b08 Mon Sep 17 00:00:00 2001 From: Sebastien Bourdeauducq Date: Thu, 8 Dec 2011 21:28:20 +0100 Subject: [PATCH] fhdl: improve automatic signal naming --- migen/fhdl/structure.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) 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 -- 2.30.2