sim: group signal traces according to their function.

This commit is contained in:
Marek Materzok 2024-05-22 10:40:34 +02:00 committed by Catherine
parent 89eae72a41
commit 51e0262710
3 changed files with 109 additions and 28 deletions

View file

@ -16,7 +16,7 @@ from amaranth.hdl._ir import *
from amaranth.sim import *
from amaranth.sim._pyeval import eval_format
from amaranth.lib.memory import Memory
from amaranth.lib import enum, data
from amaranth.lib import enum, data, wiring
from .utils import *
from amaranth._utils import _ignore_deprecated
@ -1393,6 +1393,49 @@ class SimulatorIntegrationTestCase(FHDLTestCase):
sim.add_testbench(testbench)
class SimulatorTracesTestCase(FHDLTestCase):
def assertDef(self, traces, flat_traces):
frag = Fragment()
def process():
yield Delay(1e-6)
sim = Simulator(frag)
sim.add_testbench(process)
with sim.write_vcd("test.vcd", "test.gtkw", traces=traces):
sim.run()
def test_signal(self):
a = Signal()
self.assertDef(a, [a])
def test_list(self):
a = Signal()
self.assertDef([a], [a])
def test_tuple(self):
a = Signal()
self.assertDef((a,), [a])
def test_dict(self):
a = Signal()
self.assertDef({"a": a}, [a])
def test_struct_view(self):
a = Signal(data.StructLayout({"a": 1, "b": 3}))
self.assertDef(a, [a])
def test_interface(self):
sig = wiring.Signature({
"a": wiring.In(1),
"b": wiring.Out(3),
"c": wiring.Out(2).array(4),
"d": wiring.In(wiring.Signature({"e": wiring.In(5)}))
})
a = sig.create()
self.assertDef(a, [a])
class SimulatorRegressionTestCase(FHDLTestCase):
def test_bug_325(self):
dut = Module()