From: Sebastien Bourdeauducq Date: Sat, 8 Sep 2012 23:26:33 +0000 (+0200) Subject: fhdl/namer: simplify + more relevant names X-Git-Tag: 24jan2021_ls180~2099^2~845 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=51f9a2a963c52cff1174954ca9f48fc9e3a20ab6;p=litex.git fhdl/namer: simplify + more relevant names --- diff --git a/migen/fhdl/namer.py b/migen/fhdl/namer.py index 55a79c3e..433882bf 100644 --- a/migen/fhdl/namer.py +++ b/migen/fhdl/namer.py @@ -2,11 +2,11 @@ from itertools import combinations from migen.fhdl.structure import * -class _StepNamer(): +class _StepNamer: def __init__(self): self.name_to_ids = {} - def context_prefix(self, obj): + def get_step_str(self, obj): if isinstance(obj, str): return obj else: @@ -24,40 +24,15 @@ class _StepNamer(): l.append(id(obj)) return n + str(idx) - def name(self, with_context_prefix, step): - if with_context_prefix or step[1] is None: - n = self.context_prefix(step[0]) - if step[1] is not None: - n += "_" + step[1] - else: - n = step[1] - return n - -# Returns True if we should include the context prefix -def _choose_strategy(objs): - id_with_name = {} - for obj in objs: - if not isinstance(obj, str): - n = obj.__class__.__name__.lower() - try: - existing_id = id_with_name[n] - except KeyError: - id_with_name[n] = id(obj) - else: - if existing_id != id(obj): - return True - return False - def _bin(sn, sig_iters): status = [] for signal, it in sig_iters: step, last = next(it) status.append((signal, it, step, last)) - with_context_prefix = _choose_strategy(step[0] for signal, it, step, last in status) terminals = [] bins = {} for signal, it, step, last in status: - step_name = sn.name(with_context_prefix, step) + step_name = sn.get_step_str(step) if last: terminals.append((step_name, signal)) else: diff --git a/migen/fhdl/structure.py b/migen/fhdl/structure.py index 9946e29b..bf86e162 100644 --- a/migen/fhdl/structure.py +++ b/migen/fhdl/structure.py @@ -168,7 +168,7 @@ class Signal(Value): return id(self) def __repr__(self): - return "" + return "" # statements diff --git a/migen/fhdl/tracer.py b/migen/fhdl/tracer.py index c363eadd..8a782a48 100644 --- a/migen/fhdl/tracer.py +++ b/migen/fhdl/tracer.py @@ -42,7 +42,9 @@ def trace_back(name=None): if name is None: name = get_var_name(frame) - l.insert(0, (obj, name)) + if name is not None: + l.insert(0, name) + l.insert(0, obj) name = None frame = frame.f_back return l