Verwendeter Programmcode in Studienarbeit für ESY1B zum Thema "Verifikation mit SystemVerilog und Python"
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

counter_4bit_conv.py 837B

123456789101112131415161718192021222324252627282930313233
  1. import myhdl
  2. from myhdl import *
  3. @block
  4. def counter_4bit(clk, rst, data, updown, load, data_out):
  5. @always(clk.posedge)
  6. def cycle():
  7. if rst:
  8. data_out.next = 0
  9. elif load:
  10. data_out.next = data
  11. else:
  12. if updown:
  13. data_out.next = data_out + 1
  14. else:
  15. data_out.next = data_out - 1
  16. return cycle
  17. def convert():
  18. clk = Signal(bool(0))
  19. rst = Signal(bool(0)) # nur sync reset hier
  20. # reset = ResetSignal(0, active=0, isasync=True)
  21. updown = Signal(bool(0))
  22. load = Signal(bool(0))
  23. data = Signal(modbv(val=0, min=0, max=15)[4:])
  24. data_out = Signal(modbv(val=0, min=0, max=15)[4:])
  25. inst = counter_4bit(clk, rst, data, updown, load, data_out)
  26. inst.convert(hdl='Verilog')
  27. # inst.convert(hdl='VHDL')