2022年vhdl设计_三层电梯控制程序 .pdf

上传人:Che****ry 文档编号:27879067 上传时间:2022-07-26 格式:PDF 页数:7 大小:45.29KB
返回 下载 相关 举报
2022年vhdl设计_三层电梯控制程序 .pdf_第1页
第1页 / 共7页
2022年vhdl设计_三层电梯控制程序 .pdf_第2页
第2页 / 共7页
点击查看更多>>
资源描述

《2022年vhdl设计_三层电梯控制程序 .pdf》由会员分享,可在线阅读,更多相关《2022年vhdl设计_三层电梯控制程序 .pdf(7页珍藏版)》请在taowenge.com淘文阁网|工程机械CAD图纸|机械工程制图|CAD装配图下载|SolidWorks_CaTia_CAD_UG_PROE_设计图分享下载上搜索。

1、library ieee; use ieee.std_logic_1164.all; use ieee.std_logic_arith.all; use ieee.std_logic_unsigned.all; entity lift is port(clk,reset,up1,up2,down2,down3,stop1,stop2,stop3,checkow:in std_logic; -buttons uplight,downlight,stoplight:buffer std_logic_vector(3 downto 1); udmode:buffer std_logic; -0- 电

2、梯处于上升模式, 1-电梯处于下降木模式position:buffer integer range 1 to 3; -电梯位置doorlight: out std_logic; -电梯门开关灯loc: out std_logic_vector(6 downto 0); -显示电梯位置ss: buffer integer range 0 to 3; -电梯所处状态 -0-上升-1-下降-2 停止out_state: out std_logic_vector(6 downto 0);-电梯所处状态 -u-上升 d-下降 -s-停止overweight_light :out std_logic);-

3、 超重提醒灯end lift; architecture aaa of lift is type state_type is(stopon1,dooropen,doorclose,wait1,wait2,wait3,wait4,up,down,stop); signal state:state_type:=stopon1; signal clearup,cleardown,buttclk,liftclk:std_logic; signal q,p:integer range 0 to 49999999; component xianshi port( position: in integer

4、range 0 to 9; segment_7: out std_logic_vector(6 downto 0) ); end component; component upordown port( ss: in integer range 0 to 2 ; segment_7: out std_logic_vector(6 downto 0) ); end component; begin process(clk)-电梯分频进程1s begin if reset=1 then q=0; elsif clkevent and clk=1 then if q=49999999 then lif

5、tclk=1;q=0; -if q=2 then liftclk=1;q=0; else liftclk=0;q=q+1; end if; end if; 名师资料总结 - - -精品资料欢迎下载 - - - - - - - - - - - - - - - - - - 名师精心整理 - - - - - - - 第 1 页,共 7 页 - - - - - - - - - end process; process(clk)-电梯按键分频进程=0.02s begin if reset=1 then p=0; elsif clkevent and clk=1 then if p=9999999 the

6、n buttclk=1;p=0; -if p=2 then buttclk=1;p=0; else buttclk=0;p=p+1; end if; end if; end process; cont:process(reset,liftclk)- 电梯状态机variable pos :integer range 3 downto 0; begin if reset=1 then state=stopon1; clearup=0; cleardown=0; elsif liftclk=1 and liftclkevent then if checkow=1 then state doorlig

7、ht=1; position=1; pos:=1; state=wait1; udmode if checkow=1 then state=wait1;overweight_light=1; else state=wait2; ss=2;overweight_light if checkow=1 then state=wait1;overweight_light=1; else clearup=0;cleardown=0; state=wait3;ss=2;overweight_light if checkow=1 then state=wait1;overweight_light=1; el

8、se state=wait4;ss=2;overweight_light if checkow=1 then state=wait1;overweight_light=1; else overweight_light=0;state=doorclose;ss doorlight=0;ss=2; if udmode=0 then if position=3 then if stoplight=000 and uplight=000 and downlight=000 then udmode=1; state=doorclose; elsif downlight(3)=1 or stoplight

9、(3)=1 then state=dooropen; else udmode=1; state=down; end if; elsif position=2 then if stoplight=000and uplight=000 and downlight=000then udmode=0;state=doorclose; elsif uplight(2)=1 or stoplight(2)=1 then state=dooropen; elsif stoplight(3)=1or downlight(3)=1 then udmode=0; state=up; else udmode=1;s

