From 7777b7b98c5f075d5dfa5770f755a7c58925ff47 Mon Sep 17 00:00:00 2001 From: whitequark Date: Mon, 23 Sep 2019 12:48:02 +0000 Subject: [PATCH] back.rtlil: give predictable names to anonymous subfragments. This is required for applying constraints to clocks in anonymous subfragments in build.plat. --- nmigen/back/rtlil.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/nmigen/back/rtlil.py b/nmigen/back/rtlil.py index c5a0f5d..9412be4 100644 --- a/nmigen/back/rtlil.py +++ b/nmigen/back/rtlil.py @@ -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(): -- 2.30.2