From 8963ab5d9f2c7900552cd7fd349b70cdc5340d28 Mon Sep 17 00:00:00 2001 From: whitequark Date: Thu, 13 Dec 2018 08:45:10 +0000 Subject: [PATCH] fhdl.xfrm: add test for ControlInserter with subfragments. --- nmigen/test/test_fhdl_xfrm.py | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) 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))) + ) + ) + """) -- 2.30.2