From: Sebastien Bourdeauducq Date: Fri, 22 Mar 2013 17:17:54 +0000 (+0100) Subject: fhdl/module: support clock domain remapping of submodules X-Git-Tag: 24jan2021_ls180~2099^2~629 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=ca431fc7c23893d9940b3a3f0bc273c45ec73626;p=litex.git fhdl/module: support clock domain remapping of submodules --- diff --git a/migen/fhdl/module.py b/migen/fhdl/module.py index 29750c06..5cf7a7bb 100644 --- a/migen/fhdl/module.py +++ b/migen/fhdl/module.py @@ -67,11 +67,11 @@ class _ModuleSpecials(_ModuleProxy, _ModuleForwardAttr): class _ModuleSubmodules(_ModuleProxy): def __setattr__(self, name, value): - self._fm._submodules += [(name, e) for e in _flat_list(value)] + self._fm._submodules += [(name, e, dict()) for e in _flat_list(value)] setattr(self._fm, name, value) def __iadd__(self, other): - self._fm._submodules += [(None, e) for e in _flat_list(other)] + self._fm._submodules += [(None, e, dict()) for e in _flat_list(other)] return self class _ModuleClockDomains(_ModuleProxy, _ModuleForwardAttr): @@ -130,8 +130,20 @@ class Module: else: object.__setattr__(self, name, value) + def add_submodule(self, submodule, cd_remapping=dict(), name=None): + if isinstance(cd_remapping, str): + cd_remapping = {"sys": cd_remapping} + if name is not None: + setattr(self, name, submodule) + self._submodules.append((name, submodule, cd_remapping)) + def _collect_submodules(self): - r = [(name, submodule.get_fragment()) for name, submodule in self._submodules] + r = [] + for name, submodule, cd_remapping in self._submodules: + f = submodule.get_fragment() + for old, new in cd_remapping.items(): + rename_clock_domain(f, old, new) + r.append((name, f)) self._submodules = [] return r