Simple Debounce VHDL example code.

Written by Tom on Monday 28/05/07


Any FPGA that has external signals via a pushbutton will suffer from contact bounce.


Definition:

Contact bounce (also called chatter) is a common problem with mechanical switches and relays. Switch and relay contacts are usually made of springy metals that are forced into contact by an actuator. When the contacts strike together, their momentum and elasticity act together to cause bounce. The result is a rapidly pulsed electrical current instead of a clean transition from zero to full current. The waveform is then further modified by the parasitic inductances and capacitances in the switch and wiring, resulting in a series of damped sinusoidal oscillations. This effect is usually unnoticeable in AC mains circuits, where the bounce happens too quickly to affect most equipment, but causes problems in some analogue and logic circuits that are not designed to cope with oscillating voltages.


Sequential digital logic circuits are particularly vulnerable to contact bounce. The voltage waveform produced by switch bounce usually violates the amplitude and timing specifications of the logic circuit. The result is that the circuit may fail, due to problems such as metastability, race conditions, runt pulses and glitches.


There are a number of techniques for debouncing (mitigating the effects of switch bounce). They can be split into timing based techniques and Hysteresis based techniques.

(Source: http://en.wikipedia.org/wiki/Switch#Contact_bounce)


This debounce VHDL code is level sensitive with a programmable delay length. The delay can be set from 2 to 255. This determines the length of time that the button must be pushed before a resulting output pulse is produced.


From GTKWaveSignals.JPG the results of the simulation can be seen.


Download the project from here.


Use the go.bat to compile and run GTKWave.