Advertisement
Guest User

Untitled

a guest
Dec 9th, 2019
147
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. module counter(input clk,
  2.                input cmd,
  3.                output reg [4:0] out = 0);
  4.  
  5. always @(posedge clk) begin
  6.  
  7.     if (0 == cmd) begin
  8.         out = out + 1;
  9.  
  10.         if (31 == out)
  11.        out = 0;
  12.     end
  13.     else
  14.         if (0 == out)
  15.             out = 29;
  16.         else
  17.             if (1 == out)
  18.             out = 30;
  19.         else
  20.                     out = out - 2;
  21. end
  22. endmodule
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement