here is my debouncer module:
- Code: Select all
module debouncer(clk,button,out,counter);
input clk;
input button;
output reg out;
output reg [20:0] counter;
reg counting;
wire same = (out==button);
always @(posedge clk)
begin
if(!same) counting <= 1;
if(counting) counter <= counter + 1;
if(counter == 100) counter <= 0; out <= button; counting <= 0;
end
endmodule
the idea is that if the button input differs from the output register, the counter starts.
when the counter has finished counting, the counter is emptied, the output is set to the button input, and the counting ceases.
the compiler reduces the counting reg to GND, because the reg's D port is 'stuck'.
here is the actual message:
- Code: Select all
Warning (14130): Reduced register "debouncer:inst1|counting" with stuck data_in port to stuck value GND
how is it stuck, shouldn't it be loaded with a 1 as soon as the input is different from the output?
i notice that this code is very small in comparison to the debouncer on this site, why would this circuit be inadequate?