From: whitequark Date: Fri, 17 Jan 2020 02:13:46 +0000 (+0000) Subject: hdl.xfrm: transform drivers as well in DomainRenamer. X-Git-Tag: v0.2~37 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=7cb3095334f7734d15ec9d350043b448c7c5e66d;p=nmigen.git hdl.xfrm: transform drivers as well in DomainRenamer. This is necessary because drivers may be late bound. Fixes #304. --- diff --git a/nmigen/hdl/xfrm.py b/nmigen/hdl/xfrm.py index 882ae94..75f85ba 100644 --- a/nmigen/hdl/xfrm.py +++ b/nmigen/hdl/xfrm.py @@ -482,7 +482,7 @@ class DomainRenamer(FragmentTransformer, ValueTransformer, StatementTransformer) if domain in self.domain_map: domain = self.domain_map[domain] for signal in signals: - new_fragment.add_driver(signal, domain) + new_fragment.add_driver(self.on_value(signal), domain) class DomainLowerer(FragmentTransformer, ValueTransformer, StatementTransformer): diff --git a/nmigen/test/test_hdl_ir.py b/nmigen/test/test_hdl_ir.py index fc4d0fe..4685523 100644 --- a/nmigen/test/test_hdl_ir.py +++ b/nmigen/test/test_hdl_ir.py @@ -389,6 +389,25 @@ class FragmentDomainsTestCase(FHDLTestCase): "domains explicitly, or give distinct names to subfragments"): f._propagate_domains_up() + def test_domain_conflict_rename_drivers(self): + cda = ClockDomain("sync") + cdb = ClockDomain("sync") + + fa = Fragment() + fa.add_domains(cda) + fb = Fragment() + fb.add_domains(cdb) + fb.add_driver(ResetSignal("sync"), None) + f = Fragment() + f.add_subfragment(fa, "a") + f.add_subfragment(fb, "b") + + f._propagate_domains_up() + fb_new, _ = f.subfragments[1] + self.assertEqual(fb_new.drivers, OrderedDict({ + None: SignalSet((ResetSignal("b_sync"),)) + })) + def test_propagate_down(self): cd = ClockDomain()