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.

digit_driver.v 1.1KB

3 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. `include "bcd_to_7seg.v"
  2. module digit_driver
  3. #(
  4. parameter D = 28'd0
  5. )
  6. (
  7. input clk, input [19:0] number, input dot, output [7:0] segs, output [4:0] digs
  8. );
  9. // io for 7seg
  10. reg [2:0] active_digit;
  11. wire [4:0] buf_digs;
  12. wire [19:0] number;
  13. wire [3:0] a_number;
  14. wire [6:0] seg_out;
  15. bcd_to_7seg bcd_to_7seg_inst(
  16. .bcd_in(a_number),
  17. .seg_out(seg_out)
  18. );
  19. // see bcd_to_7seg.v for segments placement
  20. // common anode ~seg_out[], common cathode seg_out[]
  21. assign segs = { dot, seg_out };
  22. assign buf_digs = (number > 20'hFFFF) ? 5'b11111 :
  23. (number > 20'hFFF) ? 5'b01111 :
  24. (number > 20'hFF) ? 5'b00111 :
  25. (number > 20'hF) ? 5'b00011 :
  26. 5'b00001; // default shouldn't happen
  27. assign digs = buf_digs & (1'b1 << active_digit);
  28. assign a_number = (number & (4'b1111 << (active_digit*4))) >> (active_digit*4);
  29. always @(posedge clk)
  30. begin
  31. active_digit <= active_digit + 1'b1;
  32. if(active_digit > 3'd3)
  33. active_digit <= 1'b0;
  34. end
  35. endmodule