📄 fuza05.vhd
字号:
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;
use ieee.std_logic_arith.all;
entity fuza05 is
port(clk1,clk2,reset:in std_logic;
led7s:out std_logic_vector(6 downto 0);
sel:out std_logic_vector(0 downto 0);
pout:out std_logic_vector(12 downto 1));
end ;
architecture one of fuza05 is
signal er,ey,eg:std_logic;
signal sr,sy,sg:std_logic;
signal wr,wy,wg:std_logic;
signal nr,ny,ng:std_logic;
signal cn0:integer range 0 to 9;
signal cn1:integer range 0 to 9;
signal num:integer range 0 to 9;
signal state:integer range 0 to 4;
signal count:integer range 0 to 1;
begin
process(clk1,clk2,reset,cn0,cn1)
begin
if reset='1' then
cn0<=2;cn1<=0;
state<=0;
else if(clk1'event and clk1='1')then
if (cn0=0 and cn1>0) then
cn0<=9;cn1<=cn1-1;
else cn0<=cn0-1;
end if;
if(state=0 or state=2)then
if(cn0=0 and cn1=0)then state<=state+1;cn0<=9;cn1<=1;end if;
else if(state=4) then
if(cn0=0 and cn1=0) then state<=1;cn0<=9;cn1<=1;end if;
else if(cn0=0 and cn1=0)then state<=state+1;cn0<=2;cn1<=0;
end if;end if;end if;
if(state>4)then state<=1;
end if;end if;end if;
case state is
when 0=>ey<='1';wy<='1';sy<='1';ny<='1';
eg<='0';wg<='0';sg<='0';ng<='0';
er<='0';wr<='0';sr<='0';nr<='0';
when 1=>ey<='0';wy<='0';sy<='0';ny<='0';
eg<='1';wg<='1';sg<='0';ng<='0';
er<='0';wr<='0';sr<='1';nr<='1';
when 2=>ey<='1';wy<='1';sy<='0';ny<='0';
eg<='1';wg<='1';sg<='0';ng<='0';
er<='0';wr<='0';sr<='1';nr<='1';
when 3=>ey<='0';wy<='0';sy<='0';ny<='0';
eg<='0';wg<='0';sg<='1';ng<='1';
er<='1';wr<='1';sr<='0';nr<='0';
when 4=>ey<='0';wy<='0';sy<='1';ny<='1';
eg<='0';wg<='0';sg<='1';ng<='1';
er<='1';wr<='1';sr<='0';nr<='0';
when others=>null;
end case;
end process;
PROCESS(clk2)
BEGIN
if(clk2'event and clk2='1') then
if count=1 then count<=0;else count<=count+1;end if;end if;
end process;
sel<=conv_std_logic_vector(count,1);
num<=cn0 when count=0 else
cn1;
LED7S<="0111111" when num=0 else
"0000110" when num=1 else
"1011011" when num=2 else
"1001111" when num=3 else
"1100110" when num=4 else
"1101101" when num=5 else
"1111101" when num=6 else
"0000111" when num=7 else
"1111111";
pout(1)<=er; pout(2)<=eg; pout(3)<=ey and clk1;
pout(4)<=sr; pout(5)<=sg; pout(6)<=sy and clk1;
pout(7)<=wr; pout(8)<=wg; pout(9)<=wy and clk1;
pout(10)<=nr; pout(11)<=ng; pout(12)<=ny and clk1;
end;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -