Search This Blog

Sunday, 3 January 2016

VHDL Code for Debouncer Circuit

The debouncer circuit is useful when we specially use push button switches in our design. This design code will generate high pulse for 1 millisecond after press and goes back to low. If you want to input a manual switch signal into a digital circuit you'll need to debounce the signal so a single press doesn't appear like multiple presses. Pin description is given below.
Name of Pins
Direction
Data Width
msClk
Input
1
pb
Input
1
debouncedPb
Output
1





library IEEE;
use IEEE.STD_LOGIC_1164.ALL;

entity debouncer is
	port(
		msClk: in std_logic;
		pb: in std_logic;
		debouncedPb: out std_logic);
end debouncer;

architecture Behavioral of debouncer is
	--one millisecond per bit 
	signal q: std_logic_vector(19 downto 0):= "00000000000000000000";
begin 
	process (msClk)
	begin
		if(msClk'event and msClk='1')then  
			q <= q(18 downto 0) & pb;
		end if;
	 
		if (q="00000000000000000000")then
			debouncedPb<='0';
		else
			debouncedPb<='1';
		end if;
	end process;
end Behavioral;

No comments:

Post a Comment