From: Adam Greig Date: Sat, 6 Jun 2020 11:43:25 +0000 (+0100) Subject: hdl.xfrm: preserve allow_reset_less when transforming ResetSignal. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=0a3bfc9e987c41f9917cdac98a16f498cc8ce605;p=nmigen.git hdl.xfrm: preserve allow_reset_less when transforming ResetSignal. Fixes #400. --- diff --git a/nmigen/hdl/xfrm.py b/nmigen/hdl/xfrm.py index 4d83eb7..6e0c209 100644 --- a/nmigen/hdl/xfrm.py +++ b/nmigen/hdl/xfrm.py @@ -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): diff --git a/nmigen/test/test_hdl_xfrm.py b/nmigen/test/test_hdl_xfrm.py index 121c87f..394d349 100644 --- a/nmigen/test/test_hdl_xfrm.py +++ b/nmigen/test/test_hdl_xfrm.py @@ -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()