Created
October 6, 2021 17:20
-
-
Save bit-hack/645fd2da1dc6ddb4fc1448d822a53e55 to your computer and use it in GitHub Desktop.
A simple verilog debouncer circuit
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module debounce( | |
input clk, | |
input iKey, | |
output oOut, | |
); | |
reg [3:0] state; | |
assign oOut = state[3]; | |
always @(posedge clk) begin | |
if (iKey) begin | |
state <= (state == 4'hf) ? 4'hf : (state + 1); | |
end else begin | |
state <= (state == 4'h0) ? 4'h0 : (state - 1); | |
end | |
end | |
endmodule |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment