8.19 µçÌÝ¿ØÖÆÆ÷VHDL³ÌÐòÓë·ÂÕæ¡£
--
--ÎļþÃû£ºdianti.vhd¡£
--¹¦ÄÜ£º6²ãÂ¥µÄµçÌÝ¿ØÖÆÏµÍ³¡£ --×îºóÐÞ¸ÄÈÕÆÚ£º library ieee;
use ieee.std_logic_1164.all; use ieee.std_logic_unsigned.all; use ieee.std_logic_arith.all; entity dianti is
port ( clk : in std_logic; --ʱÖÓÐźţ¨ÆµÂÊΪ2Hz£©
full,deng,quick,clr : in std_logic; --³¬ÔØ¡¢¹ØÃÅÖжϡ¢Ìáǰ¹ØÃÅÇå³ý±¨¾¯ÐźŠc_u1,c_u2,c_u3,c_u4,c_u5: in std_logic; --µçÌÝÍâÈ˵ÄÉÏÉýÇëÇóÐźŠc_d2,c_d3,c_d4,c_d5,c_d6 : in std_logic; --µçÌÝÍâÈ˵ÄϽµÇëÇóÐźŠd1,d2,d3,d4,d5,d6 : in std_logic; --µçÌÝÄÚÈ˵ÄÇëÇóÐźŠg1,g2,g3,g4,g5,g6 : in std_logic; --µ½´ïÂ¥²ãÐźŠdoor : out std_logic_vector(1 downto 0); --µçÌÝÃÅ¿ØÖÆÐźŠled : out std_logic_vector(6 downto 0); --µçÌÝËùÔÚÂ¥²ãÏÔʾ led_c_u:out std_logic_vector(5 downto 0); --µçÌÝÍâÈËÉÏÉýÇëÇóÐźÅÏÔʾ led_c_d:out std_logic_vector(5 downto 0); --µçÌÝÍâÈËϽµÇëÇóÐźÅÏÔʾ
led_d : out std_logic_vector(5 downto 0); --µçÌÝÄÚÇëÇóÐźÅÏÔʾ wahaha : out std_logic; --¿´ÃŹ·±¨¾¯ÐźÅ
ud,alarm : out std_logic; --µçÌÝÔ˶¯·½ÏòÏÔʾ£¬³¬Ôؾ¯¸æÐźÅ
up,down : out std_logic ); --µç»ú¿ØÖÆÐźź͵çÌÝÔ˶¯
end dianti;
architecture behav of dianti is
signal d11,d22,d33,d44,d55,d66:std_logic; --µçÌÝÄÚÈËÇëÇóÐźżĴæÐźŠsignal c_u11,c_u22,c_u33,c_u44,c_u55:std_logic; --µçÌÝÍâÈËÉÏÉýÇëÇóÐźżĴæÐźŠsignal c_d22,c_d33,c_d44,c_d55,c_d66:std_logic; --µçÌÝÍâÈËϽµÇëÇóÐźżĴæÐźŠsignal q:integer range 0 to 1; --·ÖƵÐźÅ
signal q1:integer range 0 to 6; --¹ØÃÅÑÓʱ¼ÆÊýÆ÷ signal q2:integer range 0 to 9; --¿´ÃŹ·¼ÆÊýÆ÷
signal dd,cc_u,cc_d,dd_cc:std_logic_vector(5 downto 0); --µçÌÝÄÚÍâÇëÇóÐźżĴæÆ÷ signal opendoor:std_logic; --¿ªÃÅʹÄÜÐźÅ
signal updown:std_logic; --µçÌÝÔ˶¯·½ÏòÐźżĴæÆ÷
signal en_up,en_dw:std_logic; --Ô¤±¸ÉÏÉý¡¢Ô¤±¸Ï½µÔ¤²Ù×÷ʹÄÜÐźŠbegin
com:process(clk) begin
if clk'event and clk='1' then
if clr='1' then q1<=0;q2<=0;wahaha<='0'; --Çå³ý¹ÊÕϱ¨¾¯ elsif full='1' then alarm<='1'; q1<=0; --³¬Ôر¨¾¯ if q1>=3 then door<=\ else door<=\
end if; elsif q=1 then q<=0;alarm<='0';
if q2=3 then wahaha<='1'; --¹ÊÕϱ¨¾¯ else
if opendoor='1' then door<=\ --¿ªÃŲÙ×÷ elsif en_up='1' then --ÉÏÉýÔ¤²Ù×÷ if deng='1' then door<=\ --¹ØÃÅÖÐ¶Ï elsif quick='1' then q1<=3; --Ìáǰ¹ØÃÅ elsif q1=6 then door<=\¹ØÃÅÍê±Ï£¬µçÌݽøÈëÉÏÉý״̬ elsif q1>=3 then door<=\ --µçÌݽøÈë¹ØÃÅ״̬ else q1<=q1+1;door<=\ --µçÌݽøÈëµÈ´ý״̬ end if;
elsif en_dw='1' then --ϽµÔ¤²Ù×÷ if deng='1' then door<=\
elsif quick='1' then q1<=3; elsif q1=6 then door<=\ elsif q1>=3 then door<=\ else q1<=q1+1;door<=\ end if;
end if;
if g1='1' then led<=\ --µçÌݵ½´ï1Â¥£¬ÊýÂë¹ÜÏÔʾ1 if d11='1' or c_u11='1' then d11<='0'; c_u11<='0';opendoor<='1';
--Óе±Ç°²ãµÄÇëÇó£¬ÔòµçÌݽøÈ뿪ÃÅ״̬
elsif dd_cc>\
--ÓÐÉÏÉýÇëÇó£¬ÔòµçÌݽøÈëÔ¤±¸ÉÏÉý״̬
elsif dd_cc=\ --ÎÞÇëÇóʱ£¬µçÌÝÍ£ÔÚ1Â¥´ý»ú end if;
elsif g2='1' then led<=\ --µçÌݵ½´ï2Â¥£¬ÊýÂë¹ÜÏÔʾ2 if updown='1' then --µçÌÝǰһÔ˶¯×´Ì¬Î»ÉÏÉý if d22='1' or c_u22='1' then d22<='0'; c_u22<='0'; opendoor<='1';
--Óе±Ç°²ãµÄÇëÇó£¬ÔòµçÌݽøÈ뿪ÃÅ״̬ elsif dd_cc>\
--ÓÐÉÏÉýÇëÇó£¬ÔòµçÌݽøÈëÔ¤±¸ÉÏÉý״̬ elsif dd_cc<\ opendoor<='0';
--ÓÐϽµÇëÇó£¬ÔòµçÌݽøÈëÔ¤±¸Ï½µ×´Ì¬
end if;
--µçÌÝǰһÔ˶¯×´Ì¬ÎªÏ½µ
elsif d22='1' or c_d22='1' then d22<='0'; c_d22<='0';opendoor<='1';
--Óе±Ç°²ãµÄÇëÇó£¬ÔòµçÌݽøÈ뿪ÃÅ״̬ elsif dd_cc<\ opendoor<='0';
--ÓÐϽµÇëÇó£¬ÔòµçÌݽøÈëÔ¤±¸Ï½µ×´Ì¬
elsif dd_cc>\ opendoor<='0';
--ÓÐÉÏÉýÇëÇó£¬ÔòµçÌݽøÈëÔ¤±¸ÉÏÉý״̬
end if;
elsif g3='1' then led<=\ --µçÌݵ½´ï3Â¥£¬ÊýÂë¹ÜÏÔʾ3 if updown='1' then
if d33='1' or c_u33='1' then d33<='0'; c_u33<='0';opendoor<='1'; elsif dd_cc>\ opendoor<='0'; elsif dd_cc<\ opendoor<='0'; end if;
elsif d33='1' or c_d33='1' then d33<='0'; c_d33<='0'; opendoor<='1'; elsif dd_cc<\ opendoor<='0'; elsif dd_cc>\ opendoor<='0'; end if;
elsif g4='1' then led<=\ --µçÌݵ½´ï4Â¥£¬ÊýÂë¹ÜÏÔʾ4 if updown='1' then
if d44='1' or c_u44='1' then d44<='0'; c_u44<='0'; opendoor<='1'; elsif dd_cc>\ elsif dd_cc<\ opendoor<='0'; end if;
elsif d44='1' or c_d44='1' then d44<='0'; c_d44<='0'; opendoor<='1'; elsif dd_cc<\ opendoor<='0'; elsif dd_cc>\ opendoor<='0'; end if;