Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- module debounce_button (clk, butin, butout);
- parameter DELAY = 250000;
- input clk, butin;
- output reg butout;
- reg [19:0] count;
- always @(posedge clk)
- begin
- if (butin == 0)
- begin
- count = (count == 20'b11111_11111_11111_11110) ? 20'b11111_11111_11111_11110 : count + 1;
- if (count == DELAY)
- butout = 1;
- else
- butout = 0;
- end
- else
- begin
- count = 0;
- butout = 0;
- end
- end
- endmodule
Add Comment
Please, Sign In to add comment