




版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)
文檔簡(jiǎn)介
1、精品文檔這個(gè)程序不需要你再添加任何的程序,你只需要添加樓層數(shù)就可以成功控制 6 層以上電梯,另外你必須得讀懂每一塊程序的作用,才能對(duì)這個(gè)程序有更好的應(yīng)用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; /故障警報(bào)鍵out
2、put6:0 hex,lig; /light 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 下降按鍵,/now_f量reg1:0 ud_f;/reg light;/reg29:0 counter;/reg clkout;和 led 用數(shù)碼管是內(nèi)部按鍵, up 外部上升按鍵,dn 是外部是當(dāng)前樓層,curr 是當(dāng)前樓層的另外一個(gè)變上升下降標(biāo)志位parameteridle_state=3'b
3、001,open_state=3'b010,close_state=3'b011,up_state=3'b100,down_state=3'b101,sleep_state=3'b110,alarm_state=3'b111,f1=6'b000001,f2=6'b000010,f3=6'b000100,f4=6'b001000 ,f5=6'b010000,f6=6'b100000,up_f=2'b01,dn_f=2'b10,idle=2'b00;/jiu zhong zhua
4、ng tai he shang sheng zhuang tai 'shang sheng zhuang tai he xia jia zhuang taiinitialbeginstate<=idle_state;endalways (posedge clk or posedge reset)if(reset)state<=idle_state;elsestate<=next_state;always (state or up or dn or d or now_f or count or ud_f)case(state)open_state:beginif(cou
5、nt<5)next_state=open_state;elsenext_state=close_state;endsleep_state:beginif(up|dn|d|ud_f)=0)beginnext_state=close_state;endelsenext_state=idle_state;endidle_state: /初始狀態(tài)beginif(up|dn|d|ud_f)=0)next_state=sleep_state;if(!overw|pro=1)next_state=alarm_state;else if(d>0)beginif(d&now_f)>0)
6、next_state=open_state;else if(d>now_f) next_state=up_state;elsenext_state=down_state;endelse if(up&now_f)|(dn&now_f) next_state=open_state;else if(up>now_f)|(dn>now_f) next_state=up_state;else if(up|dn)next_state=down_state;elsenext_state=idle_state;endup_state:beginif(up|dn|d|ud_f)
7、=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(d>now_f)|(up>now_f) next_state=up_state;else if(d<now_f)|(up<now_f) /else if(d|up) wait speak next_state=down_state;else if(dn>0)beginif(dn>now_f)next_
8、state=up_state;else if(dn&now_f)|(now_f<f6) next_state=open_state;else if(dn&now_f)&&(now_f=f6) next_state=open_state;elsenext_state=down_state;endelsenext_state=idle_state;enddown_state:beginif(up|dn|d|ud_f)=0)next_state=sleep_state;else if(!overw|pro=1)next_state=alarm_state;els
9、e if(d&now_f)|(dn&now_f)next_state=open_state;elseif(d<now_f)&&(d!=6'b000001)|(dn<now_f)&&(dn!=6'b000001) next_state=down_state;else if(d>now_f)|(dn>now_f)next_state=up_state;else if(up>0)beginif (up<now_f)next_state=down_state;else if(up&now_f)&
10、amp;&(now_f>f1) next_state=down_state;else if(up&now_f)&&(now_f=f1) next_state=open_state;elsenext_state=up_state;endelsenext_state=idle_state;endclose_state:beginif(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)beginif(d&
11、;now_f)|(up&now_f) next_state=open_state;else if(d>now_f)|(up>now_f) next_state=up_state;else if(d|up)next_state=down_state;else if(dn>0)beginif(dn>now_f)next_state=up_state;else if(dn&now_f)>0) next_state=open_state;elsenext_state=down_state;endelsenext_state=idle_state;endel
12、se if(ud_f=dn_f)beginif(d&now_f)|(dn&now_f) next_state=open_state;elseif(d<now_f)&&(d!=6'b000000)|(dn<now_f)&&(dn!=6'b000000) next_state=down_state;else if(d|dn)next_state=up_state;else if(up>0)beginif(up<now_f)next_state=down_state;else if(up&now_f)&g
13、t;0) next_state=open_state;elsenext_state=up_state;endelsenext_state=idle_state;endelsebeginif(d>0)beginif(d&now_f)>0)next_state=open_state;else if(d>now_f) next_state=up_state;elsenext_state=down_state;endelse if(up&now_f)&&(dn&now_f) next_state=open_state;else if(up>
14、;now_f)&&(dn>now_f) next_state=up_state;else if(up|dn)next_state=down_state;elsenext_state=idle_state;endendalarm_state:beginif(!overw|pro=1)begin/Buzzer1<=1'b1;next_state=open_state;endelsebegin/Buzzer1<=1'b0;if(d>0)beginif(d&now_f)>0)next_state=open_state;else if
15、(d>now_f)next_state<=up_state;elsenext_state=down_state;endelse if(up&now_f)|(dn&now_f) next_state=open_state;else if(up>now_f)|(dn>now_f) next_state=up_state;else if(up|dn)next_state=down_state;elsenext_state=idle_state;endenddefault:next_state<=idle_state;endcasealways (up1
16、or up2 or up3 or up4 or up5)up =1'b0,up5,up4,up3,up2,up1;always (dn2 or dn3 or dn4 or dn5 or dn6)dn =dn6,dn5,dn4,dn3,dn2,1'b0;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)beginif(reset)count<=0;else if(next_state=open_state)&&(
17、count<5) count<=count+1;elsecount<=0;endalways (posedge clk or posedge reset )/always (reset or next_state)if(reset)beginnow_f<=f1;ud_f<=idle;led<=6'b000001;light<=1'b0;endelsebeginnow_f<=now_f;curr=now_f;6歡迎下載 。精品文檔case(next_state) idle_state: beginnow_f<=now_f;ud
18、_f<=idle;led<=led;curr<=now_f;Buzzer1<=1'bO;endup_state:beginn o w_f<=n o w_f< < 1; ud_f<=up_f;led<=led+1; curr<=now_f;enddown_state: beginn o w_f<=n o w_f> > 1; ud_f<=dn_f;led<=led+1; curr<=now_f; endopen_state: beginnow_f<=now_f;ud_f<=ud_f;
19、led<=led;door<=1'b1;light<=door; curr<=now_f; endclose_state:begin now_f<=now_f; ud_f<=ud_f; led<=led;curr<=now_f;door<=1'bO; light<=door; end alarm_state: beginnow_f<=now_f;ud_f<=ud_f;led<=led;Buzzer1<=1'b1;curr<=now_f;door<=1'b1;light<=door;endsleep_state:beginnow_f<=now_f;ud_f<=ud_f;led<=6'b000000;curr<=now_f;enddefault:beginnow_f<=f1;ud_f<=idle;led<=led;endendcaseendalways (curr)begincase(curr)6'b000
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁(yè)內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫(kù)網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。
最新文檔
- 第七章 力第2節(jié) 彈力(教學(xué)設(shè)計(jì))2024-2025學(xué)年度人教版(2024)物理八年級(jí)下冊(cè)
- 中國(guó)核酸檢測(cè)試劑行業(yè)市場(chǎng)全景分析及投資前景展望報(bào)告
- 2025年油漆油墨項(xiàng)目投資可行性研究分析報(bào)告
- Unit 5 Poems Using Language 教學(xué)設(shè)計(jì)-2023-2024學(xué)年高中英語(yǔ)人教版(2019)選擇性必修第三冊(cè)
- 房屋出租合同協(xié)議范本6篇
- 辦公樓裝修改造項(xiàng)目概述
- 未來五年中式餐飲行業(yè)預(yù)測(cè)與發(fā)展戰(zhàn)略
- 時(shí)尚女裝店裝修合同樣本
- 2025-2030年中國(guó)緞紋摩絲桃皮絨項(xiàng)目投資可行性研究分析報(bào)告
- 二零二五年度液化氣汽車加氣站項(xiàng)目投資合同
- 關(guān)于辦理物業(yè)管理交接事宜告知函
- 全面新編部編版四年級(jí)下冊(cè)語(yǔ)文教材解讀分析
- 《電解富氫水機(jī)》課件
- 《建筑工程質(zhì)量檢驗(yàn)評(píng)定標(biāo)準(zhǔn)》
- 江蘇農(nóng)牧科技職業(yè)學(xué)院?jiǎn)握小堵殬I(yè)技能測(cè)試》參考試題庫(kù)(含答案)
- VDA6.3 2023過程審核教材
- 2024年青海省旅游行業(yè)分析報(bào)告及未來發(fā)展趨勢(shì)
- 高職應(yīng)用語(yǔ)文教程(第二版)教案 3管晏列傳
- 高中物理《光電效應(yīng)》
- 高中教師職業(yè)發(fā)展規(guī)劃及目標(biāo)
- 烹飪實(shí)訓(xùn)室安全隱患分析報(bào)告
評(píng)論
0/150
提交評(píng)論