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_reference.v 570B

1234567891011121314151617181920212223
  1. //////////////////////////////////////////////////////////////
  2. // 4-bit loadable up-down counter //////
  3. //////////////////////////////////////////////////////////////
  4. module counter(clk, rst, data, updown, load, data_out);
  5. input clk, rst, load;
  6. input updown;
  7. input [3:0] data;
  8. output reg [3:0] data_out;
  9. always @(posedge clk)
  10. begin
  11. if(rst)
  12. data_out <= 4'b0;
  13. else if(load)
  14. data_out <= data;
  15. else
  16. data_out <= ((updown)?(data_out + 1'b1):(data_out -1'b1));
  17. end
  18. endmodule