该程序是实现012345-123450-234501-345012-450123-501234-012345的循环表示
library IEEE;
use IEEE.std_logic_1164.all;
use IEEE.std_logic_unsigned.all;
use ieee.std_logic_arith.all;
entity disp_inturn is
port(
clk: in std_logic;
cats: out std_logic_vector(0 to 5);
a2g: out std_logic_vector(0 to 6)
);
end disp_inturn;
architecture v of disp_inturn is
signal flag,flag1 : integer range 0 to 6;
signal num : integer range 0 to 1200;
signal flag2:std_logic;
begin
process (clk)
begin
if (clk'event and clk='1') then
case flag1 is
when 0 => a2g<="1111110";
when 1 => a2g<="0110000";
when 2 => a2g<="1101101";
when 3 => a2g<="1111001";
when 4 => a2g<="0110011";
when 5 => a2g<="1011011";
when others => null;
end case;
flag2<='0';
if(num = 12) then
num <= 0; flag2 <= '1';
else
num <= num + 1;
end if;
if (flag1 = 5 and flag2 = '0')
then flag1 <= 0;
else
flag1 <= flag1 + 1;
end if;
if flag2 = '1' then
if flag1 = 5 then flag1 <= 0;
elsif flag1 = 6 then flag1 <= 1;
else flag1 <= flag + 1; end if;
end if;
end if;
end process;
process (clk)
begin if (clk'event and clk='1') then
case flag is
when 0 => cats <= "011111";
when 1 => cats <= "101111";
when 2 => cats <= "110111";
when 3 => cats <= "111011";
when 4 => cats <= "111101";
when 5 => cats <= "111110";
when others => null;
end case ;
if (flag =5) then
flag <=0;
else
flag <= flag+1;
end if;
end if;
end process;
end;
if (flag1 = 5 and flag2 = '0')
then flag1 <= 0;
else
flag1 <= flag1 + 1;
end if;
------------这部分可能有点问题,也许应该用"OR",不是"AND"
有可能是你的CLK频率太高,你看不清它的变化......(应当只有在10HZ以下才可能看得清)