VHDL model of a push button debouncer

F

fpgawizz

I have this deboucing logic that i have using 2 d flip flops to sense an
push button input..the trouble here is that this also needs to be level
sensitive..i.e. as long as this push button is pushed i must display
something..

my code right now is

process(clk,button)
begin
if clk'event and clk = '1' then
button1 <= button;
button2 <= button1;
end if;
end process Debounce_Process;
mybutton <= button2 and (not(button1));

mybutton is my debounced version of button..but this signal mybutton does
not take care of the scenario when "button" is pushed and held high. In
that case i want button to be debounced when the first edge happens as
well as stay high since the user has still not taken his finger off of the
button.

Any thoughts on how i can achieve that?
thanks
 
D

Douglas Sykora

fpgawizz said:
I have this deboucing logic that i have using 2 d flip flops to sense an
push button input..the trouble here is that this also needs to be level
sensitive..i.e. as long as this push button is pushed i must display
something..

my code right now is

process(clk,button)
begin
if clk'event and clk = '1' then
button1 <= button;
button2 <= button1;
end if;
end process Debounce_Process;
mybutton <= button2 and (not(button1));

mybutton is my debounced version of button..but this signal mybutton does
not take care of the scenario when "button" is pushed and held high. In
that case i want button to be debounced when the first edge happens as
well as stay high since the user has still not taken his finger off of the
button.

Any thoughts on how i can achieve that?
thanks
fpgaWizz,
The button1 register has metastablility issues because your input "button"
is not synchronized to your clock. button2 is a stable version of the
possibly metastable "button1". May I suggest you google metastablity.
mybutton just has a pulse on every rising edge of button2.
This circuit doesn't debounce the input. You may want to google debounce.
I just checked and a few very informative links were right at the top of the
list.
Homework, or hobbyist project?
Doug
 
F

fpgawizz

will give google a try..this portion is a part of my overall design..which
is a simple RISC processor using Xilinx FPGA.Yes its a course as
well..Just trying to learn something that i can hopefully use to move to a
different position in my firm..
 
B

Bert Cuzeau

fpgawizz said:
I have this deboucing logic that i have using 2 d flip flops to sense an
push button input..the trouble here is that this also needs to be level
sensitive..i.e. as long as this push button is pushed i must display
something..

See alse-fr.com/archive/debounce.zip !
 
W

Winfried Salomon

Hello,

fpgawizz said:
I have this deboucing logic that i have using 2 d flip flops to sense an
push button input..the trouble here is that this also needs to be level
sensitive..i.e. as long as this push button is pushed i must display
something..

my code right now is

process(clk,button)
begin
if clk'event and clk = '1' then
button1 <= button;
button2 <= button1;
end if;
end process Debounce_Process;
mybutton <= button2 and (not(button1));

mybutton is my debounced version of button..but this signal mybutton does
not take care of the scenario when "button" is pushed and held high. In
that case i want button to be debounced when the first edge happens as
well as stay high since the user has still not taken his finger off of the
button.

Any thoughts on how i can achieve that?
thanks

under the topic "making a glitch filter" 2 weeks ago, Ulf Samuelsson posted
a VHDL solution for glitches, that are IMHO longer than a clock periode. I
myself wrote something about a schematics solution to debounce the clock
itself, that could be translated into VHDL, but it needs an "analog" delay
line.

Regards, Winfried
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top