hdl.xfrm, back.rtlil: implement and use LHSGroupFilter.

This is a refactoring to simplify reusing the filtering code in
simulation, and separate that concern from backends in general.
This commit is contained in:
whitequark 2018-12-24 02:17:28 +00:00
parent 1c7c75a254
commit 98f554aa08
3 changed files with 59 additions and 36 deletions

View file

@ -168,7 +168,9 @@ class SwitchCleanerTestCase(FHDLTestCase):
1: a.eq(0),
0: [
b.eq(1),
Switch(b, {1: []})
Switch(b, {1: [
Switch(a|b, {})
]})
]
})
]
@ -244,6 +246,31 @@ class LHSGroupAnalyzerTestCase(FHDLTestCase):
])
class LHSGroupFilterTestCase(FHDLTestCase):
def test_filter(self):
a = Signal()
b = Signal()
c = Signal()
stmts = [
Switch(a, {
1: a.eq(0),
0: [
b.eq(1),
Switch(b, {1: []})
]
})
]
self.assertRepr(LHSGroupFilter(SignalSet((a,)))(stmts), """
(
(switch (sig a)
(case 1
(eq (sig a) (const 1'd0)))
(case 0 )
)
)
""")
class ResetInserterTestCase(FHDLTestCase):
def setUp(self):