hdl.xfrm: transform drivers as well in DomainRenamer.
authorwhitequark <whitequark@whitequark.org>
Fri, 17 Jan 2020 02:13:46 +0000 (02:13 +0000)
committerwhitequark <whitequark@whitequark.org>
Fri, 17 Jan 2020 02:13:46 +0000 (02:13 +0000)
This is necessary because drivers may be late bound.

Fixes #304.

nmigen/hdl/xfrm.py
nmigen/test/test_hdl_ir.py

index 882ae94b6dc9e2902cb302732f62215617d24088..75f85ba6a24be76746ceb1418ea9c425c159ff8d 100644 (file)
@@ -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):
index fc4d0fe0eeb3ecb05621c6ed42f934dd93ae419a..4685523b93ed675b96b7dbefa97daeffdf242200 100644 (file)
@@ -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()