2 use ieee.std_logic_1164.
all;
3 use ieee.numeric_std.
ALL;
4 use work.debounce_pkg.
ALL;
13 pbutton
: in std_logic;
14 pb_deb
: out std_logic
19 architecture rtl
of debouncer
is
21 signal cnt_deb
: unsigned
(DIV_DEB_W
-1 downto 0);
22 signal clk_en
: std_logic;
23 signal cnt_threshold
: unsigned
(DEB_LEN_W
-1 downto 0);
24 signal pb_deb_i
: std_logic;
25 signal pbutton_s
: std_logic;
29 -- downcounter for input clock freq. division
33 cnt_deb
<= (others => '0');
35 elsif (rising_edge
(clk
)) then
37 cnt_deb
<= to_unsigned
(DIV_DEB
, cnt_deb
'length);
46 -- sample pushbutton and debounce
50 cnt_threshold
<= (others => '0');
53 elsif (rising_edge
(clk
)) then
55 if (pbutton_s
= '1' and clk_en
= '1') then
56 if (cnt_threshold
< (DEB_LEN
-1) ) then
57 cnt_threshold
<= cnt_threshold
+ 1;
60 if (pbutton_s
= '0' and clk_en
= '1') then
61 if (cnt_threshold
> 0 ) then
62 cnt_threshold
<= cnt_threshold
- 1;
66 -- Activate output with hysteresis
67 if (pb_deb_i
= '0' and (cnt_threshold
> DEB_THRES_HI
)) then
70 if (pb_deb_i
= '1' and (cnt_threshold
< DEB_THRES_LO
)) then