---------------------------------------------------------- -- keyDebounce -- Author : Gautam Karnik -- Date : March 30, 2001 -- Filename : keyDebounce.vhd -- Architecture : Behavioral -- Description : This entity is the key debounce -- control unit for the keypad. -- It simply counts to "3FFFFF", when the -- sense line is 0. When we hit the -- threshold value we know a key has been -- pressed and we signal the rest of the -- system. ---------------------------------------------------------- library ieee; use ieee.std_logic_1164.all; use ieee.std_logic_arith.all; use ieee.std_logic_unsigned.all; library work; use work.CDMA_pkg.all; entity keyDebounce is port ( resetn : in std_logic; clock : in std_logic; sense : in std_logic; keyPressed : out std_logic ); end entity keyDebounce; architecture behavioral of keyDebounce is signal count : std_logic_vector ( 23 downto 0); begin debounce_test : process (clock, resetn ) is -- user 16 bit counter to approximate 5 ms begin wait until rising_edge ( clock ); if ( resetn = '0' ) then count <= (others => '0'); else -- if we something has been pressed on the keypad begin the counter if ( sense = '0' ) then count <= count + '1'; if count = x"3FFFFF" then KeyPressed <= '1'; else KeyPressed <= '0'; end if; elsif ( sense = '1' ) then count <= ( others => '0' ); end if; end if; end process debounce_test; -- with count select -- keyPressed <= '1' when X"3FFFFF", -- time constant, changed for testing -- '0' when others; end behavioral;