Advertisement
Guest User

Untitled

a guest
Feb 24th, 2020
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.59 KB | None | 0 0
  1. `timescale 1ns / 1ps
  2. //////////////////////////////////////////////////////////////////////////////////
  3. // Company:
  4. // Engineer:
  5. //
  6. // Create Date: 07:04:55 01/14/2020
  7. // Design Name:
  8. // Module Name: swcounterupdated
  9. // Project Name:
  10. // Target Devices:
  11. // Tool versions:
  12. // Description:
  13. //
  14. // Dependencies:
  15. //
  16. // Revision:
  17. // Revision 0.01 - File Created
  18. // Additional Comments:
  19. //
  20. //////////////////////////////////////////////////////////////////////////////////
  21. module swcounterupdated(
  22. //inputs
  23. CLK, RST,
  24. //outputs
  25. M_H, M_L, S_H, S_L, PSE
  26. );
  27.  
  28. output reg[3:0] M_H = 4'b0; //tens digit of minutes
  29. output reg[3:0] M_L = 4'b0; //ones digit of minutes
  30. output reg[3:0] S_H = 4'b0; //tens digit of seconds
  31. output reg[3:0] S_L = 4'b0; //ones digit of seconds
  32. output reg[0:0] PSE = 1'b0;
  33.  
  34. input RST; //reset button
  35. input CLK; //2 Hz clock
  36.  
  37. always @(posedge CLK)
  38. begin
  39. if(RST)
  40. begin
  41. M_H = 4'b0; //tens digit of minutes
  42. M_L = 4'b0; //ones digit of minutes
  43. S_H = 4'b0; //tens digit of seconds
  44. S_L = 4'b0; //ones digit of seconds
  45. end
  46.  
  47. if(S_L == 4'b1010)
  48. begin
  49. S_H = S_H + 1;
  50. S_L = 4'b0;
  51. end
  52. else
  53. S_L = S_L + 1;
  54. begin
  55. end
  56.  
  57. if(S_H == 4'b0110)
  58. begin
  59. M_L = M_L + 1;
  60. S_H = 4'b0;
  61. end
  62. else
  63. //S_H = S_H + 1;
  64. begin
  65. end
  66.  
  67. if(M_L == 4'b1010)
  68. begin
  69. M_H = M_H + 1;
  70. M_L = 4'b0;
  71. end
  72. else
  73. //M_L = M_L + 1;
  74. begin
  75. end
  76.  
  77. if(M_H == 4'b0110)
  78. begin
  79. PSE = 1;
  80. end
  81. else
  82. //M_H = M_H + 1;
  83. begin
  84. end
  85.  
  86. end
  87.  
  88.  
  89. endmodule
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement