hdl._ir,hdl._nir,back.rtlil: new intermediate representation.
The new intermediate representation will enable global analyses on Amaranth code without lowering it to another representation such as RTLIL. This commit also changes the RTLIL builder to use the new IR. Co-authored-by: Wanda <wanda@phinode.net>
This commit is contained in:
parent
78981232d9
commit
6f44438e58
7 changed files with 2536 additions and 1048 deletions
|
|
@ -244,136 +244,6 @@ class DomainLowererTestCase(FHDLTestCase):
|
|||
DomainLowerer()(f)
|
||||
|
||||
|
||||
class SwitchCleanerTestCase(FHDLTestCase):
|
||||
def test_clean(self):
|
||||
a = Signal()
|
||||
b = Signal()
|
||||
c = Signal()
|
||||
stmts = [
|
||||
Switch(a, {
|
||||
1: a.eq(0),
|
||||
0: [
|
||||
b.eq(1),
|
||||
Switch(b, {1: [
|
||||
Switch(a|b, {})
|
||||
]})
|
||||
]
|
||||
})
|
||||
]
|
||||
|
||||
self.assertRepr(SwitchCleaner()(stmts), """
|
||||
(
|
||||
(switch (sig a)
|
||||
(case 1
|
||||
(eq (sig a) (const 1'd0)))
|
||||
(case 0
|
||||
(eq (sig b) (const 1'd1)))
|
||||
)
|
||||
)
|
||||
""")
|
||||
|
||||
|
||||
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_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):
|
||||
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,)),
|
||||
])
|
||||
|
||||
def test_lhs_empty(self):
|
||||
stmts = [
|
||||
Cat().eq(0)
|
||||
]
|
||||
|
||||
groups = LHSGroupAnalyzer()(stmts)
|
||||
self.assertEqual(list(groups.values()), [
|
||||
])
|
||||
|
||||
|
||||
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 )
|
||||
)
|
||||
)
|
||||
""")
|
||||
|
||||
def test_lhs_empty(self):
|
||||
stmts = [
|
||||
Cat().eq(0)
|
||||
]
|
||||
|
||||
self.assertRepr(LHSGroupFilter(SignalSet())(stmts), "()")
|
||||
|
||||
|
||||
class ResetInserterTestCase(FHDLTestCase):
|
||||
def setUp(self):
|
||||
self.s1 = Signal()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue