Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from amaranth.sim import Simulator
- from buttons import ButtonDevice, Button
- def set_buttons(dut, value):
- for button in dut.buttons:
- yield button.eq(value)
- def set_button(dut, button, value):
- yield dut.buttons[button].eq(value)
- dut = ButtonDevice()
- def bench():
- # `out` should remain false if disabled
- yield dut.en.eq(0)
- set_buttons(dut, 1)
- yield
- assert not (yield dut.out)
- # `out` should be true if enabled and both buttons are true
- yield dut.en.eq(1)
- yield
- # assert (yield dut.out)
- sim = Simulator(dut)
- sim.add_clock(1e-6) # 1 MHz
- sim.add_sync_process(bench)
- with sim.write_vcd("buttons.vcd"):
- sim.run()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement