📄 threeflift.tdf
字号:
LIBRARY IEEE;
USE IEEE.STD_LOGIC_1164.ALL;
USE IEEE.STD_LOGIC_ARITH.ALL;
USE IEEE.STD_LOGIC_UNSIGNED.ALL;
ENTITY threeflift IS
PORT(buttonclk: IN STD_LOGIC;
liftclk: IN STD_LOGIC;
reset: IN STD_LOGIC;
f1upbutton: IN STD_LOGIC;
f2upbutton: IN STD_LOGIC;
f2dnbutton: IN STD_LOGIC;
f3dnbutton: IN STD_LOGIC;
fuplight: BUFFER STD_LOGIC_VECTOR(3 DOWNTO 1);
fdnlight: BUFFER STD_LOGIC_VECTOR(3 DOWNTO 1);
stop1button,stop2button,stop3button: IN STD_LOGIC;
stoplight: BUFFER STD_LOGIC_VECTOR(3 DOWNTO 1);
position: BUFFER INTEGER RANGE 1 TO 3;
doorlight: OUT STD_LOGIC;
udsig: BUFFER STD_LOGIC;
END threeflift;
ARCHITECTURE a OF threeflift IS
TYPE lift_state IS
(stopon1,dooropen,doorclose,doorwait1,doorwait2,doorwait3,doorwait4,up,down,stop);
SIGNAL mylift:lift_state
SIGNAL clearup:STD_LOGIC;
SIGNAL cleardn:STD_LOGIC;
BEGIN
ctrlift:PROCESS(reset,liftclk)
VARIABLE pos:INTEGER RANGE 3 DOWNTO 1;
BEGIN
IF reset='1'THEN
mylift<=stopon1;
clearup<='0';
cleardn<='0';
ELSE
IF liftclk'EVENT AND liftclk='1' THEN
CASE mylift IS
WHEN stopon1=>
doorlight<='1';
position<='1';pos:=1;
mylift<=doorwait1;
WHEN doorwait1=>
mylift<=doorwait2;
WHEN doorwait2=>
clearup<='0';
cleardn<='0';
mylift<=doorwait3;
WHEN doorwait3=>
mylift<=doorwait4;
WHEN doorwait4=>
mylift<doorclose;
WHEN doorclose=>
doorlight<='0';
IF udsig='0' THEN
IF position=3 THEN
IF
stoplight="000" AND fuplight="000";
udsig<='1';
mylift<=doorclose;
ELSE udsig<='1';mylift<=down;
END IF;
ELSIF position=2 THEN
IF
stoplight="000" AND fuplight="000" AND fdnlight="000" THEN
udsig<='0';
mylift<=doorclose
ELSIF
stoplight(3)='1' OR (stoplight(3)='0' AND fdlight(3)='1') THEN
udsig<='0';
mylift<=up;
ELSE udsig<='1';mylift<=down;
END IF;
ELSIF position=1 THEN
IF
stoplight="000" AND fuplight="000" AND fdnlight="000" THEN
udsig<='0';
mylift<=doorclose;
ELSE udsig<='0';mylift<=up;
END IF;
END IF;
ELSIF udsig='1' THEN
IF position=1 THEN
IF
stoplight="000" AND fuplight="000" AND fdnlight="000" THEN
udsig<='0';mylift<=doorclose;
ELSE udsig<='0';mylift<=up;
END IF;
ELSIF position=2 THEN
IF
stoplight="000" AND fuplight="000" AND fdnlight="000" THEN
udsig<='1';
mylift<=doorclose;
ELSIF
stoplight(1)='1' OR (stoplight(1)='0' AND fuplight(1)='1')
THEN
udsig<='1';mylift<=down;
ELSE udsig<='0';mylift<=up;
END IF;
ELSIF position=3 THEN
IF
stoplight="000" AND fuplight="000" AND fdnlight="000" THEN
udsig<='1';
mylift<=doorclose;
ELSE udsig<='1';mylift<=down;
END IF;
END IF;
END IF;
WHEN up=>
position<=position+1;
pos:=pos+1;
IF pos<3 AND (stoplight(pos)='1' OR fdnlight(pos)='1')
THEN mylift<=stop;
ELSIF pos=3 and (stoplight(pos)='1' OR fdnlight(pos)='1')
THEN mylift<=stop;
ELSE mylift<=doorclose;
END IF;
WHEN down=>
position<=position-1;
pos:=pos-1;
IF pos>1 AND (stoplight(pos)='1' OR fdnlight(pos)='1')
THEN mylift<=stop;
ELSIF pos=1 AND (stoplight(pos)='1' OR fuplight(pos)='1')
THEN mylift<=stop;
ELSE mylift<=doorclose;
END IF;
WHEN stop=>
mylift<=dooropen;
WHEN dooropen=>
doorlight<='1';
IF udsig='0' THEN
IF
position<=2 AND (stoplight(position)='1' OR fuplight(position)='1') THEN
clearup<='1';
ELSE clearup<='1';cleardn<='1';
END IF;
ELSIF udsig='1' THEN
IF
position<=2 AND (stoplight(position)='1' OR fdnlight(position)='1') THEN
cleardn<='1';
ELSIF clearup<='1'cleardn<='1';
END IF;
END IF;
mylift<=doorwait1;
END CASE;
END IF;
END IF;
END PROCESS ctrlift;
ctrlight:PROCESS(reset,buttonclk)
BEGIN
IF reset='1' THEN
stoplight<="000";fuplight<="000";fdnlight<="000";
ELSE
IF buttonclk'EVENT AND buttonclk='1' THEN
IF clearup='1' THEN
stoplight(position)<='0';fuplight(position)<='0';
ELSE
IF f1upbutton='1' THEN fuplight(1)<='1';
ELSIF f2upbutton='1'THEN fuplight(2)<='1';
END IF;
END IF;
IF cleardn='1'THEN
stoplight(position)<='0';fdnlight(position)<='0';
ELSE
IF f2dnbutton='1'THEN fdnlight(2)<='1';
ELSIF f3dnbutton='1'THEN fdnlight(3)<='1';
END IF;
END IF;
IF stop1button<='1'THEN stoplight(1)<='1';
ELSIF stop2button='1'THEN stoplight(2)<='1';
ELSIF stop3button='1'THEN stoplight(3)<='1';
END IF;
END IF;
END IF;
END IF;
END PROCESS ctrlight;
END a;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -