Advertisement
STANAANDREY

Untitled

Nov 7th, 2024 (edited)
33
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.16 KB | None | 0 0
  1. module seconds_counter(
  2. input clk,
  3. output secsBus,
  4. input rst
  5. );
  6. reg [15:0] cycleCnt = 0;
  7. reg [9:0] timeCnt = 0;
  8. reg secsPassed = 0;
  9.  
  10. parameter CYCLES_PER_10ms = 50_000/2;
  11. parameter TICKS_PER_SEC = 1000;
  12.  
  13. always @(posedge clk) begin
  14. if (cycleCnt == CYCLES_PER_10ms - 1) begin
  15. cycleCnt <= 0;
  16. timeCnt <= timeCnt + 1;
  17. if (timeCnt == TICKS_PER_SEC - 1) begin
  18. timeCnt <= 0;
  19. secsPassed <= ~secsPassed;
  20. end
  21. end else begin
  22. cycleCnt <= cycleCnt + 1;
  23. end
  24. end
  25. assign secsBus = secsPassed;
  26. endmodule
  27.  
  28. module minutes_counter(
  29. input clk,
  30. output [5:0] minsBus,
  31. input rst
  32. );
  33. wire secsBus;
  34. reg [5:0] minsPassed = 0;
  35.  
  36. parameter SECS_IN_MIN = 5;
  37.  
  38. reg secsRst;
  39.  
  40.  
  41. seconds_counter sec_counter (
  42. .clk(clk),
  43. .secsBus(secsBus),
  44. .rst(rst)
  45. );
  46.  
  47. reg [5:0] secsCnt = 0;
  48. always @(posedge secsBus) begin
  49.  
  50. if (secsCnt == SECS_IN_MIN) begin
  51. minsPassed = minsPassed + 1;
  52. secsCnt = 0;
  53. end else begin
  54. secsCnt = secsCnt + 1;
  55. end
  56. end
  57.  
  58. assign minsBus = minsPassed;
  59. endmodule
  60.  
  61. module hex(
  62.  
  63. );
  64.  
  65. endmodule
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement