




已阅读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. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 农业产业集群农业科技创新与产业升级报告
- DB3311-T 269-2023 畲绣绣制技术规程
- 2025年工业园区污水处理站初步设计评估及可持续发展策略报告
- 血液净化医疗服务行业发展趋势预测与竞争格局研究报告2025
- 2025年新能源汽车无线充电技术对充电桩市场的影响分析
- 英语教学知识培训心得课件
- 氢能时代2025:基础设施投资成本控制与技术创新研究报告
- 电商物流“最后一公里”配送人员培训与职业发展报告
- 跨境支付领域2025年区块链技术在跨境支付中的安全防护
- 同工同酬培训课件
- 房地产样板间装饰工程重点难点及措施
- 康复科护理金点子
- 工地油库安全管理办法
- 全球治理转型-洞察及研究
- 高等数学课程教学中遇到的问题及解决对策
- (高清版)DB32∕T 4001-2025 公共机构能耗定额及计算方法
- 电力物资打包方案(3篇)
- 2025至2030中国味精行业发展趋势分析与未来投资战略咨询研究报告
- 保险执业登记管理制度
- 你的样子就是教育的样子-一位校长对教师行为规范的深度思考建议收藏
- 中医治疗泌尿系结石课件
评论
0/150
提交评论