From 024ca37a93c2c2c7e7e6f917c3a79e75511af9cd Mon Sep 17 00:00:00 2001 From: whitequark Date: Fri, 17 Jan 2020 02:13:46 +0000 Subject: [PATCH] hdl.xfrm: transform drivers as well in DomainRenamer. This is necessary because drivers may be late bound. Fixes #304. --- nmigen/hdl/xfrm.py | 2 +- nmigen/test/test_hdl_ir.py | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) 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() -- 2.30.2