back.rtlil: give predictable names to anonymous subfragments.
authorwhitequark <whitequark@whitequark.org>
Mon, 23 Sep 2019 12:48:02 +0000 (12:48 +0000)
committerwhitequark <whitequark@whitequark.org>
Mon, 23 Sep 2019 12:48:02 +0000 (12:48 +0000)
This is required for applying constraints to clocks in anonymous
subfragments in build.plat.

nmigen/back/rtlil.py

index c5a0f5de50c472927a3f18b4f5de92fb7cc751a2..9412be447baeb6cb8ab2bca216630acc1eb7891e 100644 (file)
@@ -13,9 +13,16 @@ __all__ = ["convert", "convert_fragment"]
 class _Namer:
     def __init__(self):
         super().__init__()
+        self._anon  = 0
         self._index = 0
         self._names = set()
 
+    def anonymous(self):
+        name = "U$${}".format(self._anon)
+        assert name not in self._names
+        self._anon += 1
+        return name
+
     def _make_name(self, name, local):
         if name is None:
             self._index += 1
@@ -772,6 +779,9 @@ def _convert_fragment(builder, fragment, name_map, hierarchy):
             if not subfragment.ports:
                 continue
 
+            if sub_name is None:
+                sub_name = module.anonymous()
+
             sub_params = OrderedDict()
             if hasattr(subfragment, "parameters"):
                 for param_name, param_value in subfragment.parameters.items():