library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;
use ieee.std_logic_arith.all;
entity key is
port(key,clk:in std_logic;
LEDut std_logic_vector(7 downto 0)
);
end key;
architecture ky of key is
signal q:std_logic;
signal nn:integer range 0 to 7;
begin
ky:process(key)
variable cnt1:integer range 0 to 2000;
variable cnt2:integer range 0 to 1000;
variable n:integer range 0 to 8;
variable mm:std_logic;
variable state:std_logic;
--variable ct:integer range 0 to 3;
begin
state:=key;
if state='0' then
if clk'event and clk='1' then
if cnt1=2000 then
cnt1:=0;
state:=key;
if state='1' then
if n=8 then
n:=0;
else
n:=n+1;
end if;
end if;
elsif cnt2=1000 then
cnt2:=0;
cnt1:=cnt1+1;
else
cnt2:=cnt2+1;
end if;
end if;
end if;
nn<=n;
end process ky;
keys:process(nn)
variable LED1: std_logic_vector(7 downto 0);
begin
case nn is
when 1=>LED1:="11111110";
when 2=>LED1:="11111101";
when 3=>LED1:="11111011";
when 4=>LED1:="11110111";
when 5=>LED1:="11101111";
when 6=>LED1:="11011111";
when 7=>LED1:="10111111";
when others=>LED1:="01111111";
end case;
LED<=LED1;
end process keys;
end ky;
按一次键盘,检测到按键起来的时候开启计数器延时,然后流水灯移动一位,可是我按键却没有作用,我不知道问题出在哪里了,望高手指教