Advertisement
Sidsh

Counter

Mar 25th, 2022
162
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.45 KB | None | 0 0
  1. // Code your design here
  2. module counter (clk,data,reset,count)
  3. input data;
  4. input clk;
  5. input reset;
  6. output reg [4:0] count;
  7.  
  8. reg flag =0;
  9.  
  10. always@(posedge clk)
  11. begin
  12. if (reset ==1)
  13. begin
  14. count<=0;
  15. end
  16. if (data ==1 && flag ==1)
  17. begin
  18. count=count +1;
  19. flag=0;
  20. end
  21. if (data==0)
  22. begin
  23. flag<=1;
  24. end
  25. end
  26. endmodule
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement