📄 lifttt.vhd.bak
字号:
library IEEE;
use IEEE.std_logic_1164.all;
use IEEE.std_logic_unsigned.all;
entity lift is
port (
clkin:in STD_LOGIC;
upin:in STD_LOGIC;
downin:in STD_LOGIC;
st_ch:in STD_LOGIC;
close:in STD_LOGIC;
delay:in STD_LOGIC;
run_stop:in STD_LOGIC;
lamp:out STD_LOGIC;
run_wait:out STD_LOGIC_VECTOR(3 downto 0);
st_out:out STD_LOGIC_VECTOR(3 downto 0);
direct:out STD_LOGIC_VECTOR(3 downto 0)
);
end lift;
architecture lift_arch of lift is
signal ur,dr:STD_LOGIC_VECTOR(6 downto 1);
signal dir,liftor:STD_LOGIC_VECTOR(2 downto 0);
signal wai_t:STD_LOGIC_VECTOR(2 downto 0);
signal divide,hand:STD_LOGIC;
signal ladd:STD_LOGIC_VECTOR(1 downto 0);
signal closex,delayx:STD_LOGIC;
begin
direct<='0'&dir+1;
st_out<='0'&liftor+1;
run_wait<='0'&wai_t;
lamp<=ladd(1);
--hand<=wai_t(2)and (not wai_t(1)) and wai_t(0);
closex<=close and (not ladd(1));
delayx<=delay and (not ladd(1));
p1:process(clkin)
begin
if (clkin'event and clkin='1')then
divide<=not divide;
if (dir="101")then dir<="000";
else dir<=dir+1;
end if ;
end if;
end process p1;
p2:process(ur,dr,dir,upin,downin,st_ch,liftor,wai_t,run_stop,hand)
variable num,t:integer;
begin
num:=conv_integer(liftor)+1;
t:=conv_integer(dir)+1;
if (run_stop='1')then
if(((t>num)and(st_ch='1'))or(upin='1')) then ur(t)<='1';
elsif(hand='1')then ur(num)<='0';
end if ;
if(((t<num)and(st_ch='1'))or(downin='1')) then dr(t)<='1';
elsif(hand='1')then dr(num)<='0';
end if ;
else ur<= "000000";
dr<= "000000";
end if;
end process p2;
p3:process(ur,dr,liftor,ladd,wai_t,run_stop)
begin
if(run_stop='1') then
if (wai_t="110") then
if ((ur or dr)="000000") then ladd(1)<='0';
else
case liftor is
when "000"=>if ((ur (1) or dr(1))>'0')then ladd(1)<='0';
else ladd<="11";
end if;
when "001"=>if ((ur(2) or dr(2))>'0')then ladd(1)<='0';
elsif (((ladd(0)='1')and((ur(6 downto 3) or dr(6 downto 3))>"0000"))or((ur(1) or dr(1))='0')) then ladd<="11";
else ladd<="10";
end if;
when "010"=>if ((ur(3) or dr(3))>'0')then ladd(1)<='0';
elsif (((ladd(0)='1')and((ur(6 downto 4) or dr(6 downto 4))>"000"))or((ur(2 downto 1) or dr(2 downto 1 ))="00")) then ladd<="11";
else ladd<="10";
end if;
when "011"=>if ((ur(4) or dr(4))>'0')then ladd(1)<='0';
elsif (((ladd(0)='1')and((ur(6 downto 5) or dr(6 downto 5))>"00"))or((ur(3 downto 1) or dr(3 downto 1))="000")) then ladd<="11";
else ladd<="10";
end if;
when "100"=>if ((ur(5) or dr(5))>'0')then ladd(1)<='0';
elsif (((ladd(0)='1')and((ur(6 ) or dr(6 ))>'0'))or((ur(4 downto 1) or dr(4 downto 1))="0000")) then ladd<="11";
else ladd<="10";
end if;
when "101"=>if ((ur (6) or dr(6))>'0')then ladd(1)<='0';
else ladd<="10";
end if;
when others=>null;
end case;
end if;
end if;
else ladd<="00";
end if;
end process p3;
p4:process(wai_t,ladd,closex,delayx)
begin
if (divide 'event and divide ='1') then
if (wai_t="000" or closex='1') then wai_t<="110";
else
if (delayx='0') then wai_t<=wai_t-1;
else wai_t<="010";
end if;
if (wai_t="001") then
if (ladd="11") then liftor<=liftor+1;
elsif (ladd="10") then liftor<=liftor-1;
end if;
end if;
end if;
end if;
end process p4;
end lift_arch;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -