I made more experiments and I feel that there is problem with buttons edge detection on the DE2 board. I tried T flip flop:
library ieee;
use ieee.std_logic_1164.all;
entity t_ff_async is
port (
t : in std_logic;
r : in std_logic;
q : out std_logic;
n_q : out std_logic
);
end t_ff_async;
architecture struct of t_ff_async is
begin
process (r, t)
variable ff : std_logic;
begin
-- reset
if r = '1' then
ff := '0';
elsif t'event and t = '1' then
ff := not ff;
end if;
q <= ff;
n_q <= not ff;
end process;
end struct;
Toggle is 't' in here - in which I have tested step by step all 4 keys (buttons) on the DE2. Code defines rising edge which is every release of the key (button). I assigned LEDs to Q and n_Q, so LED light should switch with every release of the key (button) which was not 100% event; it sometimes switched also when the button was pressed and then when released. I have also assigned another LEDs to indicate immediate value of the key
ledr <= key which is working 100% correct.
So I have reached a view that those type of buttons isn't good to use in applications where edge detection (due electrical characteristic) is needed. Do you think that this could be correct explanation ?
Thanks for reply.