eddie_b
Newbie level 2
- Joined
- Mar 16, 2013
- Messages
- 2
- Helped
- 0
- Reputation
- 0
- Reaction score
- 0
- Trophy points
- 1,281
- Activity points
- 1,295
Hi everyone, I'm trying to build a debouncer for an 8-bit counter that registers how many times the button is pushed that differentiates between a full push and release and the button being held down. In other words, the output should be the "clean" number of times the button was fully pushed and released. I also want to include a reset. At the moment, I'm a bit stuck and I don't know what to do. I'm also unable to test it at the moment because I have to be at home all day today. Would anyone please be able to give me some advice for the code I have? Would this code work?
Thank you, so greatly appreciate it.
Code:
module debouncer(clock, reset, bounce, y);
input clock;
input reset;
input bounce;
output reg [7:0] y;
reg bounce;
reg value;
reg [32:0] counter;
parameter delay = 50000;
always @ (posedge btn or posedge rst)
begin
if (bounce)
begin
if (bounce != value)
begin
value <= bounce;
counter <= 32'b0;
end
else if (counter = = delay)
begin
y <= value;
end
else
begin
counter <= counter + 1'b1;
end
end
if (reset)
begin
y <= 1'b0;
end
end
endmodule
Thank you, so greatly appreciate it.
Last edited: