




版權(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ì)自己和他人造成任何形式的傷害或損失。
最新文檔
- DB32/T 4448-2023信息系統(tǒng)運(yùn)行維護(hù)體系建設(shè)指南
- DB32/T 4406-2022高速公路施工質(zhì)量檢查技術(shù)標(biāo)準(zhǔn)
- DB32/T 3589-2019皺紋盤鮑淺海筏式養(yǎng)殖技術(shù)規(guī)程
- DB32/T 3564-2019節(jié)段預(yù)制拼裝混凝土橋梁設(shè)計(jì)與施工規(guī)范
- DB32/T 3555-2019消防機(jī)構(gòu)食堂設(shè)施設(shè)備配置規(guī)范
- DB32/T 3310-2017船閘維護(hù)規(guī)程
- DB31/T 999.3-2016網(wǎng)上政務(wù)大廳接入技術(shù)規(guī)范第3部分:業(yè)務(wù)協(xié)同數(shù)據(jù)交換格式
- DB31/T 635-2020造船行業(yè)職業(yè)病危害控制規(guī)范
- DB31/T 1343-2022醫(yī)用超聲探頭消毒衛(wèi)生要求
- DB31/T 1187-2019特種設(shè)備風(fēng)險(xiǎn)分級(jí)管控實(shí)施指南
- DBJ45 024-2016 巖溶地區(qū)建筑地基基礎(chǔ)技術(shù)規(guī)范
- 養(yǎng)殖產(chǎn)業(yè)政策與市場(chǎng)趨勢(shì)分析-洞察分析
- 快遞柜租賃合同
- 2025年電源管理芯片市場(chǎng)分析報(bào)告
- 2025年行政執(zhí)法證考試必考題庫(kù)及答案(共四套)
- 《律師事務(wù)所管理辦法》(全文)
- 校長(zhǎng)國(guó)培計(jì)劃培訓(xùn)成果匯報(bào)
- 湖南出版中南傳媒招聘筆試真題2023
- 2025年河北省職業(yè)院校高職組“食品安全與質(zhì)量檢測(cè)”技能大賽參考試題庫(kù)(含答案)
- 中國(guó)血管性認(rèn)知障礙診治指南(2024版)解讀
- 2024版房屋市政工程生產(chǎn)安全重大事故隱患判定標(biāo)準(zhǔn)內(nèi)容解讀
評(píng)論
0/150
提交評(píng)論