數(shù)字邏輯課程設(shè)計(jì)-電梯控制系統(tǒng)Word版_第1頁
數(shù)字邏輯課程設(shè)計(jì)-電梯控制系統(tǒng)Word版_第2頁
數(shù)字邏輯課程設(shè)計(jì)-電梯控制系統(tǒng)Word版_第3頁
數(shù)字邏輯課程設(shè)計(jì)-電梯控制系統(tǒng)Word版_第4頁
數(shù)字邏輯課程設(shè)計(jì)-電梯控制系統(tǒng)Word版_第5頁
已閱讀5頁,還剩62頁未讀, 繼續(xù)免費(fèi)閱讀

下載本文檔

版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進(jìn)行舉報(bào)或認(rèn)領(lǐng)

文檔簡介

整理為word格式整理為word格式整理為word格式數(shù)字電路與邏輯設(shè)計(jì)課程設(shè)計(jì)報(bào)告題目:電梯控制器的設(shè)計(jì)與實(shí)現(xiàn)專業(yè): 班級(jí): 學(xué)號(hào): 姓名: 電話: 郵件: 分組: 完成日期: 指導(dǎo)教師: 整理為word格式整理為word格式整理為word格式團(tuán)隊(duì)成員:姓名班級(jí)學(xué)號(hào)貢獻(xiàn)百分比實(shí)驗(yàn)部分完成情況(亮點(diǎn)、完成、基本完成、未完成、時(shí)間)總分:實(shí)驗(yàn)部分70%+報(bào)告30%)檢查老師簽名:整理為word格式整理為word格式整理為word格式目錄課程設(shè)計(jì)概述.........................................................................................................................................課設(shè)目的............................................................................................................................課設(shè)要求............................................................................................................................課設(shè)任務(wù)............................................................................................................................實(shí)驗(yàn)環(huán)境............................................................................................................................基本方案設(shè)計(jì).........................................................................................................................................設(shè)計(jì)需求............................................................................................................................總體結(jié)構(gòu)設(shè)計(jì)....................................................................................................................電梯狀態(tài)判斷模塊..........................................................................................................電梯上下樓控制模塊......................................................................................................電梯開關(guān)門模塊..............................................................................................................整理為word格式整理為word格式整理為word格式電梯升降模塊..................................................................................................................電梯指示燈模塊..............................................................................................................電梯數(shù)碼管顯示模塊......................................................................................................詳細(xì)設(shè)計(jì)............................................................................................................................電梯狀態(tài)判斷模塊..........................................................................................................電梯上下樓控制模塊....................................................................................................電梯開關(guān)門模塊............................................................................................................電梯升降模塊................................................................................................................電梯指示燈模塊............................................................................................................電梯數(shù)碼管顯示模塊....................................................................................................實(shí)驗(yàn)過程與調(diào)試..............................................................................................................真結(jié)果........................................................................................................................整理為word格式整理為word格式整理為word格式主要故障與調(diào)試............................................................................................................1課程設(shè)計(jì)概述1.1課設(shè)目的通過硬件描述語言VHDL的編程,深入了解并掌握可編程芯片PLD的設(shè)計(jì)技術(shù),加強(qiáng)學(xué)生對《數(shù)字邏輯》課程所學(xué)知識(shí)綜合利用的能力。培養(yǎng)學(xué)生創(chuàng)造性思維能力和獨(dú)立解決實(shí)際問題的能力。1.2課設(shè)要求能夠全面地應(yīng)用課程中所學(xué)的基本理論和基本方法,完成從設(shè)計(jì)邏輯電路到設(shè)計(jì)簡單數(shù)字系統(tǒng)的過渡。能力獨(dú)立思考、獨(dú)立查閱資料,獨(dú)立設(shè)計(jì)規(guī)定的系統(tǒng)。能夠獨(dú)立地完成實(shí)施過程,包括安裝、布線、測試和排除故障。1.3課設(shè)任務(wù)制定出詳細(xì)設(shè)計(jì)方案;通過VerilogHDL完成規(guī)定的設(shè)計(jì)任務(wù),然后進(jìn)行編譯和仿真,保證設(shè)計(jì)的正確性;生成容絲圖文件,下載到Basys2開發(fā)板,通過實(shí)際線路進(jìn)行驗(yàn)證;對復(fù)雜系統(tǒng)的設(shè)計(jì)采取模塊化、層次化的設(shè)計(jì)方法;撰寫設(shè)計(jì)報(bào)告,并對存在的問題進(jìn)行分析、提出改進(jìn)意見。1.4實(shí)驗(yàn)環(huán)境Basys2開發(fā)板(芯片為XC3S100E,封裝為CP132)1套;Xilinx_ISE設(shè)計(jì)仿真軟件1套;計(jì)算機(jī)1臺(tái)。整理為word格式整理為word格式整理為word格式2基本方案設(shè)計(jì)2.1設(shè)計(jì)需求隨著科學(xué)技術(shù)的發(fā)展以及城市化建設(shè),越來越多的高樓林立在城市之間,對于電梯的需求也愈發(fā)強(qiáng)烈。因此,一部安全可靠的電梯逐漸成為人們熱議的話題,而我們要設(shè)計(jì)的電梯控制系統(tǒng),能實(shí)現(xiàn)各種用戶需求,并且安全可靠,足以適應(yīng)當(dāng)前社會(huì)發(fā)展的要求。2.2總體結(jié)構(gòu)設(shè)計(jì)本電梯控制器系統(tǒng)包含:電梯狀態(tài)判斷模塊電梯上下樓控制模塊電梯開關(guān)門模塊電梯升降模塊電梯指示燈模塊電梯數(shù)碼管顯示模塊共六個(gè)模塊。電梯分為以下四個(gè)狀態(tài):關(guān)門等待狀態(tài)此時(shí),電梯門關(guān)閉且停在某一樓,等待用戶請求。電梯上行狀態(tài)電梯此刻處于向上運(yùn)行狀態(tài)。電梯下行狀態(tài)電梯此刻處于向下運(yùn)行狀態(tài)。開門狀態(tài)此時(shí),電梯門打開,同時(shí)進(jìn)行關(guān)門倒計(jì)時(shí)。2.2.1電梯狀態(tài)判斷模塊該模塊用于獲取電梯此刻的狀態(tài),并根據(jù)用戶請求進(jìn)行相應(yīng)狀態(tài)轉(zhuǎn)變。輸入:openButton——電梯開門按鍵整理為word格式整理為word格式整理為word格式 powerButton——電梯電源按鍵 targetFloor——用戶請求的目標(biāo)樓層輸出:liftState——電梯狀態(tài)2.2.2電梯上下樓控制模塊該模塊用于獲取用戶請求,判斷電梯是否到達(dá)目標(biāo)樓層以及進(jìn)行計(jì)時(shí)器設(shè)置。輸入:powerButton——電梯電源鍵 resetButton——電梯重置按鍵infloorButton1——電梯內(nèi)部1樓按鍵 infloorButton3——電梯內(nèi)部3樓按鍵 infloorButton6——電梯內(nèi)部6樓按鍵 infloorButton8——電梯內(nèi)部8樓按鍵 outfloorButton1——電梯外部1樓按鍵 outfloorButton3——電梯外部3樓按鍵 outfloorButton6——電梯外部6樓按鍵 outfloorButton8——電梯外部8樓按鍵 liftState——電梯狀態(tài)輸出:targetFloor——目標(biāo)樓層 clkFloor——電梯樓層間運(yùn)行速率 整理為word格式整理為word格式整理為word格式clkLight——電梯運(yùn)行燈 runTime——電梯運(yùn)行時(shí)間2.2.3電梯開關(guān)門模塊該模塊用于處理用戶開關(guān)門請求并進(jìn)行關(guān)門倒計(jì)時(shí)輸入:powerButton——電梯電源按鍵 openButton——電梯開門按鍵 closeButton——電梯關(guān)門按鍵 liftState——電梯狀態(tài)輸出:doorTime——關(guān)門時(shí)間 doorState——電梯門狀態(tài) doorLight——電梯門燈2.2.4電梯升降模塊該模塊進(jìn)行電梯上升、下降處理輸入:liftState——電梯狀態(tài)輸出:currentFloor——當(dāng)前樓層2.2.5電梯指示燈模塊該模塊用于電梯運(yùn)行時(shí),控制上行燈、下行燈亮與滅輸入:liftState——電梯狀態(tài)輸出:upLight——電梯上行燈 ownLight——電梯下行燈 整理為word格式整理為word格式整理為word格式runState——電梯運(yùn)行狀態(tài)2.2.6電梯數(shù)碼管顯示模塊該模塊用于顯示電梯運(yùn)行時(shí)間、關(guān)門時(shí)間、當(dāng)前樓層輸入:currentFloor——當(dāng)前樓層 runTime——運(yùn)行時(shí)間 doorTime——關(guān)門時(shí)間輸出:eightDecode——八段數(shù)碼顯示管 sevenF、sevenJ、sevenM、sevenK——數(shù)碼掃描管顯示2.2.7總控制模塊電梯升降模塊電梯狀態(tài)判斷模塊結(jié)合個(gè)子模塊,共同實(shí)現(xiàn)電梯功能電梯升降模塊電梯狀態(tài)判斷模塊總控制模塊電梯指示燈模塊總控制模塊電梯指示燈模塊電梯上下樓模塊電梯上下樓模塊數(shù)碼管顯示模塊數(shù)碼管顯示模塊電梯開關(guān)門模塊電梯開關(guān)門模塊整理為word格式整理為word格式整理為word格式2.3詳細(xì)設(shè)計(jì)頂層模塊——將各個(gè)子模塊有機(jī)結(jié)合起來,以實(shí)現(xiàn)各個(gè)功能2.3.1電梯狀態(tài)判斷模塊本模塊用于處理電梯各種運(yùn)行狀態(tài)并進(jìn)行設(shè)置整理為word格式整理為word格式整理為word格式模塊模塊開始電源鍵開關(guān)開關(guān)電梯置于關(guān)門狀態(tài)開門鍵開電梯處于關(guān)門狀態(tài)是電梯置于開門狀態(tài)關(guān)電梯處于上升狀態(tài)否否當(dāng)前樓層與目標(biāo)樓層是否相等是電梯置于關(guān)門狀態(tài)電梯運(yùn)行2.3.2電梯上下樓判斷模塊本模塊用于處理用戶樓層請求、以及判斷是否到達(dá)目標(biāo)樓層整理為word格式整理為word格式整理為word格式模塊模塊開始電源鍵是否打開是否電梯目標(biāo)樓層請求清空電梯計(jì)時(shí)器清零電梯重置按下樓層請求只為1樓其他樓層請求清零未按根據(jù)用戶具體樓層按鍵,設(shè)置相應(yīng)樓層請求電梯達(dá)到指定樓層后,對應(yīng)樓層請求清空2.3.3電梯開關(guān)門模塊整理為word格式整理為word格式整理為word格式本模塊用于電梯靜止時(shí)運(yùn)行狀態(tài)本模塊用于電梯靜止時(shí)運(yùn)行狀態(tài)否是否是是否是模塊開始電源鍵是否打開強(qiáng)制開關(guān)打開并且電梯運(yùn)行狀態(tài)為開門或靜止開門指示燈亮,開門狀態(tài)為開,開始5秒倒計(jì)時(shí)電梯運(yùn)動(dòng)狀態(tài)為打開強(qiáng)制關(guān)門鍵開門指示燈滅,倒計(jì)時(shí)直接置為0開門指示燈亮,倒計(jì)時(shí)5秒開門指示燈滅,狀態(tài)為關(guān)門狀態(tài)。關(guān)門計(jì)時(shí)為0整理為word格式整理為word格式整理為word格式2.3.4電梯升降模塊否是電梯狀態(tài)為上升當(dāng)前樓層+1電梯狀態(tài)為下降模塊開始當(dāng)前樓層-12.3.5電梯指示燈模塊本模塊用于指示電梯上下運(yùn)行狀態(tài) 電梯下行狀態(tài)否模塊開始電梯上行狀態(tài)否是是上行指示燈滅,下行指示燈亮上行指示燈亮,下行指示燈滅上、下下指示燈均滅整理為word格式整理為word格式整理為word格式2.3.6電梯數(shù)碼管顯示模塊否是掃描分頻顯示當(dāng)前樓層電梯狀態(tài)為上升或者下降顯示樓層間9秒倒計(jì)時(shí)電梯狀態(tài)為開門顯示5秒開門倒計(jì)時(shí)模塊開始實(shí)驗(yàn)過程與調(diào)試2.4.1模塊內(nèi)部圖1、主模塊整理為word格式整理為word格式整理為word格式輸入:clk:時(shí)鐘端powerButton:電源開關(guān)resetButton:重置開關(guān)openButton:強(qiáng)制開門closeButton:強(qiáng)制關(guān)門infloorButton1:一樓內(nèi)部開關(guān)infloorButton3:三樓內(nèi)部開關(guān)infloorButton6:六樓內(nèi)部開關(guān)infloorButton8:八樓內(nèi)部開關(guān)outfloorButton1:一樓外部開關(guān)outfloorButton3:三樓外部開關(guān)outfloorButton6:六樓外部開關(guān)outfloorButton8:八樓外部開關(guān)整理為word格式整理為word格式整理為word格式輸出:eightDecode:七段顯示譯碼器flashLight:電梯運(yùn)行閃爍燈doorLight:開門顯示燈upLight:上升指示燈floorLight1:一樓指示燈floorLight3:三樓指示燈floorLight6:六樓指示燈floorLight8:八樓指示燈sevenF,sevenJ,sevenM,sevenK:數(shù)碼管掃描指示2.4.2仿真結(jié)果1、電梯狀態(tài)判斷模塊仿真文件如下:moduletest;//Inputsregclk;regpowerButton;regresetButton;regopenButton; regcloseButton; reginfloorButton1; reginfloorButton3; reginfloorButton6; reginfloorButton8; regoutfloorButton1; regoutfloorButton3; regoutfloorButton6; regoutfloorButton8;整理為word格式整理為word格式整理為word格式 //Outputs wire[7:0]eightDecode; wireflashLight; wiredoorLight; wireupLight; wiredownLight; wirefloorLight1; wirefloorLight3; wirefloorLight6; wirefloorLight8; wiresevenF; wiresevenJ; wiresevenM; wiresevenK;alwaysbegin #5; clk=~clk;endalways整理為word格式整理為word格式整理為word格式 begin #5; infloorButton1=~infloorButton1; endalways begin #10; outfloorButton3=~outfloorButton3; endalways begin #15; outfloorButton6=~outfloorButton6; endalways begin #20;infloorButton8=~infloorButton8;end initialbegin //InitializeInputs clk=0; powerButton=1; resetButton=0;openButton=0;closeButton=0;infloorButton1=0;infloorButton3=0;infloorButton6=0;infloorButton8=0;整理為word格式整理為word格式整理為word格式 outfloorButton1=0; outfloorButton3=0; outfloorButton6=0; outfloorButton8=0; endendmodule仿真結(jié)果:2、電梯上下樓判斷模塊仿真文件如下:moduletest; //Inputs regclk; regpowerButton;regresetButton;regopenButton;regcloseButton;reginfloorButton1;整理為word格式整理為word格式整理為word格式reginfloorButton3;reginfloorButton6; reginfloorButton8; regoutfloorButton1; regoutfloorButton3; regoutfloorButton6; regoutfloorButton8; //Outputs wire[7:0]eightDecode; wireflashLight; wiredoorLight; wireupLight; wiredownLight; wirefloorLight1; wirefloorLight3; wirefloorLight6; wirefloorLight8; wiresevenF; wiresevenJ; wiresevenM; wiresevenK;整理為word格式整理為word格式整理為word格式always begin #5; clk=~clk;endalwaysbegin#5;infloorButton1=~infloorButton1;endalways begin #15; outfloorButton3=~outfloorButton3; endalways begin #25; outfloorButton6=~outfloorButton6; endalways begin #35; infloorButton8=~infloorButton8; end initialbegin //InitializeInputs clk=0; powerButton=1; resetButton=0; openButton=0; closeButton=0; infloorButton1=0; infloorButton3=0;infloorButton6=0;infloorButton8=0;outfloorButton1=0;outfloorButton3=0;outfloorButton6=0;outfloorButton8=0;整理為word格式整理為word格式整理為word格式 endendmodule仿真結(jié)果:3、電梯開關(guān)門模塊仿真文件如下:整理為word格式整理為word格式整理為word格式moduletest; //Inputs regclk; regpowerButton; regresetButton; regopenButton; regcloseButton; reginfloorButton1; reginfloorButton3;reginfloorButton6;reginfloorButton8;regoutfloorButton1;regoutfloorButton3;regoutfloorButton6;regoutfloorButton8; //Outputs wire[7:0]eightDecode; wireflashLight; wiredoorLight; wireupLight; wiredownLight; wirefloorLight1; wirefloorLight3; wirefloorLight6; wirefloorLight8; wiresevenF; wiresevenJ; wiresevenM; wiresevenK;整理為word格式整理為word格式整理為word格式always begin #5; clk=~clk; endalways begin #8; openButton=~openButton;endalways#7closeButton=~closeButton;always#50infloorButton8=~infloorButton8;initialbegin //InitializeInputs clk=0; powerButton=1; resetButton=0; openButton=0; closeButton=0; infloorButton1=0; infloorButton3=0; infloorButton6=0; infloorButton8=0; outfloorButton1=0; outfloorButton3=0; outfloorButton6=0; outfloorButton8=0;整理為word格式整理為word格式整理為word格式 //Wait100nsforglobalresettofinish //Addstimulushere endendmodule仿真結(jié)果:4、電梯升降模塊仿真文件如下:moduletest; //Inputs regclk; regpowerButton; regresetButton; regopenButton; regcloseButton; reginfloorButton1; reginfloorButton3; reginfloorButton6; reginfloorButton8; regoutfloorButton1; regoutfloorButton3; regoutfloorButton6; regoutfloorButton8;整理為word格式整理為word格式整理為word格式 //Outputs wire[7:0]eightDecode; wireflashLight; wiredoorLight; wireupLight; wiredownLight; wirefloorLight1; wirefloorLight3; wirefloorLight6; wirefloorLight8; wiresevenF; wiresevenJ; wiresevenM; wiresevenK; always begin整理為word格式整理為word格式整理為word格式 #5; clk=~clk; endalways#10infloorButton8=~infloorButton8;always#100infloorButton3=~infloorButton3; initialbegin //InitializeInputs clk=0; powerButton=1; resetButton=0; openButton=0; closeButton=0; infloorButton1=0; infloorButton3=0; infloorButton6=0; infloorButton8=0; outfloorButton1=0; outfloorButton3=0; outfloorButton6=0; outfloorButton8=0; //Wait100nsforglobalresettofinish //Addstimulushere endendmodule仿真結(jié)果:整理為word格式整理為word格式整理為word格式5、電梯指示燈模塊仿真文件如下:moduletest; //Inputs regclk; regpowerButton; regresetButton; regopenButton; regcloseButton; reginfloorButton1; reginfloorButton3; reginfloorButton6; reginfloorButton8; regoutfloorButton1; regoutfloorButton3; regoutfloorButton6; regoutfloorButton8; //Outputswire[7:0]eightDecode;wireflashLight;wiredoorLight;wireupLight;整理為word格式整理為word格式整理為word格式wiredownLight;wirefloorLight1; wirefloorLight3; wirefloorLight6; wirefloorLight8; wiresevenF; wiresevenJ; wiresevenM; wiresevenK; always begin #5; clk=~clk; endalways begin #20; infloorButton3=~infloorButton3; endalways begin #40;整理為word格式整理為word格式整理為word格式 infloorButton6=~infloorButton6; endalways begin #80; outfloorButton8=~outfloorButton8;endinitialbegin //InitializeInputs clk=0; powerButton=1; resetButton=0; openButton=0; closeButton=0; infloorButton1=0; infloorButton3=0; infloorButton6=0; infloorButton8=0; outfloorButton1=0; outfloorButton3=0; outfloorButton6=0; outfloorButton8=0; //Wait100nsforglobalresettofinish //Addstimulushere整理為word格式整理為word格式整理為word格式 endendmodule仿真結(jié)果:6、電梯數(shù)碼管顯示模塊仿真文件如下:moduletest; //Inputs regclk; regpowerButton; regresetButton; regopenButton; regcloseButton; reginfloorButton1; reginfloorButton3; reginfloorButton6; reginfloorButton8; regoutfloorButton1; regoutfloorButton3; regoutfloorButton6; regoutfloorButton8;整理為word格式整理為word格式整理為word格式 //Outputs wire[7:0]eightDecode; wireflashLight; wiredoorLight; wireupLight; wiredownLight;wirefloorLight1;wirefloorLight3;wirefloorLight6;wirefloorLight8;wiresevenF;wiresevenJ; wiresevenM; wiresevenK; always begin #5; clk=~clk; endalways#10infloorButton6=~infloorButton6;initialbegin//InitializeInputsclk=0;powerButton=1;resetButton=0;openButton=0;closeButton=0;infloorButton1=0;infloorButton3=0;infloorButton6=0;infloorButton8=0;outfloorButton1=0;outfloorButton3=0;outfloorButton6=0;outfloorButton8=0;整理為word格式整理為word格式整理為word格式 //Wait100nsforglobalresettofinish //Addstimulushereendendmodule仿真結(jié)果:2.4.3主要故障與調(diào)試(1)故障1問題描述::3、6兩層電梯外按鍵未設(shè)置上下行按鍵,導(dǎo)致電梯不能完成如(電梯1樓,3樓下,6樓上)這樣的問題整理為word格式整理為word格式整理為word格式解決辦法:增加3樓上下,6樓上下按鍵,以同向較近優(yōu)先,反向較遠(yuǎn)優(yōu)先2.5功能測試2.5.1電梯初始狀態(tài)功能測試圖2.5.1電梯初始狀態(tài)模塊測試功能測試:打開電源,顯示當(dāng)前樓層為一樓。打開強(qiáng)制開門開關(guān),開門燈亮,倒計(jì)時(shí)5秒整理為word格式整理為word格式整理為word格式2.5.2電梯上升模塊功能測試圖2.5.2電梯上升模塊測試功能測試:如圖,打開電源,按下6樓按鈕,6樓指示燈亮,上行指示燈亮,當(dāng)前樓層為4樓,每層樓之間進(jìn)行9秒倒計(jì)時(shí),此時(shí)倒計(jì)時(shí)進(jìn)行至7秒。每層樓之間運(yùn)行指示燈閃爍9下。3.3仿真與測試3總結(jié)與心得4.1課設(shè)總結(jié)為了實(shí)現(xiàn)電梯控制器系統(tǒng)的功能要求,作了如下幾點(diǎn)工作:前期對頂層模塊和子模塊做了劃分,確定了頂層模塊對子模塊的控制每當(dāng)完成一個(gè)子模塊時(shí),便進(jìn)行仿真測試,查找錯(cuò)漏的地方后期上開發(fā)板調(diào)試時(shí),仔細(xì)斟酌各模塊設(shè)計(jì)是否合理,并根據(jù)實(shí)際情況進(jìn)行修改整理為word格式整理為word格式整理為word格式4.2課設(shè)心得本次課程設(shè)計(jì),加強(qiáng)了對上學(xué)期所學(xué)知識(shí)的理解,意識(shí)到理論對實(shí)踐的重要性,也培養(yǎng)了和同學(xué)的交流協(xié)作能力。而設(shè)計(jì)中所存在的缺陷,讓自己意識(shí)到自己分析設(shè)計(jì)的不足。同時(shí),對verilog語言的學(xué)習(xí)和運(yùn)用,也讓自己意識(shí)到在編程能力仍需要提高。附錄(源程序).v文件modulemain( inputwireclk,//時(shí)鐘信號(hào) inputwirepowerButton,//電源開關(guān) inputwireresetButton,//重置開關(guān) inputwireopenButton,//強(qiáng)制開門 inputwirecloseButton,//強(qiáng)制關(guān)門 inputwireinfloorButton1,//一樓內(nèi)部開關(guān) inputwireinfloorButton3,//三樓內(nèi)部開關(guān) inputwireinfloorButton6,//六樓內(nèi)部開關(guān) inputwireinfloorButton8,//八樓內(nèi)部開關(guān) inputwireoutfloorButton1,//一樓外部開關(guān) inputwireoutfloorButton3,//三樓外部開關(guān) inputwireoutfloorButton6,//六樓外部開關(guān) inputwireoutfloorButton8,//八樓外部開關(guān)整理為word格式整理為word格式整理為word格式 outputreg[7:0]eightDecode,//七段顯示譯碼器 outputwireflashLight,//電梯運(yùn)行閃爍燈 outputwiredoorLight,//開門顯示燈 outputregupLight,//上升指示燈 outputregdownLight,//下降指示燈 outputwirefloorLight1,//一樓指示燈 outputwirefloorLight3,//三樓指示燈 outputwirefloorLight6,//六樓指示燈 outputwirefloorLight8,//八樓指示燈 outputregsevenF, outputregsevenJ, outputregsevenM, outputregsevenK); reg[3:0]currentFloor;//電梯當(dāng)前樓層 reg[3:0]targetFloor;//目標(biāo)樓層,1代表當(dāng)前樓層有請求 reg[1:0]liftState;//電梯運(yùn)行狀態(tài)0.關(guān)門等待狀態(tài)1.上升狀態(tài)2.下降狀態(tài)3.開門狀態(tài) regmark;//用于周期滯后 wiredoorState;//電梯門開關(guān)狀態(tài),0為關(guān)門,1為開門 regrunState;//電梯最近運(yùn)動(dòng)狀態(tài),1為上升,0為下降 reg[2:0]doorTime; regclkFloor; //電梯上下樓層速率 regclkLight;//電梯運(yùn)行時(shí)指示燈閃爍頻率 regscan;整理為word格式整理為word格式整理為word格式 reg[3:0]runTime;//電梯運(yùn)行時(shí)間顯示 integerq,qLight,qScan,qRun; reg[28:0]cTime;//電梯關(guān)門計(jì)時(shí)器initial//初始化 begin q<=0; qLight<=0; qScan<=0; qRun<=0; cTime<=0; runState<=1;//電梯初始化上升 liftState<=0;//電梯初始化狀態(tài) currentFloor<=1;//當(dāng)前樓層初始化為1樓 targetFloor[0]<=0;//目標(biāo)樓層均初始化為無請求 targetFloor[1]<=0; targetFloor[2]<=0; targetFloor[3]<=0; clkFloor<=0; clkLight<=0; runTime<=0;scan<=0;sevenF<=0; sevenJ<=1; sevenM<=1; sevenK<=1; doorTime<=0; end整理為word格式整理為word格式整理為word格式//綁定將目標(biāo)樓層綁定至相應(yīng)LED燈上 assignfloorLight1=targetFloor[0]; assignfloorLight3=targetFloor[1]; assignfloorLight6=targetFloor[2]; assignfloorLight8=targetFloor[3]; assigndoorLight=(cTime<=286870911||cTime==0)?0:1; assigndoorState=(cTime<=286870911||cTime==0)?0:1; assignflashLight=clkLight;///////////////////////////////////////////////////////////////////////////////module--StatueJudgealways@(posedgeclk) begin if(powerButton==1&&openButton==1&&liftState==0) begin liftState<=3; mark<=0; end elseif(powerButton==1&&(liftState==0||liftState==1||liftState==2)) begin case(currentFloor) 1:整理為word格式整理為word格式整理為word格式 begin if(targetFloor[0]) begin liftState<=3; mark<=0; end elseif(targetFloor[1]|targetFloor[2]|targetFloor[3]) begin liftState<=1; end end 3: begin if(targetFloor[1]) begin liftState<=3; mark<=0; end elseif(targetFloor[0]|targetFloor[2]|targetFloor[3]) begin if(runState==0&targetFloor[0]) begin liftState<=2; end整理為word格式整理為word格式整理為word格式 elseif(runState==1&(targetFloor[2]|targetFloor[3])) begin liftState<=1; end elseif(targetFloor[0]) begin liftState<=2; end elseif(targetFloor[2]|targetFloor[3]) begin liftState<=1; end end end 6: begin if(targetFloor[2]) begin liftState<=3; mark<=0; end elseif(targetFloor[0]|targetFloor[1]|targetFloor[3]) begin整理為word格式整理為word格式整理為word格式 if(runState==1&targetFloor[3]) begin liftState<=1; end elseif(runState==0&(targetFloor[0]|targetFloor[1])) begin liftState<=2; end elseif(targetFloor[3]) begin liftState<=1; end elseif(targetFloor[0]|targetFloor[1]) begin liftState<=2; end end end 8:begin if(targetFloor[3]) begin liftState<=3; mark<=0; end整理為word格式整理為word格式整理為word格式 elseif(targetFloor[0]|targetFloor[1]|targetFloor[2]) begin liftState<=2; end end default: begin if(runState==0) liftState<=2; else liftState<=1; end endcase end else begin if(mark==1) begin if(doorState==0) begin liftState<=0; end end else begin mark<=1;整理為word格式整理為word格式整理為word格式 end end end////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////module--ControlSystemalways@(posedgeclk) beginif(powerButton==1)//電梯運(yùn)行開關(guān)打開 begin//計(jì)時(shí)器 if(liftState==1||liftState==2) begin if(q==225000000) begin clkFloor<=~clkFloor; q<=0; end else整理為word格式整理為word格式整理為word格式 begin q<=q+1; end if(qLight==25000000) begin clkLight<=~clkLight; qLight<=0; end else begin qLight<=qLight+1; end if(runTime==0) begin runTime<=9; end if(qRun==50000000) begin runTime<=runTime-1; qRun<=0; end else begin qRun<=qRun+1; end整理為word格式整理為word格式整理為word格式 end else begin q<=0; clkLight<=0; end//判斷用戶請求 if(resetButton==1) begin targetFloor[0]<=1; targetFloor[1]<=0; targetFloor[2]<=0; targetFloor[3]<=0; end else begin if(infloorButton1||outfloorButton1) targetFloor[0]<=1; if(infloorButton3||outfloorButton3) targetFloor[1]<=1; if(infloorButton6||outfloorButton6) targetFloor[2]<=1; if(infloorButton8||outfloorButton8) targetFloor[3]<=1; end//判斷是否到達(dá)目標(biāo)樓層整理為word格式整理為word格式整理為word格式 if(currentFloor==1&targetFloor[0]) targetFloor[0]<=0; if(currentFloor==3&targetFloor[1]) targetFloor[1]<=0; if(currentFloor==6&targetFloor[2]) targetFloor[2]<=0; if(currentFloor==8&targetFloor[3]) targetFloor[3]<=0; endelseif(powerButton==0) begin q<=0; targetFloor[0]<=0; targetFloor[1]<=0; targetFloor[2]<=0; targetFloor[3]<=0; end end//電梯狀態(tài)控制--靜止情況always@(posedgeclk) begin if(powerButton==1) begin if(openButton==1&&(liftState==0||liftState==3)) begin整理為word格式整理為word格式整理為word格式 cTime<=-1;//強(qiáng)制賦值,使cTime最高位置為1 doorTime<=5; end elseif(liftState==3) begin if(closeButton==1) begin cTime<=0; doorTime<=0; end else begin cTime<=cTime-1; if(cTime>=486870911) doorTime<=5; elseif(cTime>=436870911) doorTime<=4; elseif(cTime>=386870911) doorTime<=3; elseif(cTime>=336870911) doorTime<=2; elseif(cTime>=286870911) doorTime<=1; else doorTime<=0; end整理為word格式整理為word格式整理為word格式 else begin cTime<=0; end end else begin cTime<=0; end end//電梯狀態(tài)控制--電梯升降always@(negedgeclkFloor begin if(liftState==1) begin currentFloor<=currentFloor+1; end elseif(liftState==2) begin currentFloor<=currentFloor-1; end end/////////////////////////////////////////////////////////////////////////////整理為word格式整理為word格式整理為word格式///////////////////////////////////////////////////////////////////////////////module--StatueDisplay//電梯升降指示燈always@(posedgeclk) begin if(liftState==1) begin upLight<=1; downLight<=0; runState<=1; endelseif(liftState==2) begin upLight<=0; downLight<=1; runState<=0; end else begin upLight<=0; downLight<=0; end end整理為word格式整理為word格式整理為word格式//數(shù)碼管顯示always@(posedgeclk) begin if(qScan==100000) begin scan<=~scan; qScan<=0; end else begin qScan<=qScan+1; end endalways@(posedgescan) begin sevenF=~sevenF; sevenJ=~sevenJ; sevenM=1; sevenK=1; if(sevenF==0) begin case(currentFloor) 1:eightDecode=8'b10011111; 2:eightDecode=8'b00100101; 3:eightDecode=8'b00001101; 4:eightDecode=8'b10011001;整理為wo

溫馨提示

  • 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫網(wǎng)僅提供信息存儲(chǔ)空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負(fù)責(zé)。
  • 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。

最新文檔

評論

0/150

提交評論