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.

46 lines
1.0 KiB

1 year ago
  1. module zutils_pluse_generator_v2 (
  2. input clk, //clock input
  3. input rst_n, //asynchronous reset input, low active
  4. input wire [31:0] pluse_width,
  5. input wire [31:0] pluse_delay,
  6. input wire trigger,
  7. output reg output_signal
  8. );
  9. reg [31:0] counter = 0;
  10. reg [31:0] tohigh_count = 0;
  11. reg [31:0] counter_init_count = 0;
  12. always @(*) begin
  13. tohigh_count <= pluse_width;
  14. counter_init_count <= pluse_width + pluse_delay;
  15. end
  16. always @(posedge clk or negedge rst_n) begin
  17. if (!rst_n) begin
  18. counter <= 0;
  19. output_signal <= 0;
  20. end else begin
  21. if (trigger) begin
  22. counter <= counter_init_count;
  23. output_signal <= 0;
  24. end else begin
  25. if (counter != 0) begin
  26. counter <= counter - 1;
  27. if (counter == tohigh_count) begin
  28. output_signal <= 1;
  29. end
  30. end else begin
  31. output_signal <= 0;
  32. counter <= 0;
  33. end
  34. end
  35. end
  36. end
  37. endmodule