PROCESS(clk,rst)
variable keys : integer range 0 to 100000;--按键消抖变量
begin
if(rst='0')then
";
elsif(clk'event and clk='1')then
if(key(2)='0')then
if(keys=100000 and key(2)='0')then
key_c<='1';
keys:=0;
else
keys:=keys+1;
end if;
end if;
if(key_c='1' and key(2)='1')then
if(keys=100000 and key(2)='1')then
key_c<='0';
keys:=0;
if(key_state="101")then
key_state<="000";
else
key_state<=key_state+1;
end if;
else
keys:=keys+1;
end if;
end if;
end if;
end PROCESS;
用户377235 2013-12-6 10:08