Advertisement
Guest User

Untitled

a guest
Jul 16th, 2021
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.89 KB | None | 0 0
  1. module top (
  2. input wire sync,
  3. output wire valid,
  4. output wire armed,
  5. input wire clk
  6. );
  7.  
  8. reg samp_sync;
  9. reg [2:0] samp_cnt;
  10. reg samp_valid;
  11.  
  12. always @(posedge clk)
  13. if (samp_sync)
  14. samp_cnt <= 3'b101;
  15. else
  16. case (samp_cnt)
  17. 3'b000: samp_cnt <= 3'b011;
  18. 3'b001: samp_cnt <= 3'b000;
  19. 3'b010: samp_cnt <= 3'b001;
  20. 3'b011: samp_cnt <= 3'b010;
  21. 3'b100: samp_cnt <= 3'b011;
  22. 3'b101: samp_cnt <= 3'b100;
  23. 3'b110: samp_cnt <= 3'b101;
  24. 3'b111: samp_cnt <= 3'b110;
  25. default: samp_cnt <= 3'bxxx;
  26. endcase
  27.  
  28. always @(posedge clk)
  29. begin
  30. samp_sync <= sync;
  31. samp_valid <= (samp_cnt[1:0] == 2'b10) & ~samp_valid;
  32. end
  33.  
  34. assign valid = samp_valid;
  35. assign armed = samp_cnt[2];
  36.  
  37. endmodule
  38.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement