Looking for DEBOUNCE circuit

Joined
Oct 11, 2007
Messages
3
Reaction score
0
The serach forum option gave me 0 results. I found it strange that noone was looking for debounce circuit in VHDL before me.

Anyway. I need to debounce using VHDL a simple switch button. For simulation I am using Xilinx Spartan 3 XC3S1000.

Could anyone please post simple VHDL code to debounce that? The idea is to select a number using 8 togling switches, then to press a button (one under 6 LED displays) so that the software will input a number according to selected switches. Then change them around and press the button again.

The program needs to take only 1 input, so I need to debounce it. How can I do it?

Thanks:)
 
Joined
Oct 11, 2007
Messages
3
Reaction score
0
I used the following code. But it does not give me single pulse for push_out. How can I get single pulse only?

entity debounce is
generic (
delay : integer range 0 to 7 := 4);
port (
clk : in STD_LOGIC;
push_in : in STD_LOGIC;
led_out : out STD_LOGIC);
end debounce;

architecture a of debounce is
signal push_out : STD_LOGIC;
signal sig_out : STD_LOGIC;
signal count_tmp: STD_LOGIC_VECTOR (20 downto 0);
signal clk_out: STD_LOGIC;

BEGIN
process (clk)
begin
if (clk'event and clk='1') then
if count_tmp="111111111111111111111" then
count_tmp <= "000000000000000000000";
else
count_tmp <= count_tmp + 1;
end if;
end if;
end process;

clk_out <= '1' WHEN count_tmp="111111111111111111111" ELSE '0';


process(clk_out, push_in)
variable count : integer range 0 to 7;
begin
if (push_in = '0') then
push_out <= '0';
count := 0;
elsif(clk_out'event and clk_out = '1') then
if (count /= delay) then
count := count + 1;
end if;
if (count = (delay-1) and push_in = '1') then
push_out <= '1';
else
push_out <= '0';
end if;
end if;
end process;
 

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
474,169
Messages
2,570,920
Members
47,462
Latest member
ChanaLipsc

Latest Threads

Top