//----------------------------------------------------------------------------- // Title : debounce // Project : ECE 491 - Senior Design I //----------------------------------------------------------------------------- // File : debounce.v // Author : John Nestor // Created : 19.08.2005 // Last modified : 19.08.2005 //----------------------------------------------------------------------------- // Description : // This circuit uses a shift register to remove mechanical bounce from a switch // input. It uses a 100 Hz clock and assumes an active-high input. //----------------------------------------------------------------------------- //------------------------------------------------------------------------------ // Modification history : // 19.08.2005 : created //----------------------------------------------------------------------------- module debounce (pb, clk_100Hz, pb_debounced); input pb; input clk_100Hz; output pb_debounced; reg pb_debounced; reg [3:0] shift_pb; always @ (posedge clk_100Hz) begin shift_pb [3:0] <= {shift_pb [2:0], pb}; if (shift_pb == 4'b1111) pb_debounced <= 1; else pb_debounced <= 0; end endmodule // debounce