I am writing a code that when the key(0) is pressed, the letter shown on the 7-segment display changes from the one to the next, like a to b, b to c. It starts from A. When the letter reaches H, it goes back to A. However, when I press the key, the letter changes,but it goes back to H when it is not pressed.I don't understand what the problem is.Here's the code:
KEY : in std_logic_vector(1 downto 0);
HEX : out std_logic_vector(6 downto 0)
architecture behavioural of display is
signal counter : std_logic_vector(2 downto 0):= "000";
begin
process (KEY)
begin
if (KEY(0)= '1') then
counter <= counter + '1';
end if;
end process;
process(counter)
begin
case counter is
when "000" => HEX <= "0001000";
when "001" => HEX <= "0000011";
when "010" => HEX <= "1000110";
when "011" => HEX <= "0100001";
when "100" => HEX <= "0000110";
when "101" => HEX <= "0001110";
when "110" => HEX <= "0010000";
when "111" => HEX <= "0001001";
end case;
end process;
end behavioural;