Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- library ieee;
- use ieee.std_logic_1164.all;
- use ieee.std_logic_unsigned;
- entity debouncer is
- generic( N:integer := 19200000); --19200000
- port
- (
- clk: in std_logic;
- sin: in std_logic;
- output: out std_logic;
- --brj: out integer range 0 to 20000000
- );
- end debouncer;
- architecture arh of debouncer is
- signal brojac,brojac2: integer range 0 to 20000000;
- signal flag: std_logic;
- begin
- process(clk)
- begin
- if clk='1' then
- if sin='1' then
- brojac<=0;
- elsif brojac /= N and sin='0' and flag='0' then
- brojac<=brojac+1;
- elsif brojac=N then
- flag<='1';
- brojac<=0;
- end if;
- if flag = '1' then
- brojac2<=brojac2+1;
- output<='1';
- end if;
- if brojac2=N then
- flag<='0';
- brojac2<=0;
- output<='0';
- end if;
- end if;
- --brj<=brojac;
- end process;
- end arh;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement