From 02e30b53ccee18d136352781c906102c030faaee Mon Sep 17 00:00:00 2001 From: Adam Greig Date: Sat, 6 Jun 2020 12:43:25 +0100 Subject: [PATCH] hdl.xfrm: preserve allow_reset_less when transforming ResetSignal. Fixes #400. --- nmigen/hdl/xfrm.py | 3 ++- nmigen/test/test_hdl_xfrm.py | 18 ++++++++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) 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() -- 2.30.2