




已阅读5页,还剩11页未读, 继续免费阅读
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
精品文档这个程序不需要你再添加任何的程序,你只需要添加楼层数就可以成功控制6层以上电梯,另外你必须得读懂每一块程序的作用,才能对这个程序有更好的应用module dtsj(clk,reset,up1,up2,up3,up4,up5,dn2,dn3,dn4,dn5,dn6,d1,d2,d3,d4,d5,d6,overw,pro,led,hex,Buzzer1,lig);input clk,reset; /reset键使用keyinput overw,pro,up1,up2,up3,up4,up5,dn2,dn3,dn4,dn5,dn6,d1,d2,d3,d4,d5,d6; /故障警报键output6:0 hex,lig; /light和led用数码管output5:0 led;output Buzzer1;reg Buzzer1,door;reg6:0 hex,lig;reg2:0state,next_state,count;reg5:0 d,up,dn,now_f,curr,led; /d是内部按键,up外部上升按键,dn是外部下降按键, /now_f是当前楼层,curr是当前楼层的另外一个变量reg1:0 ud_f; /上升下降标志位reg light;/reg29:0 counter;/reg clkout;parameter idle_state=3b001,open_state=3b010,close_state=3b011, up_state=3b100,down_state=3b101,sleep_state=3b110, alarm_state=3b111,f1=6b000001,f2=6b000010,f3=6b000100,f4=6b001000 ,f5=6b010000,f6=6b100000,up_f=2b01,dn_f=2b10,idle=2b00; /jiu zhong zhuang tai he shang sheng zhuang tai shang sheng zhuang tai he xia jia zhuang tai initial begin state=idle_state; endalways (posedge clk or posedge reset) if(reset) state=idle_state; else state=next_state;always (state or up or dn or d or now_f or count or ud_f) case(state) open_state: begin if(count0) begin if(d&now_f)0) next_state=open_state; else if(dnow_f) next_state=up_state; else next_state=down_state; end else if(up&now_f)|(dn&now_f) next_state=open_state; else if(upnow_f)|(dnnow_f) next_state=up_state; else if(up|dn) next_state=down_state; else next_state=idle_state; end up_state: begin if(up|dn|d|ud_f)=0) next_state=sleep_state; if(!overw|pro=1) next_state=alarm_state; else if(d&now_f)|(up&now_f) next_state=open_state; else if(dnow_f)|(upnow_f) next_state=up_state; else if(dnow_f)|(up0) begin if(dnnow_f) next_state=up_state; else if(dn&now_f)|(now_ff6) next_state=open_state; else if(dn&now_f)&(now_f=f6) next_state=open_state; else next_state=down_state; end else next_state=idle_state; end down_state: begin if(up|dn|d|ud_f)=0) next_state=sleep_state; else if(!overw|pro=1) next_state=alarm_state; else if(d&now_f)|(dn&now_f) next_state=open_state; else if(dnow_f)&(d!=6b000001)|(dnnow_f)|(dnnow_f) next_state=up_state; else if(up0) begin if (upf1) next_state=down_state; else if(up&now_f)&(now_f=f1) next_state=open_state; else next_state=up_state; end else next_state=idle_state; end close_state: begin if(up|dn|d|ud_f)=0) next_state=sleep_state; else if(!overw|pro=1) next_state=alarm_state; else if(ud_f=up_f) begin if(d&now_f)|(up&now_f) next_state=open_state; else if(dnow_f)|(upnow_f) next_state=up_state; else if(d|up) next_state=down_state; else if(dn0) begin if(dnnow_f) next_state=up_state; else if(dn&now_f)0) next_state=open_state; else next_state=down_state; end else next_state=idle_state; end else if(ud_f=dn_f) begin if(d&now_f)|(dn&now_f) next_state=open_state; else if(dnow_f)&(d!=6b000000)|(dn0) begin if(up0) next_state=open_state; else next_state=up_state; end else next_state=idle_state; end else begin if(d0) begin if(d&now_f)0) next_state=open_state; else if(dnow_f) next_state=up_state; else next_state=down_state; end else if(up&now_f)&(dn&now_f) next_state=open_state; else if(upnow_f)&(dnnow_f) next_state=up_state; else if(up|dn) next_state=down_state; else next_state=idle_state; end end alarm_state: begin if(!overw|pro=1) begin /Buzzer1=1b1; next_state=open_state; end else begin /Buzzer10) begin if(d&now_f)0) next_state=open_state; else if(dnow_f) next_statenow_f)|(dnnow_f) next_state=up_state; else if(up|dn) next_state=down_state; else next_state=idle_state; end end default: next_state=idle_state; endcase always (up1 or up2 or up3 or up4 or up5) up =1b0,up5,up4,up3,up2,up1; always (dn2 or dn3 or dn4 or dn5 or dn6) dn =dn6,dn5,dn4,dn3,dn2,1b0; always (d1 or d2 or d3 or d4 or d5 or d6) d =d6,d5,d4,d3,d2,d1; always (posedge clk or posedge reset) begin if(reset) count=0; else if(next_state=open_state)&(count5) count=count+1; else count=0; endalways (posedge clk or posedge reset ) /always (reset or next_state) if(reset) begin now_f=f1; ud_f=idle; led=6b000001; light=1b0; end else begin now_f=now_f; curr=now_f; case(next_state) idle_state: begin now_f=now_f; ud_f=idle; led=led; curr=now_f; Buzzer1=1b0; end up_state: begin now_f=now_f1; ud_f=up_f; led=led+1; curr=now_f; end down_state: begin now_f1; ud_f=dn_f; led=led+1; curr=now_f; end open_state: begin now_f=now_f; ud_f=ud_f; led=led; door=1b1; light=door; curr=now_f; end close_state: begin now_f=now_f; ud_f=ud_f; led=led; curr=now_f; door=1b0; light=door; end alarm_state: begin now_f=now_f; ud_f=ud_f; led=led; Buzzer1=1b1; curr=now_f; door=1b1; light=door; end sleep_state: begin now_f=now_f; ud_f=ud_f; led=6b000000; curr=now_f; end default: begin now_f=f1; ud_f=idle; led=led; end endcase end always (curr)begin case(curr) 6b000001: hex=7b1111001; /数码管共阴共阳 6b000010: hex=7b1000100; 6b000100: hex=7b0110000; 6b001000: hex=7b0011001; 6b010000: hex=7b1101101; 6b100000: hex=7b1111101; default: hex=7b0000000; endcase endalways (light) begin case(light) 1b0: lig=7b1000000; /1b1: lig=7b1000000; 1b1: lig=7b1111001; default: lig
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 农业灌溉非织造布创新创业项目商业计划书
- 肠粉店创新创业项目商业计划书
- 公章使用与管理规范操作手册
- 生产车间标准操作流程SOP范本
- 【外研高二下】辽宁省锦州市2019-2022三年高二下学期英语期末试卷汇编:完形填空
- 中小学植物学实验练习题集锦
- 高中地理实验教学设计范例
- 2025年急诊急救技术应用专项能力测试(小儿食物中毒护理干预)考核试卷
- 城市轻盈步:绿色出行方案-解决交通问题推动可持续发展
- 2025年新能源行业电动汽车充电设施产业规划与布局设计资格考核试卷
- 2025年世界粮食日节约粮食光盘行动班会《莫让“食”光成为“失”光》
- 《念奴娇·赤壁怀古》+2025-2026学年统编版高一语文必修上册
- 2025年河北石家庄市市属国有企业面向社会公开招聘工作人员(525人)笔试题库历年考点版附带答案详解
- 重庆八中高 2027 届高二(上)第一次月考语文试卷(含答案)
- 2025年石嘴山市消防救援支队招录第二批政府专职消防队员的(65人)考试参考试题及答案解析
- 中国联通辽宁地区2025秋招笔试行测题库及答案行业解决方案经理岗
- 基础水文数据采集与管理项目方案
- 医院患者服务满意度调查表模板
- 土壤沉积物中可溶性有机质对辣根过氧化物酶催化氧化去除双酚A的作用机制探究
- 注塑机操作安全培训课件
- DB-T 29-88-2025 天津市民用建筑围护结构节能检测技术规程
评论
0/150
提交评论