Advertisement
Guest User

Untitled

a guest
Mar 23rd, 2017
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.45 KB | None | 0 0
  1. module Chattering(clk, switch, led);
  2. input clk, switch;
  3. output [3:0] led;
  4. reg [3:0] ff;
  5. reg [15:0] cnt;
  6. reg swreg;
  7. wire c_clk, sw_out;
  8.  
  9. //16bit Counter
  10. always @(posedge clk) begin
  11. cnt=cnt+1;
  12. end
  13. assign c_clk=cnt[15]; //clock for chattering inhibit
  14.  
  15. //switch latch
  16. always @(posedge c_clk) begin
  17. swreg=switch;
  18. end
  19. assign sw_out=swreg;
  20.  
  21. always @(posedge sw_out) begin
  22. if(ff==4'h9)
  23. ff=4'h0;
  24. else
  25. ff=ff+1;
  26. end
  27. assign led=ff;
  28. endmodule
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement