module debounce (clock, noisy, clean); parameter DELAY = 500000; // .01 sec with a 50MHz clock input clock, noisy; output clean; reg [18:0] count; reg ne, clean; always @(posedge clock) if (noisy != ne) begin ne <= noisy; count <= 0; end else if (count == DELAY) clean <= ne; else count <= count+1; endmodule // debounce