gen/fhdl/namer: Cleanup & add comments on Namespace.
This commit is contained in:
parent
61eead5170
commit
7800858c7a
|
@ -237,18 +237,30 @@ class Namespace:
|
|||
self.clock_domains = dict()
|
||||
|
||||
def get_name(self, sig):
|
||||
# Clock Signal.
|
||||
# -------------
|
||||
if isinstance(sig, ClockSignal):
|
||||
sig = self.clock_domains[sig.cd].clk
|
||||
|
||||
# Reset Signal.
|
||||
# -------------
|
||||
if isinstance(sig, ResetSignal):
|
||||
sig = self.clock_domains[sig.cd].rst
|
||||
if sig is None:
|
||||
raise ValueError("Attempted to obtain name of non-existent "
|
||||
"reset signal of domain "+sig.cd)
|
||||
msg = f"Clock Domain {sig.cd} is reset-less, can't obtain name"
|
||||
raise ValueError(msg)
|
||||
|
||||
# Regular Signal.
|
||||
# ---------------
|
||||
# Use Name's override when set...
|
||||
if sig.name_override is not None:
|
||||
sig_name = sig.name_override
|
||||
# ... else get Name from pnd.
|
||||
else:
|
||||
sig_name = self.pnd[sig]
|
||||
|
||||
# Check/Add numbering suffix when required.
|
||||
# -----------------------------------------
|
||||
try:
|
||||
n = self.sigs[sig]
|
||||
except KeyError:
|
||||
|
@ -258,7 +270,7 @@ class Namespace:
|
|||
n = 0
|
||||
self.sigs[sig] = n
|
||||
self.counts[sig_name] = n + 1
|
||||
if n:
|
||||
return sig_name + "_" + str(n)
|
||||
else:
|
||||
return sig_name
|
||||
suffix = "" if n == 0 else f"_{n}"
|
||||
|
||||
# Return Name.
|
||||
return sig_name + suffix
|
||||
|
|
Loading…
Reference in New Issue