基于FPGA 的六层电梯控制系统
if waitcnt=’2’ then waitcnt<=0 mylift<=doorclose; else mylift<=doorwait4; end if;
;
when doorclose =>
doorlight<='0'; --电梯门关
if udsig='0' then --电梯处于上升模式
if position=6 then if
stoplight=\
and
fuplight=\
fdnlight=\
udsig<='1';mylift<=doorclose;
else udsig<='1';mylift<=down; end if;
elsif position=5 then if
stoplight=\
and
fuplight=\
fdnlight=\
udsig<='0';mylift<=doorclose; elsif stoplight(6)='1' or fdnlight(6)='1' then udsig<='0';mylift<=up;
else udsig<='1';mylift<=down; end if;
elsif position=4 then if
stoplight=\
and
fuplight=\
fdnlight=\
udsig<='0';mylift<=doorclose; elsif
stoplight(5)='1'
or
stoplight(6)=
'1'
fdnlight(6)='1' or fdnlight(5)='1' then
25
and
and
and
or
基于FPGA 的六层电梯控制系统
udsig<='0';mylift<=up;
else udsig<='1';mylift<=down; end if;
elsif position=3 then if
stoplight=\
and
fuplight=\
and
fdnlight=\
udsig<='0';mylift<=doorclose; elsif
stoplight(4)='1'
or
stoplight(5)='1'
or
stoplight(6)= '1' or fdnlight(6)='1' or fdnlight(5)='1' or fdnlight(4)='1' then
udsig<='0';mylift<=up;
else udsig<='1';mylift<=down; end if;
elsif position=2 then if
stoplight=\
and
fuplight=\
and
fdnlight=\
udsig<='0';mylift<=doorclose; elsif
stoplight(3)='1'
or
stoplight(4)='1'
or
stoplight(5)='1' or stoplight(6)= '1' or fdnlight(6)='1' or fdnlight(5)='1' or fdnlight(4)='1' or fdnlight(3)='1' then udsig<='0';mylift<=up;
else udsig<='1';mylift<=down; end if;
elsif position=1 then if
stoplight=\
and
fuplight=\
and
fdnlight=\
udsig<='0';mylift<=doorclose; else udsig<='0';mylift<=up; end if;
26
基于FPGA 的六层电梯控制系统
end if;
elsif udsig='1' then
if position=1 then if
stoplight=\
and
fuplight=\
and
fdnlight=\
udsig<='0';mylift<=doorclose;
else udsig<='0'; mylift<=up; end if;
elsif position=2 then if
stoplight=\
and
fuplight=\
fdnlight=\
udsig<='1';mylift<=doorclose; elsif stoplight(1)='1' or fuplight(1)='1' then
udsig<='1';mylift<=down;
else udsig<='0'; mylift<=up; end if;
elsif position=3 then if
stoplight=\
and
fuplight=\
fdnlight=\
udsig<='1';mylift<=doorclose; elsif
stoplight(1)='1'
or
stoplight(2)='1'
fuplight(1)='1' or fuplight(2)='1' then
udsig<='1';mylift<=down;
else udsig<='0'; mylift<=up; end if;
elsif position=4 then if
stoplight=\
and
fuplight=\
fdnlight=\
udsig<='1';mylift<=doorclose;
27
and
and
or
and
基于FPGA 的六层电梯控制系统
elsif stoplight(1)='1' or stoplight(2)='1' or
stoplight(3)='1' or fuplight(1)='1' or fuplight(2)='1' or fuplight(3)='1' then
udsig<='1';mylift<=down;
else udsig<='0'; mylift<=up; end if;
elsif position=5 then if
stoplight=\
and
fuplight=\
and
fdnlight=\
udsig<='1';mylift<=doorclose; elsif
stoplight(1)='1'
or
stoplight(2)='1'
or
stoplight(3)='1' or stoplight(4)='1' or fuplight(1)='1' or fuplight(2)='1' or fuplight(3)='1' or fuplight(4)='1' then
udsig<='1';mylift<=down;
else udsig<='0'; mylift<=up; end if;
elsif position=6 then if
stoplight=\
and
fuplight=\
and
fdnlight=\
udsig<='1';mylift<=doorclose; else udsig<='1'; mylift<=down; end if; end if; end if;
when up => position<=position+1;pos:=pos+1; if position <6 and( stoplight(pos)='1' or fuplight(pos)='1') then
mylift<=stop;
elsif pos=6 and (stoplight(pos)='1' or fdnlight(pos)='1')
28
基于FPGA 的六层电梯控制系统
then
mylift<=stop; else mylift<=doorclose; end if;
when down =>
position<=position-1; pos:=pos-1; if position>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<6 and (stoplight(position)='1' or fuplight(position)='1') then clearup<='1';
else clearup<='1';cleardn<='1'; end if;
elsif udsig='1' then
if position>1 and (stoplight(position)= '1' or fdnlight(position)='1') then cleardn<='1';
else clearup<='1';cleardn<='1'; end if; end if;
mylift<=doorwait1; end case; end if;
29