正在加载图片...
use ieee.std logic 1164.all; use ieee.std_logic_arith.all: use ieee.std_logic_unsigned.all; entity elevator is port(clk in std logic; --Clock Signal k1,k2u,k2d,k3 in std_logic: --Push button d1,d2u,d2d,d3 out std logic; --Led of every floor door1,door2,door3 buffer std logic: --door led r0,r1,r2,r3,r4,r5,r6,r7: out std logic; --7 segment driver sa,sb,sc out std logic); -Display Select end elevator; architecture behave of elevator is signal statel,state3 std logic: signal state2u,state2d std logic; signal doorflag std logic: signal udflag,runflag std logic; --up and down flag,run flag signal dcount std_logic_vector(2 downto 0): --display counter signal display std logic vector(7 downto 0); signal location std_logic_vector(1 downto 0); signal wcount std logic vector(10 downto 0); --wait counter signal doorcount std-logic_vector(9 downto 0):--door counter signal col1,col2,col3,col4,col5,col6 std_logic_vector(7 downto 0); begin process(clk) judge the key is or is not been pushed begin if(clk'event and clk='1')then if (kl=0 and door1='0')then statel<='1'; d1<=’1’: elsif(location=0 and wcount=0)then de’0': if(doorcount=1020)then statel<='0' end if; end if; if(k2u='0'and door2='0')then state2u<=' 1 d2u<=’1 elsif(location=1 and udflag='1'and wcount=0)then d2u<= 0 if(doorcount=1020)then state2u<='0': end if; end if; if(k2d=’0' and door2='0')then state2d<=’I d2d=1 elsif(location=1 and udflag='0'and wcount=0)then d2d<=’0': if(doorcount=1020)then state2d<='0'; end if; end if; if(k3=0'and door3='0')then state3<=’1' d3<= 1 elsif(location=2 and wcount=0)then d3<=0': if(doorcount=1020)then state:3<=’0': end if; end if; end if; end process; process(clk) begin if(clk'event and clk='1')then if(location=0)then --display 1use ieee.std_logic_1164.all; use ieee.std_logic_arith.all; use ieee.std_logic_unsigned.all; entity elevator is port( clk : in std_logic; --Clock Signal k1,k2u,k2d,k3 : in std_logic; --Push button d1,d2u,d2d,d3 : out std_logic; --Led of every floor door1,door2,door3 : buffer std_logic; --door led r0,r1,r2,r3,r4,r5,r6,r7 : out std_logic; --7 segment driver sa,sb,sc : out std_logic); --Display Select end elevator; architecture behave of elevator is signal state1,state3 : std_logic; signal state2u,state2d : std_logic; signal doorflag : std_logic; signal udflag,runflag : std_logic; --up and down flag,run flag signal dcount : std_logic_vector(2 downto 0); --display counter signal display : std_logic_vector(7 downto 0); signal location : std_logic_vector(1 downto 0); signal wcount : std_logic_vector(10 downto 0); --wait counter signal doorcount : std_logic_vector(9 downto 0); --door counter signal col1,col2,col3,col4,col5,col6 : std_logic_vector(7 downto 0); begin process(clk) -- judge the key is or is not been pushed begin if(clk’event and clk=’1’) then if(k1=’0’ and door1=’0’) then state1<=’1’; d1<=’1’; elsif(location=0 and wcount=0) then d1<=’0’; if(doorcount=1020) then state1<=’0’; end if; end if; if(k2u=’0’ and door2=’0’) then state2u<=’1’; d2u<=’1’; elsif(location=1 and udflag=’1’ and wcount=0) then d2u<=’0’; if(doorcount=1020) then state2u<=’0’; end if; end if; if(k2d=’0’ and door2=’0’) then state2d<=’1’; d2d<=’1’; elsif(location=1 and udflag=’0’ and wcount=0) then d2d<=’0’; if(doorcount=1020) then state2d<=’0’; end if; end if; if(k3=’0’ and door3=’0’) then state3<=’1’; d3<=’1’; elsif(location=2 and wcount=0) then d3<=’0’; if(doorcount=1020) then state3<=’0’; end if; end if; end if; end process; process(clk) begin if(clk’event and clk=’1’) then if(location=0) then --display 1
<<向上翻页向下翻页>>
©2008-现在 cucdc.com 高等教育资讯网 版权所有