the buttonOut, flipflops and temporal is un-utilized after the frequency divider process is added into the codes.. I couldn't figure out the problem as I'm new to vhdl.. my codes is as below..
1 | library ieee; |
2 | use ieee.std_logic_1164.all; |
3 | use ieee.std_logic_unsigned.all; |
4 | |
5 | entity debounce is |
6 | --counter size (19 bits gives 10.5ms with 50MHz clock)
|
7 | generic ( counter_size : INTEGER := 4); |
8 | port( clk : in std_logic; --input clock |
9 | buttonIn : in std_logic; --input signal to be debounced |
10 | buttonOut : out std_logic); --debounced signal |
11 | end debounce; |
12 | |
13 | architecture debounce of debounce is |
14 | |
15 | signal flipflops : std_logic_vector(1 downto 0); --input flip flops |
16 | signal counter_set : std_logic ; --sync reset to zero |
17 | |
18 | signal temporal: std_logic; |
19 | signal counter : integer range 0 to 124999 := 0; --counter size(200Hz) |
20 | |
21 | begin
|
22 | |
23 | counter_set <= flipflops(0) xor flipflops(1);--check when to start/reset counter |
24 | |
25 | --freqeuncy divider process
|
26 | process (clk) begin |
27 | if rising_edge(clk) then |
28 | if (counter = 124999) then --Condition met |
29 | temporal <= not(temporal); |
30 | counter <= 0; |
31 | else --Condition not met |
32 | counter <= counter + 1; |
33 | end if; |
34 | end if; |
35 | end process; |
36 | |
37 | --debounce process
|
38 | process(temporal) |
39 | begin
|
40 | if(rising_edge(temporal)) then |
41 | flipflops(0) <= buttonIn; |
42 | flipflops(1) <= flipflops(0); |
43 | buttonOut <= flipflops(1); |
44 | end if; |
45 | end process; |
46 | |
47 | end debounce; |