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.

clocks.v 1.0KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. // generate clocks
  2. module clocks
  3. #(
  4. parameter PRE_PWM = 28'd12,
  5. parameter PRE_7SEG = 28'd12,
  6. parameter PRE_COUNTER = 28'd12
  7. )
  8. (
  9. input clk, output clk_pwm, output clk_7seg, output clk_counter
  10. );
  11. reg [27:0] counter = 28'd0;
  12. reg [27:0] counter_7seg = 28'd0;
  13. reg [27:0] counter_counter = 28'd0;
  14. reg clk_pwm;
  15. reg clk_7seg;
  16. reg clk_counter;
  17. always @(posedge clk)
  18. begin
  19. counter <= counter + 28'd1;
  20. if(counter >= (PRE_PWM-1))
  21. counter <= 28'd0;
  22. clk_pwm <= ( counter < PRE_PWM/2) ? 1'b1 : 1'b0;
  23. end
  24. always @(posedge clk)
  25. begin
  26. counter_7seg <= counter_7seg + 28'd1;
  27. if(counter_7seg >= (PRE_7SEG-1))
  28. counter_7seg <= 28'd0;
  29. clk_7seg <= ( counter_7seg < PRE_7SEG/2) ? 1'b1 : 1'b0;
  30. end
  31. always @(posedge clk)
  32. begin
  33. counter_counter <= counter_counter + 28'd1;
  34. if(counter_counter >= (PRE_COUNTER-1))
  35. counter_counter <= 28'd0;
  36. clk_counter <= ( counter_counter < PRE_COUNTER/2) ? 1'b1 : 1'b0;
  37. end
  38. endmodule