Guest User

Untitled

a guest
Aug 5th, 2018
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. module debounce_button (clk, butin, butout);
  2.         parameter DELAY = 250000;
  3.         input clk, butin;
  4.         output reg butout;
  5.         reg [19:0] count;
  6.        
  7.         always @(posedge clk)
  8.         begin
  9.                 if (butin == 0)
  10.                 begin
  11.                         count = (count == 20'b11111_11111_11111_11110) ? 20'b11111_11111_11111_11110 : count + 1;
  12.                         if (count == DELAY)
  13.                                 butout = 1;
  14.                         else
  15.                                 butout = 0;
  16.                 end
  17.                 else
  18.                 begin
  19.                         count = 0;
  20.                         butout = 0;
  21.                 end
  22.         end
  23. endmodule
Add Comment
Please, Sign In to add comment