




已阅读5页,还剩17页未读, 继续免费阅读
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
Verilog课程设计Verilog Curriculum Design所在院系教育信息与技术学院专业名称信息工程班级1202题目单电梯微控制器设计指导教师xxx成员完成时间2014年5月27日2014年6月12日 一、设计任务及要求:设计任务: 单电梯微控制器要 求: (1) 用S0和S1作为手动上下开关(2) 数码管指示当前所在楼层(3) 用led灯表示电梯当前状态(上/下/停)(4) 利用modelsim和Quartus II仿真综综合指导教师签名: 2014年6月12日 二、指导教师评语:指导教师签名: 2014年6月 12日 三、成绩 验收盖章 2014年6月12 日 单电梯微控制器的设计1 设计目的采用Verilog HDL,源程序经Multisim软件仿真。在电梯时钟的触发下,通过当前状态和信号灯信号来判定下一状态。设计要求:(1) 用S0和S1作为手动上下开关(2) 数码管指示当前所在楼层(3) 用led灯表示电梯当前状态(上/下/停)(4) 利用modelsim和Quartus II仿真综综合2 设计思路将电梯运行定义为6个状态,具体的状态定义如下:S1:floor1,表示在楼层1;S2:floor2,表示在楼层2;S3: floor3,表示在楼层3; S4:floor4,表示在楼层4;S5:direction=2b11,表示电梯向上运动;S6:direction=2b00,表示电梯向下运动;S7:direction=2b10,表示电梯在等待状态;状态转换图:S6S5S2S1S4S7S3表一 电梯控制器状态转换条件现态次态转换条件S1S5r_up1=f1|r_up2=f2|r_up3=f3|r_down2=f2|r_down3=f3|r_down4=f4|r_inter2=f2|r_inter3=f3|r_inter4=f4S2S5direction=2b11的情况下(r_up2=f2 | r_up3=f3 | r_down4=f4 | r_down3=f3 | r_inter3=f3 | r_inter4=f4)或direction=2b00的情况下(r_up2=f2 | r_up3=f3 | r_down4=f4 | r_down3=f3 | r_inter3=f3 | r_inter4=f4)S2S6direction=2b11的情况下(r_up1=f1 | r_down2=f2 | r_inter1=f1)或direction=2b00的情况下(r_up1=f1|r_down2=f2|r_inter1=f1)S2S7S2的下一状态不为S5/S6S3S5direction=2b11的情况下( r_inter4=f4 | r_up3=f3 | r_down4=f4 )或direction=2b00的情况下( r_up3=f3 | r_down4=f4 | r_inter4=f4 )S3S6direction=2b11的情况下(r_inter1=f1 | r_inter2=f2)或(r_down2=f2|r_up2=f2)或(r_up1=f1)或direction=2b00的情况下( r_up1=f1 | r_up2=f2 | r_down2=f2 | r_down3=f3 | r_inter1=f1 | r_inter2=f2 )S3S7S3的下一状态不为S5/S6S4S6r_up1=f1 | r_up2=f2 | r_up3=f3 | r_down2=f2 | r_down3=f3 | r_down4=f4 | r_inter1=f1 | r_inter2=f2 | r_inter3=f3S7S7没有任何信号请求3 设计过程 系统描述:1、这是一个4层电梯控制系统2、在电梯的内部有一个控制面板,它负责按下请求到的楼层,并且显示当前尚未完成的目的地请求,当到达该楼层以后自动撤销本楼层的请求,即将面板灯熄灭.3、除1层和4层分别只有上/下按钮外,每个楼层(电梯门口旁)的召唤面板都有两个按钮,分别指示上楼和下楼请求.4、电梯的外部面板会显示电梯当前所在的楼层,及上行还是下行(暂停显示刚才运行时的状态).当电梯在运行时,对应的楼层灯间固定显示一段时间进入下一楼层.5、电梯向一个方向运行时,只对本方向前方的请求进行应答,直到本方向前方无请求时,才对反方向的请求进行应答。当前内部控制面板上有的请求,只要经过所在楼层均会立即响应.设计图:楼层请求电梯控制系统电路系统时钟请求信号显示楼层请求电梯升、降、停电梯门开关3.1方案论证1 方案的选择1、当电梯开始启动的时候,将当前所处的楼层置为第一层,电梯为暂停状态,方向向上,然后等待控制器的调度2、等待过程当中(FLOOR保持在该楼层),判断当前楼层(第I层)以上的楼层是否发出召唤或者已经有人已经发请求,若有则向上运行;否则以同样的方法判断是否向下运行;若不向下运行则重复等待状态3、若已经判明要向上运行,则首先使运行暂停触发器置为运行,且标志向上运行,控制LED在该楼层亮后将所在楼层加,接着判断当前楼层是否发出向上召唤或者已经有人已经发出目的地为第i+1层的请求,若有则在第i+1层停靠;否则判断第i+1层以上的楼层是否发出召唤或者已经有人已经发出目的地为第i+1层以上的请求,若有则向上运行若不在当前的第i+1层停靠,就使灯闪烁,继续中开始的操作如果停靠就修改运行状态为停止,撤销所在楼层的召唤请求和目的地任务,接受用户的目的地请求,然后为等待状态3.2模块设计3.1电梯门控模块设计:该模块用于控制电梯门的开关模块定义如下:module door(door, /电梯门状态close_door, /关门信号open_door, /开门信号cnt_time, /开门时间计数status, /电梯运行状态floor, /到达楼层信号);I/O管脚描述(二)名称方向位宽功能clkinput1时钟脉冲rstinput1复位信号(高电平有效)close_doorinput1关门信号open_doorinput1开门信号dooroutput1电梯门状态3.2楼层显示模块设计:该模块用于译码器显示当前所在楼层。模块定义如下:module storey(floor, /到达楼层信号direction, /电梯运行方向status, /电梯运行状态cnt, /电梯楼层计数number, /电梯楼层数);I/O管脚描述(一)名称方向位宽功能clkinput1时钟脉冲rstinput1复位信号(高电平有效)floorinput1所到楼层信号(高电平有效)numberoutput1电梯楼层数 3.3电梯控制模块设计:该模块控制电梯的运行方向,运行状态,并设置指示灯。模块定义:module control(up1 to up3, /电梯外部上升请求down2 to down4, /电梯外部下降请求inter_button1 to inter_button4, /电梯内部靠站请求led_up1 to led_up3, /电梯上升指示灯led-down2 to led_down4, /电梯下降指示灯status, /电梯运行状态direction, /电梯运行方向r_up1 to r_up3,r_down2 to r_down4,r_inter1 to r_inter4,cnt, /楼层计数floor, /所到楼层信号);I/O管脚描述(三)名称方向位宽功能clkinput1时钟脉冲rstinput1复位信号(高电平有效)up1 to up3input1电梯外部上升请求down2 to down4input1电梯外部下降请求inter_button1 to inter_button4input1电梯内部停站请求led_up1 to led_up3output1电梯上升指示灯led-down2 to led_down4output1电梯下降指示灯r_up1 to r_up3output2电梯上升寄存信号r_down2 to r_down4output2电梯下降寄存信号r_inter1 to r_inter4output2电梯内部请求寄存信号statusoutput1电梯运行状态directionoutput1电梯运行方向4 仿真测试:在波形仿真中,根据实际,我们有必要做一些假设,即是:a、外部请求上升的乘客,进入电梯后一定是按更高层的停站按钮;b、外部请求下降的乘客,进入电梯后一定是按更低层的停站按钮;c、如果有乘客进入电梯,则一定有停站请求;d、同一时刻有很多人按键的概率很小,所以我们认为请求信号都有一定的先后顺序。1、给定测试的总过程是:开始电梯停在一楼,二楼有人按了向上的请求,电梯未到达二楼前,有人按了三楼停靠请求,紧接着二楼又有人按了向下的请求,然后有人按了一楼的停靠请求,电梯到达三楼后,一楼有人按了向上的请求。图一 仿真结果示意总图2、这是电梯从一楼运动到三楼的波形,由于电梯向一个方向运行时,只对本方向前方的请求进行应答,直到本方向前方无请求时,才对反方向的请求进行应答。所以该电梯只回应了从一楼向上的请求。图二 电梯上升过程 3、这时电梯从三楼到一楼的仿真波形,原因同上,当电梯响应完向上的请求后,才处理反方向的信号器2的时钟输入。图三 电梯下降过程5 结论:在本学期做课程设计的过程中,我学习了VHDL语言的基本语法,也学到了很多东西,本课题在选题及研究过程中遇到了很多难题,让我深刻的意识到课外拓展及自学的重要性。同时感谢那些给予帮助的同学们,在他们的帮助下,我才能顺利完成设计,另外,在以后的课程设计中,一定要敢于克服难题,多动脑,这样才会有所收获。参考文献1 夏宇闻.verilog数字系统设计教程第二版.北京航空航天大学出版社.2006.01附件完整程序module lift2(clk, /1KHz reset, /reset signal,low(0) active up1, /1st floor ,request for up,high active up2, /2nd floor ,request for up,high active up3, /3rd floor,request for up,high active down2, /2th floor ,request for down,high active down3, /3th floor ,request for down,high active down4, /4th floor ,request for down,high active inter_button1, /inside of the lift,request for 1st floor,high active inter_button2, /inside of the lift,request for 2nd floor,high active inter_button3, /inside of the lift,request for 3rd floor,high active inter_button4, /inside of the lift,request for 4th floor,high active close_door, /the signal for close the liftdoor,high active open_door, /the signal for open the liftdoor,high active floor, /the signal for the lift arriving at the floor,high active led_up1, /output led_up2, /output led_up3, /output led_down2, /output led_down3, /output led_down4, /output inter1, /output inter2, /output inter3, /output inter4, /output status, /output 1-operate 0-stop door, /output 0-close,1-open number, /output r_up1,r_up2,r_up3,r_down2,r_down3,r_down4, r_inter1,r_inter2,r_inter3,r_inter4 );input clk,reset/*,maintain*/;input up1,up2,up3,down2,down3,down4;input inter_button1,inter_button2,inter_button3,inter_button4;input close_door,open_door;input floor;output led_up1,led_up2,led_up3;output led_down2, led_down3, led_down4;output inter1,inter2,inter3,inter4;output door; /0-close,1-openoutput 1:0number;output status;output 1:0r_up1,r_up2,r_up3,r_down2,r_down3,r_down4, r_inter1,r_inter2,r_inter3,r_inter4;reg led_up1,led_up2,led_up3;reg led_down2, led_down3, led_down4;reg inter1,inter2,inter3,inter4;reg door;reg 1:0direction; /11-up,00-downreg 1:0cnt; /count for the floorreg 2:0cnt_time; /count the time for the doorreg status; /operate-1,stop-0reg 1:0r_up1,r_up2,r_up3,r_down2,r_down3,r_down4;reg 1:0r_inter1,r_inter2,r_inter3,r_inter4;parameter f1=2d0,/1st floor f2=2d1,/2nd floor f3=2d2,/3rd floor f4=2d3;/4th floor parameter s1=2d0,/1st floor s2=2d1,/2nd floor s3=2d2,/3rd floor s4=2d3;/4th floorwire t1=( r_up1!=f1 | r_inter1!=f1 );/-judge the lifts storey-/ always (posedge clk or negedge reset)begin if (!reset ) cnt=f1; else if (status=0) cnt=cnt; else if (status=1b1 &floor=1b1) begin if (direction=2b11) cnt=cnt+1; else if (direction=0) cnt=cnt-1; else cnt=cnt; end else cnt=cnt;endassign number=cnt; /-the lifts door-/always (posedge clk or negedge reset )begin if(!reset ) door=1b0; else if(status=1b1) /the lift is operating. door=1b0; else if(close_door & (status=0 &floor=1) ) door=1b0; else if(cnt_time=3d5 & (status=0 &floor=1) ) door=1b0; else if( cnt=f1 & s1=0) door=1b0; else if (status=0 & floor=1 /*& cnt_time=3d0*/) /the lift is stopping. door=1b1; else if (open_door&(status=1b0 &floor=1b1) door=1b1; else door=door;endalways (posedge clk or negedge reset /*or posedge door*/)begin if(!reset) cnt_time=3d0; else if (door=1b1) cnt_time=cnt_time+1; else cnt_time=3d0;end/-the lift control-/always (posedge clk or negedge reset) /the lifts request - the 1st floor begin if(!reset ) begin led_up1=1b0; r_up1=2b11; end else if(up1) begin r_up1=f1; led_up1=1b1; end else if(cnt=s1) begin led_up1=1b0; r_up1=2b11; end end always (posedge clk or negedge reset) /the lifts request -the 2nd floor begin if(!reset ) begin led_up2=1b0; r_up2=2b00; end else if(up2) begin r_up2=f2; led_up2=1b1; end else if(cnt=s2) begin led_up2=1b0; r_up2=2b00; end end always (posedge clk or negedge reset) /the lifts request begin if(!reset ) begin led_up3=1b0; r_up3=2b00; end else if (up3) begin r_up3=f3; led_up3=1b1; end else if (cnt=s3) begin led_up3=1b0; r_up3=2b00; end end always (posedge clk or negedge reset) /the lifts request begin if(!reset ) begin led_down2=1b0; r_down2=2b00; end else if(down2) begin r_down2=f2; led_down2=1b1; end else if(cnt=s2) begin led_down2=1b0; r_down2=2b00; end end always (posedge clk or negedge reset) /the lifts request begin if(!reset ) begin led_down3=1b0; r_down3=2b00; end else if(down3) begin r_down3=f3; led_down3=1b1; end else if(cnt=s3) begin led_down3=1b0; r_down3=2b00; end end always (posedge clk or negedge reset) /the lifts request begin if(!reset ) begin led_down4=1b0; r_down4=2b00; end else if(down4) begin r_down4=f4; led_down4=1b1; end else if(cnt=s4) begin led_down4=1b0; r_down4=2b00; end end always (posedge clk or negedge reset) /the lifts request begin if(!reset ) begin inter1=1b0; r_inter1=2b11; end else if(inter_button1) begin inter1=1b1; r_inter1=f1; end else if(cnt=s1) begin inter1=1b0; r_inter1=2b11; end endalways (posedge clk or negedge reset) /the lifts request begin if(!reset ) begin inter2=1b0; r_inter2=2b00; end else if(inter_button2) begin inter2=1b1; r_inter2=f2; end else if(cnt=s2) begin inter2=1b0; r_inter2=2b00; end end always (posedge clk or negedge reset) /the lifts request begin if(!reset ) begin inter3=1b0; r_inter3=2b00; end else if(inter_button3) begin inter3=1b1; r_inter3=f3; end else if(cnt=s3) begin inter3=1b0; r_inter3=2b00; end end always (posedge clk or negedge reset) /the lifts request begin if(!reset ) begin inter4=1b0; r_inter4=2b00; end else if(inter_button4) begin inter4=1b1; r_inter4=f4; end else if(cnt=s4) begin inter4=1b0; r_inter4=2b00; end end wire tt = (r_up1=f1|r_up2=f2|r_up3=f3|r_down2=f2|r_down3=f3|r_down4=f4|r_inter2=f2|r_inter3=f3|r_inter4=f4) ; always (posedge clk or negedge reset)begin if (!reset) direction=2b10; else begin case(cnt) s1:begin if (r_up1=f1|r_up2=f2|r_up3=f3|r_down2=f2|r_down3=f3|r_down4=f4|r_inter2=f2|r_inter3=f3|r_inter4=f4) direction=2b11; else direction=2b11; end s2:begin if(direction=2b11) begin if ( r_up2=f2 | r_up3=f3 | r_down4=f4 | r_down3=f3 | r_inter3=f3 | r_inter4=f4 ) direction=2b11; else if (r_up1=f1 | r_down2=f2 | r_inter1=f1 ) direction=2b00; end else if(direction=2b00) begin if(r_up1=f1|r_down2=f2|r_inter1=f1) direction=2b00; else if (r_up2=f2 | r_up3=f3 | r_down4=f4 | r_down3=f3 | r_inter3=f3 |
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 2025员工劳动合同协议书模板
- 2025标准版自然人借款合同书
- 2025年白茶 考试试题及答案
- 2025年酒店前台考试试题及答案
- 秦淮区房屋防潮施工方案
- 地下游泳池防潮施工方案
- 句容铸铁暖气片施工方案
- 设施实施改造方案范本
- 河道防渗漏工程施工方案
- 江苏蔬菜冷藏库施工方案
- 《非道路移动工程机械二手设备评估通则》
- 监控验收单完整版本
- DL-T-5743-2016水电水利工程土木合成材料施工规范
- (正式版)YST 1682-2024 镁冶炼行业绿色工厂评价要求
- 体育健康知识教案课件
- 卡西欧dh800电吹管说明书
- 体育课免修申请书体育课免修申请书八篇
- 【超星尔雅学习通】商法的思维网课章节答案
- 509册泵类书籍大全-截止到20150531
- GB/T 5796.3-2022梯形螺纹第3部分:基本尺寸
- GA 576-2018防尾随联动互锁安全门通用技术条件
评论
0/150
提交评论