Altera_Forum
Honored Contributor
15 years agoDebouncer verilog code
Hi you
I wrote a simple code for a debouncer circuit, and I appreciate if you can have a look and correct what's wrong.
module debouncer (noisy,clk_1KHz,debounced);
input wire clk_1KHz, noisy;
output wire debounced;
reg cnt;
//counter: waits that button is pressed at least 10ms
always @ (posedge clk_1KHz)
begin
if (noisy) cnt <= cnt + 1'b1;
else cnt <= 0;
end
assign debounced = (cnt==4'b1010) ? 1'b1 : 1'b0;
endmodule
what you think about it?:confused: thank you all GP