1
0
Fork 0
mirror of https://git.sr.ht/~kivikakk/niar synced 2024-12-23 08:52:24 +00:00
niar/docs/template/tests/test_top.py

25 lines
564 B
Python
Raw Normal View History

2024-06-16 14:19:44 +00:00
from amaranth.hdl import Fragment
from amaranth.sim import Simulator
from newproject.rtl import Blinker
class test:
simulation = True
default_clk_frequency = 8.0
2024-07-02 09:59:02 +00:00
def test_blinks():
dut = Blinker()
2024-06-16 14:19:44 +00:00
2024-07-02 09:59:02 +00:00
async def testbench(ctx):
for ledr in [0, 1, 1, 0, 0, 1, 1, 0]:
for _ in range(2):
assert ctx.get(dut.ledr) == ledr
assert ctx.get(dut.ledg)
await ctx.tick()
2024-06-16 14:19:44 +00:00
2024-07-02 09:59:02 +00:00
sim = Simulator(Fragment.get(dut, test()))
sim.add_clock(1 / 8)
sim.add_testbench(testbench)
sim.run()