hdl.xfrm: preserve allow_reset_less when transforming ResetSignal.
authorAdam Greig <adam@adamgreig.com>
Sat, 6 Jun 2020 11:43:25 +0000 (12:43 +0100)
committerLuke Kenneth Casson Leighton <lkcl@lkcl.net>
Fri, 31 Dec 2021 13:39:52 +0000 (13:39 +0000)
Fixes #400.

nmigen/hdl/xfrm.py
nmigen/test/test_hdl_xfrm.py

index 4d83eb72663fdb6639db0627e2d2937b086f2d5b..6e0c209ffa3cce61e5c0de6e901ce9ceb71d207e 100644 (file)
@@ -453,7 +453,8 @@ class DomainRenamer(FragmentTransformer, ValueTransformer, StatementTransformer)
 
     def on_ResetSignal(self, value):
         if value.domain in self.domain_map:
-            return ResetSignal(self.domain_map[value.domain])
+            return ResetSignal(self.domain_map[value.domain],
+                               allow_reset_less=value.allow_reset_less)
         return value
 
     def map_domains(self, fragment, new_fragment):
index 121c87f10cb4b174d6d97094fe06f5ce2632e2c6..394d3497bb2d7f0b3345932063742541c6278a6c 100644 (file)
@@ -74,6 +74,24 @@ class DomainRenamerTestCase(FHDLTestCase):
             "pix": cd_pix,
         })
 
+    def test_rename_cd_preserves_allow_reset_less(self):
+        cd_pix  = ClockDomain(reset_less=True)
+
+        f = Fragment()
+        f.add_domains(cd_pix)
+        f.add_statements(
+            self.s1.eq(ResetSignal(allow_reset_less=True)),
+        )
+
+        f = DomainRenamer("pix")(f)
+        f = DomainLowerer()(f)
+        self.assertRepr(f.statements, """
+        (
+            (eq (sig s1) (const 1'd0))
+        )
+        """)
+
+
     def test_rename_cd_subfragment(self):
         cd_sync = ClockDomain()
         cd_pix  = ClockDomain()