hdl.xfrm: avoid cycles in union-find graph in LHSGroupAnalyzer.
This commit is contained in:
parent
3448953f61
commit
621dddebfd
|
@ -298,6 +298,8 @@ class LHSGroupAnalyzer(StatementVisitor):
|
||||||
root_group = self.find(root)
|
root_group = self.find(root)
|
||||||
for leaf in leaves:
|
for leaf in leaves:
|
||||||
leaf_group = self.find(leaf)
|
leaf_group = self.find(leaf)
|
||||||
|
if root_group == leaf_group:
|
||||||
|
continue
|
||||||
self.unions[leaf_group] = root_group
|
self.unions[leaf_group] = root_group
|
||||||
|
|
||||||
def groups(self):
|
def groups(self):
|
||||||
|
|
|
@ -186,6 +186,20 @@ class LHSGroupAnalyzerTestCase(FHDLTestCase):
|
||||||
SignalSet((a, b)),
|
SignalSet((a, b)),
|
||||||
])
|
])
|
||||||
|
|
||||||
|
def test_no_loops(self):
|
||||||
|
a = Signal()
|
||||||
|
b = Signal()
|
||||||
|
stmts = [
|
||||||
|
a.eq(0),
|
||||||
|
Cat(a, b).eq(0),
|
||||||
|
Cat(a, b).eq(0),
|
||||||
|
]
|
||||||
|
|
||||||
|
groups = LHSGroupAnalyzer()(stmts)
|
||||||
|
self.assertEqual(list(groups.values()), [
|
||||||
|
SignalSet((a, b)),
|
||||||
|
])
|
||||||
|
|
||||||
def test_switch(self):
|
def test_switch(self):
|
||||||
a = Signal()
|
a = Signal()
|
||||||
b = Signal()
|
b = Signal()
|
||||||
|
|
Loading…
Reference in a new issue