Guest User

Untitled

a guest
May 19th, 2018
129
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. module count_4bit(
  2.     input cin,
  3.     output cout,
  4.      output count [3:0]
  5.     );
  6. parameter timeconst = 60;//constant
  7. integer count0;
  8. integer count1;
  9. integer count2;
  10. integer count3;
  11.  
  12. reg d;
  13. reg count;
  14.  
  15. initial d = 1'b0;
  16.  
  17.  
  18.  
  19. always @ (posedge cin)//begin
  20.     begin
  21.         count0 <= (count0 + 1);
  22.         if ((count0 == timeconst))
  23.             begin
  24.                 count <= 0;
  25.                 count1 <= (count1 +1);
  26.             end
  27.         else if ((count1 == timeconst))
  28.             begin
  29.                 count1 <= 0;
  30.                 count2 <= (count2 + 1);
  31.             end
  32.         else if ((count2 == timeconst))
  33.             begin
  34.                 count2 <= 0;
  35.                 count3 <= (count3 + 1);
  36.             end
  37.         else if ((count3 == timeconst))
  38.             begin
  39.                 count3 <= 0;
  40.                 d <= ~ (d);
  41.             end
  42.     cout <= d;
  43. end
  44. endmodule
Add Comment
Please, Sign In to add comment