Simple filter and debounce circuit
This is a simple filter for single-bit serial inputs, digital I/O or can also be used as part of a debounce circuit for pushbuttons and dipswitches.
It will eliminate any high or low pulses that are less then a certain number of clocks - this is specified by the gNclks generic. It works by counting
the length of time that the input is high (or low) and then setting the output to high (or low) when it has been in that state for gNclks periods.
When setting the number of gClks, take care to ensure that it is considerably less than the minimum expected high or low time of the incoming signal - the idea is to filter glitches, not eliminate valid pulses.
The circuit can also be used to filter out the
bounce noise from a switch input, but this may require a very slow clock to be created - see the note about
dividing clocks using SRLs for hints on how to do this.
The code for the filter along with a testbench can be downloaded from my git hub page.