Advertisement
Guest User

Untitled

a guest
Apr 8th, 2022
42
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.67 KB | None | 0 0
  1. from amaranth.sim import Simulator
  2. from buttons import ButtonDevice, Button
  3.  
  4. def set_buttons(dut, value):
  5.     for button in dut.buttons:
  6.         yield button.eq(value)
  7.  
  8. def set_button(dut, button, value):
  9.     yield dut.buttons[button].eq(value)
  10.  
  11. dut = ButtonDevice()
  12. def bench():
  13.     # `out` should remain false if disabled
  14.     yield dut.en.eq(0)
  15.     set_buttons(dut, 1)
  16.     yield
  17.     assert not (yield dut.out)
  18.  
  19.     # `out` should be true if enabled and both buttons are true
  20.     yield dut.en.eq(1)
  21.     yield
  22. #    assert (yield dut.out)
  23.  
  24. sim = Simulator(dut)
  25. sim.add_clock(1e-6) # 1 MHz
  26. sim.add_sync_process(bench)
  27. with sim.write_vcd("buttons.vcd"):
  28.     sim.run()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement