hdl.xfrm: implement LHSGroupAnalyzer.

This commit is contained in:
whitequark 2018-12-22 06:50:32 +00:00
parent 98a9744be4
commit ae0cb48fbb
2 changed files with 97 additions and 4 deletions

View file

@ -158,6 +158,52 @@ class DomainLowererTestCase(FHDLTestCase):
DomainLowerer({"sync": sync})(f)
class LHSGroupAnalyzerTestCase(FHDLTestCase):
def test_no_group_unrelated(self):
a = Signal()
b = Signal()
stmts = [
a.eq(0),
b.eq(0),
]
groups = LHSGroupAnalyzer()(stmts)
self.assertEqual(list(groups.values()), [
SignalSet((a,)),
SignalSet((b,)),
])
def test_group_related(self):
a = Signal()
b = Signal()
stmts = [
a.eq(0),
Cat(a, b).eq(0),
]
groups = LHSGroupAnalyzer()(stmts)
self.assertEqual(list(groups.values()), [
SignalSet((a, b)),
])
def test_switch(self):
a = Signal()
b = Signal()
stmts = [
a.eq(0),
Switch(a, {
1: b.eq(0),
})
]
groups = LHSGroupAnalyzer()(stmts)
self.assertEqual(list(groups.values()), [
SignalSet((a,)),
SignalSet((b,)),
])
class ResetInserterTestCase(FHDLTestCase):
def setUp(self):
self.s1 = Signal()