back.pysim: give better names to unnamed fragments and their signals.
authorwhitequark <cz@m-labs.hk>
Sat, 26 Jan 2019 18:07:16 +0000 (18:07 +0000)
committerwhitequark <cz@m-labs.hk>
Sat, 26 Jan 2019 18:07:16 +0000 (18:07 +0000)
Was: top.#0, top.None_clk
Now: top.U0, top.U0_clk

(U for Unnamed, or similarly, an unit refdes.)

nmigen/back/pysim.py

index 962d0e0f1a7b1ea7ba6af2a8a20614557212326b..58e9d8c789b0908a7ad3033624073133379b02e9 100644 (file)
@@ -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