From: whitequark Date: Thu, 13 Dec 2018 08:45:10 +0000 (+0000) Subject: fhdl.xfrm: add test for ControlInserter with subfragments. X-Git-Tag: working~304 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=8963ab5d9f2c7900552cd7fd349b70cdc5340d28;p=nmigen.git fhdl.xfrm: add test for ControlInserter with subfragments. --- diff --git a/nmigen/test/test_fhdl_xfrm.py b/nmigen/test/test_fhdl_xfrm.py index f7e45ad..b569601 100644 --- a/nmigen/test/test_fhdl_xfrm.py +++ b/nmigen/test/test_fhdl_xfrm.py @@ -142,3 +142,36 @@ class CEInserterTestCase(unittest.TestCase): ) ) """) + + def test_ce_subfragment(self): + f1 = Fragment() + f1.add_statements( + self.s1.eq(1) + ) + f1.drive(self.s1, "sync") + + f2 = Fragment() + f2.add_statements( + self.s2.eq(1) + ) + f2.drive(self.s2, "sync") + f1.add_subfragment(f2) + + f1 = CEInserter(self.c1)(f1) + (f2, _), = f1.subfragments + self.assertRepr(f1.statements, """ + ( + (eq (sig s1) (const 1'd1)) + (switch (sig c1) + (case 0 (eq (sig s1) (sig s1))) + ) + ) + """) + self.assertRepr(f2.statements, """ + ( + (eq (sig s2) (const 1'd1)) + (switch (sig c1) + (case 0 (eq (sig s2) (sig s2))) + ) + ) + """)