From: whitequark Date: Sat, 26 Jan 2019 18:07:16 +0000 (+0000) Subject: back.pysim: give better names to unnamed fragments and their signals. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=62addf99d135887ce54960dcf589b0e3c5d3f4fa;p=nmigen.git back.pysim: give better names to unnamed fragments and their signals. Was: top.#0, top.None_clk Now: top.U0, top.U0_clk (U for Unnamed, or similarly, an unit refdes.) --- diff --git a/nmigen/back/pysim.py b/nmigen/back/pysim.py index 962d0e0..58e9d8c 100644 --- a/nmigen/back/pysim.py +++ b/nmigen/back/pysim.py @@ -454,7 +454,7 @@ class Simulator: hierarchy[fragment] = scope for index, (subfragment, name) in enumerate(fragment.subfragments): if name is None: - add_fragment(subfragment, (*scope, "#{}".format(index))) + add_fragment(subfragment, (*scope, "U{}".format(index))) else: add_fragment(subfragment, (*scope, name)) add_fragment(root_fragment, scope=("top",)) @@ -504,9 +504,9 @@ class Simulator: signal_slot = self._signal_slots[signal] - for subfragment, name in fragment.subfragments: + for i, (subfragment, name) in enumerate(fragment.subfragments): if signal in subfragment.ports: - var_name = "{}_{}".format(name, signal.name) + var_name = "{}_{}".format(name or "U{}".format(i), signal.name) break else: var_name = signal.name