10、tate=down; end if; elsif position=1 then if stoplight=000 and uplight=000 and downlight=000then udmode=0; state=doorclose; elsif uplight(1)=1 or stoplight(1)=1 then state=dooropen; else udmode=0; state=up; end if; end if; elsif udmode=1 then if position=1 then if stoplight=000 and uplight=000and dow

11、nlight=000 then udmode=0;state=doorclose; elsif uplight(1)=1 or stoplight(1)=1 then state=dooropen; else udmode=0;state=up; end if; elsif position=2 then if stoplight=000 and uplight=000and downlight=000 then udmode=1;state=doorclose; elsif downlight(2)=1 or stoplight(2)=1 then state=dooropen; elsif

12、 stoplight(1)=1or uplight(1)=1then udmode=1; state=down; else udmode=0;state=up; end if; elsif position=3 then if stoplight=000 and uplight=000and downlight=000 then udmode=1;state=doorclose; elsif downlight(3)=1 or stoplight(3)=1 then state=dooropen; else udmode=1;state position=position+1;pos:=pos

13、+1;ss=0; if pos=2 and stoplight(2)=0 and uplight(2)=0 and (stoplight(3)=1 or downlight(3)=1) then state=up; else state position=position-1;pos:=pos-1;ss=1; if pos=2 and stoplight(2)=0 and uplight(2)=0 and (stoplight(1)=1 or uplight(1)=1) then state=down; else statestatedoorlight=1;ss=2; if udmode=0

14、then if pos3 and (stoplight(pos)=1 or uplight(pos)=1) then clearup=1; else clearup=1;cleardown1 and (stoplight(pos)=1 or uplight(pos)=1) then cleardown=1; else clearup=1;cleardown=1; end if; end if; state state=stopon1;ss=2; end case; end if; end if; end process cont; butt:process (reset,buttclk)- 按

15、键灯控制进程begin if reset=1 then stoplight=000; uplight=000; downlight=000; else if buttclkevent and buttclk=1 then if clearup=1 then -stoplight(position)=0; uplight(position)=0; else if up1=1 then uplight(1)=1; end if; 名师资料总结 - - -精品资料欢迎下载 - - - - - - - - - - - - - - - - - - 名师精心整理 - - - - - - - 第 4 页,共

16、 7 页 - - - - - - - - - if up2=1 then uplight(2)=1; end if; end if; if cleardown=1 then -stoplight(position)=0; downlight(position)=0; else if down2=1 then downlight(2)=1; end if; if down3=1 then downlight(3)=1; end if; end if; if clearup=1 or cleardown=1 then if position=1 then stoplight(1)=0; if st

17、op2=1 then stoplight(2)=1 ;end if; if stop3=1 then stoplight(3)=1 ;end if; elsif position=2 then stoplight(2)=0; if stop1=1 then stoplight(1)=1 ;end if; if stop3=1 then stoplight(3)=1 ;end if; else if stop1=1 then stoplight(1)=1 ;end if; if stop2=1 then stoplight(2)position,segment_7=loc);-数码管显示楼层si

18、:upordown port map(ss=ss,segment_7=out_state);- 数码管显示状态end aaa; -数码管显示楼层 - library ieee; use ieee.std_logic_1164.all; use ieee.std_logic_unsigned.all; use ieee.std_logic_arith.all; entity xianshi is port( position: in integer range 0 to 9 ; segment_7: out std_logic_vector(6 downto 0) ); 名师资料总结 - - -

19、精品资料欢迎下载 - - - - - - - - - - - - - - - - - - 名师精心整理 - - - - - - - 第 5 页,共 7 页 - - - - - - - - - end xianshi; architecture a of xianshi is begin process(position) begin case position is when 1=segment_7segment_7segment_7segment_7segment_7segment_7segment_7segment_7segment_7segment_7segment_7segment_7segment_7=0010010; end case; end process; end a; 名师资料总结 - - -精品资料欢迎下载 - - - - - - - - - - - - - - - - - - 名师精心整理 - - - - - - - 第 7 页,共 7 页 - - - - - - - - -

展开阅读全文
相关资源
相关搜索

当前位置:首页 > 教育专区 > 高考资料

本站为文档C TO C交易模式,本站只提供存储空间、用户上传的文档直接被用户下载,本站只是中间服务平台,本站所有文档下载所得的收益归上传人(含作者)所有。本站仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。若文档所含内容侵犯了您的版权或隐私,请立即通知淘文阁网,我们立即给予删除!客服QQ:136780468 微信:18945177775 电话:18904686070

工信部备案号:黑ICP备15003705号© 2020-2023 www.taowenge.com 淘文阁