From: whitequark Date: Mon, 23 Sep 2019 12:48:02 +0000 (+0000) Subject: back.rtlil: give predictable names to anonymous subfragments. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=ddd61e74cb395eb2d2f13879d9f9bb65dd2a306d;p=nmigen.git back.rtlil: give predictable names to anonymous subfragments. This is required for applying constraints to clocks in anonymous subfragments in build.plat. --- 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():