SDVD/design/debouncer.sv
Waylon Cude a50efdc6c6 Fixed up debouncer and added some assertions
I moved around where packages are. I couldn't find any evidence of where
other people put them, but for now they are in the `lib/` folder. Other
infrastructure changes are that all the weird includes we need to make
the linter happy are gated behind ifdefs, so they don't mess with
vivado.

I kinda can't believe concurrent assertions work because there's so
little info about them, good to ssee they actually do something
2025-05-30 13:56:52 -07:00

23 lines
457 B
Systemverilog

//NOTE: you should drive this with a slow clock to actually debounce input
module debouncer(input logic clk, input reset, input source, output logic out);
logic pressed;
always_ff @(posedge clk) begin
if (reset)
pressed <= 0;
if (!source) begin
pressed <= 0;
out <= 0;
end
else
if (pressed)
out <= 0;
else begin
pressed <= 1;
out <= 1;
end
end
endmodule