




版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進(jìn)行舉報(bào)或認(rèn)領(lǐng)
文檔簡介
EDA技術(shù)課程設(shè)計(jì)-電子密碼鎖主要內(nèi)容:設(shè)計(jì)一個(gè)密碼鎖的控制電路,第一個(gè)按鈕觸動(dòng)后的5秒內(nèi)若未將鎖打開,則電路自動(dòng)復(fù)位并進(jìn)入自鎖狀態(tài),當(dāng)輸入正確代碼時(shí),輸出開鎖信號以推動(dòng)執(zhí)行機(jī)構(gòu)工作。設(shè)計(jì)內(nèi)容、技術(shù)條件和要求1、設(shè)計(jì)一個(gè)密碼鎖的控制電路,當(dāng)輸入正確代碼時(shí),輸出開鎖信號以推動(dòng)執(zhí)行機(jī)構(gòu)工作,用紅燈亮、綠燈熄滅表示關(guān)鎖,用綠燈亮、紅燈熄滅表示開鎖;2、在鎖的控制電路中儲存一個(gè)可以修改的4位二進(jìn)制代碼,當(dāng)開鎖按鈕開關(guān)的輸入代碼等于儲存代碼時(shí),開鎖;從第一個(gè)按鈕觸動(dòng)后的5秒內(nèi)若未將鎖打開,則電路自動(dòng)復(fù)位并進(jìn)入自鎖狀態(tài),使之無法再打開,并由揚(yáng)聲器發(fā)出持續(xù)20秒的報(bào)警信號,并輸出一個(gè)信號推動(dòng)LED不斷閃爍主要參考文獻(xiàn)[1]潘松著.EDA技術(shù)實(shí)用教程(第二版).北京:科學(xué)出版社,2005.[2]康華光主編.電子技術(shù)基礎(chǔ)模擬部分.北京:高教出版社,2006.[3]閻石主編.數(shù)字電子技術(shù)基礎(chǔ).北京:高教出版社,2003.[4]譚會生、瞿遂春,《EDA技術(shù)綜合應(yīng)用實(shí)例與分析》,西安電子科技大學(xué)出版社,2004[5]高有堂,《EDA技術(shù)及應(yīng)用實(shí)踐》,清華大學(xué)出版社,2006設(shè)計(jì)思路根據(jù)設(shè)計(jì)要求,該電子密碼鎖主要有設(shè)置密碼,5秒時(shí)間輸入密碼(即第一個(gè)按鍵按下后的5秒內(nèi)輸入密碼),報(bào)警(即超出5秒后若未將鎖開啟則揚(yáng)聲器發(fā)出20秒的報(bào)警信號,同時(shí)一個(gè)LED不斷閃爍),開鎖時(shí)輸出聲光信號(即揚(yáng)聲器發(fā)出5秒的信號,同時(shí)對應(yīng)的指示燈發(fā)生變換)的功能。因此,我的設(shè)計(jì)思路是輸入datain(3downto0)為四位密碼按鍵,其對應(yīng)的二進(jìn)制序列為密碼(當(dāng)然也可以設(shè)置6位或8位,其中實(shí)際有效為4位,其余為虛設(shè)),enter1為設(shè)置密碼確認(rèn)鍵(上升沿有效),enter2為輸入密碼確認(rèn)鍵(上升沿有效),set為模式選擇鍵(0為設(shè)置密碼,1為輸入密碼),系統(tǒng)時(shí)鐘clk_1k設(shè)置為1024Hz;輸出有l(wèi)ed_r(紅燈)、led_g(綠燈)、led_alert(報(bào)警指示燈)、speaker(揚(yáng)聲器)。首先在set為0的情況下,將4位按鍵設(shè)置成想要的密碼(例如1001),然后按一下enter1將密碼鎖存起來,這時(shí)對應(yīng)的指示燈由紅燈滅、綠燈滅變成紅燈亮、綠燈滅(表示關(guān)鎖),接著將set設(shè)為1,此時(shí)將4位按鍵設(shè)置成輸入的密碼(初始值都還原為0),按enter2進(jìn)行確認(rèn),第一個(gè)按鍵按下后會產(chǎn)生一個(gè)5秒計(jì)時(shí)信號,若5秒內(nèi)將鎖開啟,則對應(yīng)的指示燈由紅燈亮、綠燈滅變成紅燈滅、綠燈亮(表示開鎖),同時(shí)揚(yáng)聲器發(fā)出短暫的提示信號,若5秒后沒有將鎖開啟,則報(bào)警,揚(yáng)聲器發(fā)出20秒的信號,報(bào)警指示燈閃爍20秒。設(shè)計(jì)步驟分頻由于要產(chǎn)生5秒、20秒的計(jì)時(shí)信號,故對系統(tǒng)時(shí)鐘clk_1k進(jìn)行分頻來得到1Hz的時(shí)鐘clk。其模塊及部分程序如下:process(clk_1k)variablecount:std_logic_vector(9downto0);beginif(clk_1k'eventandclk_1k='1')then count:=count+1; endif; clk<=count(9);endprocess;仿真波形如下:設(shè)置密碼本模塊主要是將設(shè)置的密碼鎖存到中間變量ram中去,同時(shí)控制燈的變化,由于這里的燈并不能作為最終的輸出,所以這里先用led_r_temp1、led_r_temp2代替。其模塊及部分程序如下:process(enter1,set)begin if(enter1'eventandenter1='1')then if(set='0')then ram<=datain; led_r_temp1<='1';led_g_temp1<='0'; elseled_r_temp1<='0';led_g_temp1<='0'; endif; endif;endprocess;仿真波形如下:輸入密碼時(shí)第一個(gè)按鍵判斷信號本模塊主要在密碼輸入下,當(dāng)?shù)谝粋€(gè)按鍵按下時(shí)產(chǎn)生一個(gè)judge信號(高電平有效),其模塊及部分程序如下:process(set,clk_1k,datain)beginif(clk_1k'eventandclk_1k='1')thenif(set='0')thenjudge<='0';elsif(set='1')thenif((datain(0)ordatain(1)ordatain(2)ordatain(3))='0')then judge<='0'; elsif((datain(0)ordatain(1)ordatain(2)ordatain(3))='1')then judge<='1'; elsejudge<='0'; endif;endif;endif;endprocess;仿真波形如下:從仿真波形上看,當(dāng)按鍵按下后judge信號由0變?yōu)?,但是當(dāng)按鍵重新彈回0時(shí),judge信號又回到0,所以需對judge高電平信號進(jìn)行鎖存:signaltemp:std_logic:='0';beginprocess(judge)beginif(judge'eventandjudge='1')then temp<='1';endif;endprocess;judge_load<=temp;5秒計(jì)時(shí)信號該模塊是產(chǎn)生一個(gè)5秒計(jì)時(shí)的信號state,5秒期間為‘1’,當(dāng)5秒時(shí)間過去后state變?yōu)椤?’,并作為報(bào)警信號。其模塊及部分程序如下:signalcount_5:std_logic_vector(2downto0);signalstate1:std_logic;beginprocess(clk)beginif(clk'eventandclk='1')then if(judge_load='1')then ——第一個(gè)按鍵按下 if(count_5="101")then count_5<="101"; elsecount_5<=count_5+1; endif; endif;endif;endprocess;process(count_5)begincasecount_5is when"000"=>state1<='1'; when"001"=>state1<='1'; when"010"=>state1<='1'; when"011"=>state1<='1'; when"100"=>state1<='1'; whenothers=>state1<='0';endcase;endprocess;state<=state1andset;——確保在set置為‘1’而第一個(gè)按鍵沒有按下時(shí),state仿真波形如下:根據(jù)仿真波形可以看出,set為‘0’時(shí)設(shè)置密碼,當(dāng)set為‘1’時(shí),在judge_load(按鍵識別信號)為‘0’的情況下,state為‘1’,保證下面將要提及的報(bào)警模塊不會工作,而只有當(dāng)judge_load為‘1’,且5秒過后state變?yōu)椤?’時(shí)才有可能發(fā)出報(bào)警信號(密碼輸錯(cuò)的情況下)。開鎖信號的產(chǎn)生本模塊主要是對輸入的密碼進(jìn)行判斷,一旦密碼輸入正確,產(chǎn)生一個(gè)開鎖信號unlock(高電平有效)。其模塊與部分程序如下:process(enter2)beginif(enter2'eventandenter2='1')then ——輸入密碼確認(rèn) if(set='1')then if(state='1')then ——5秒期間 if(datain=ram)then unlock<='1'; ——開鎖信號 elseunlock<='0'; endif; endif; endif;endif;endprocess;輸入正確密碼仿真波形:輸入錯(cuò)誤密碼仿真波形:報(bào)警模塊本模塊主要是在5秒限制時(shí)間結(jié)束時(shí),如果還沒有開鎖,就產(chǎn)生報(bào)警信號。即長達(dá)20秒的聲光信號。這里的報(bào)警信號指示燈用led_r_temp3表示,揚(yáng)聲器用speaker_temp2表示。其模塊及部分程序如下:signalcount_20:std_logic_vector(4downto0);signaltemp:std_logic;beginprocess(clk)beginif(clk'eventandclk='1')thenif(set='0')thentemp<='0';elsif(set='1')then if(state='0')then if(count_20="10100")then count_20<="10100";temp<='0'; elsecount_20<=count_20+1;temp<='1'; speaker_temp2<=clk_1k; endif; endif;endif;endif;endprocess;led_r_temp3<=tempandclkand(notunlock);speaker_temp2<=tempandclk_1kand(notunlock);仿真波形如下:可見當(dāng)state由‘1’變?yōu)椤?’且沒有unlock信號時(shí),輸出20秒的聲光信號以示報(bào)警。開鎖信號控制指示燈變化模塊本模塊是實(shí)現(xiàn)當(dāng)開鎖信號產(chǎn)生時(shí),相應(yīng)的指示燈由紅亮綠滅變成紅滅綠亮。這里同樣先用led_r_temp2、led_g_temp2代表紅燈和綠燈。其模塊及部分程序如下:process(clk_1k,state)beginif(clk_1k'eventandclk_1k='1')thenif(state='1')then if(unlock='1')then led_r_temp2<='0';led_g_temp2<='1'; elseled_r_temp2<='1';led_g_temp2<='0'; endif;endif;endif;endprocess;仿真波形如下:開鎖信號產(chǎn)生2秒提示音模塊當(dāng)開鎖信號產(chǎn)生時(shí),揚(yáng)聲器發(fā)出兩秒的提示音。這里用speaker_temp2代替。其模塊及部分程序如下:signalcount_2:std_logic_vector(1downto0);signaltemp:std_logic;beginprocess(clk) beginif(clk'eventandclk='1')then ——1秒Hz if(unlock='1')then if(count_2="10")then count_2<="10";temp<='0'; elsecount_2<=count_2+1;temp<='1'; endif; endif;endif;endprocess;speaker_temp1<=clk_1kandtemp;仿真波形如下:指示燈綜合輸出模塊本模塊主要是將led_r_temp1、led_g_temp1、led_r_temp2、led_g_temp2經(jīng)過條件判斷選擇輸出,設(shè)置密碼(set=‘0’)時(shí)輸出led_r_temp1、led_g_temp1,輸入密碼(set=‘1’)時(shí)輸出led_r_temp2、led_g_temp2。其模塊及部分程序如下:if(set='0')then led_r<=led_r_temp1; led_g<=led_g_temp1;else led_r<=led_r_temp2; led_g<=led_g_temp2;仿真波形如下:揚(yáng)聲器綜合輸出模塊本模塊主要是將報(bào)警音speaker_temp1和開鎖提示音speaker_temp2經(jīng)過條件選擇判斷輸出,set=‘0’時(shí),輸出為‘0’;當(dāng)set=‘1’且unlock=‘0’時(shí)輸出speaker_temp1,當(dāng)unlock=1時(shí),輸出speaker_temp2。其模塊及部分程序如下:if(set='0')thenspeaker<='0';elsif(unlock='1')thenspeaker<=speaker_temp1;elsespeaker<=speaker_temp2;endif;仿真波形如下:頂層模塊及仿真頂層模塊詳見報(bào)告后面所附的頂層模塊圖,仿真波形如下:輸入錯(cuò)誤密碼:輸入正確密碼:結(jié)論及心得體會通過實(shí)驗(yàn)箱下載驗(yàn)證,實(shí)現(xiàn)了預(yù)期想要的結(jié)果,但也有不足之處,由于沒有考慮復(fù)位鍵的設(shè)置,所以每次驗(yàn)證還需重新下載,需要進(jìn)一步加以改進(jìn)。通過本次課程設(shè)計(jì)我收獲頗多,剛開始拿到題目后,沒有一個(gè)明確的方案,查了很多資料,大部分都用到了矩陣鍵盤,并且比較復(fù)雜,后來根據(jù)實(shí)驗(yàn)箱設(shè)計(jì)了該方案。這就要求我們要根據(jù)現(xiàn)實(shí)的條件去設(shè)計(jì)適合自己硬件的程序。在這次課程設(shè)計(jì)中,最頭疼的問題就是各個(gè)模塊仿真正確后,最后的頂層文件卻并沒有達(dá)到預(yù)期的效果,很是令人灰心,并無從查找。后來我試著把每一個(gè)模塊逐漸添加到頂層中,每添加一個(gè)就仿真一下,并留意中間信號量的變化,根據(jù)波形去調(diào)試相應(yīng)的模塊,最終得到了想要的波形。當(dāng)然期間遇到了很多的困難,通過向老師同學(xué)請教,并積極思考,最終這些難題都得到了解決,這也讓我懂得了團(tuán)隊(duì)的重要性。參考文獻(xiàn)[1]潘松著.EDA技術(shù)實(shí)用教程(第二版).北京:科學(xué)出版社,2005.[2]康華光主編.電子技術(shù)基礎(chǔ)模擬部分.北京:高教出版社,2006.[3]閻石主編.數(shù)字電子技術(shù)基礎(chǔ).北京:高教出版社,2003.[4]譚會生、瞿遂春,《EDA技術(shù)綜合應(yīng)用實(shí)例與分析》,西安電子科技大學(xué)出版社,2004[5]高有堂,《EDA技術(shù)及應(yīng)用實(shí)踐》,清華大學(xué)出版社,2006[6]候伯亨著.VHDL硬件描述語言與數(shù)字邏輯電路設(shè)計(jì)[M].西安:西安電子科技大學(xué)出版社,2009.[7]張昌凡著.可編程邏輯器件及VHDL設(shè)計(jì)技術(shù)[M].廣州:華南理工大學(xué)出版社,2001.[8]曹昕燕、周鳳臣等,《EDA技術(shù)實(shí)驗(yàn)與課程設(shè)計(jì)》,清華大學(xué)出版社,2006源程序:【1】libraryieee;useieee.std_logic_1164.all;useieee.std_logic_unsigned.all;entityfenpinisport(clk_1k:instd_logic;clk:outstd_logic);end;architecturertloffenpinisbeginprocess(clk_1k)variablecount:std_logic_vector(9downto0);beginif(clk_1k'eventandclk_1k='1')then count:=count+1; endif; clk<=count(9);endprocess;endrtl;【2】libraryieee;useieee.std_logic_1164.all;useieee.std_logic_unsigned.all;entitycode_setisport(set,enter1:instd_logic; datain:instd_logic_vector(3downto0); ram:outstd_logic_vector(3downto0); led_r_temp1,led_g_temp1:outstd_logic);end;architecturertlofcode_setisbeginprocess(enter1,set)begin if(enter1'eventandenter1='1')then if(set='0')then ram<=datain; led_r_temp1<='1';led_g_temp1<='0'; elseled_r_temp1<='0';led_g_temp1<='0'; endif; endif;endprocess;end;【3】libraryieee;useieee.std_logic_1164.all;useieee.std_logic_unsigned.all;entityjudgeisport(clk_1k,set:instd_logic; datain:instd_logic_vector(3downto0); judge:outstd_logic);end;architecturertlofjudgeisbeginprocess(set,clk_1k,datain)beginif(clk_1k'eventandclk_1k='1')thenif(set='0')thenjudge<='0'; elsif(set='1')then if((datain(0)ordatain(1)ordatain(2)ordatain(3))='0')then judge<='0'; elsif((datain(0)ordatain(1)ordatain(2)ordatain(3))='1')then judge<='1'; elsejudge<='0'; endif; endif;endif;endprocess;end;【4】libraryieee;useieee.std_logic_1164.all;useieee.std_logic_unsigned.all;entityjudge_loadisport(judge:instd_logic; judge_load:outstd_logic);end;architecturertlofjudge_loadissignaltemp:std_logic:='0';beginprocess(judge)beginif(judge'eventandjudge='1')then temp<='1';endif;endprocess;judge_load<=temp;end;【5】libraryieee;useieee.std_logic_1164.all;useieee.std_logic_unsigned.all;entitytime_5isport(clk,judge_load,set:instd_logic; state:outstd_logic);end;architecturertloftime_5issignalcount_5:std_logic_vector(2downto0);signalstate1:std_logic;beginprocess(clk)beginif(clk'eventandclk='1')then if(judge_load='1')then if(count_5="101")then count_5<="101"; elsecount_5<=count_5+1; endif; endif;endif;endprocess;process(count_5)begincasecount_5is when"000"=>state1<='1'; when"001"=>state1<='1'; when"010"=>state1<='1'; when"011"=>state1<='1'; when"100"=>state1<='1'; whenothers=>state1<='0';endcase;endprocess;state<=state1andset;end;【6】libraryieee;useieee.std_logic_1164.all;useieee.std_logic_unsigned.all;entityunlockisport(set,enter2,state:instd_logic; datain,ram:instd_logic_vector(3downto0); unlock:outstd_logic);end;architecturertlofunlockisbeginprocess(enter2)beginif(enter2'eventandenter2='1')then if(set='1')then if(state='1')then if(datain=ram)then unlock<='1'; elseunlock<='0'; endif; endif; endif;endif;endprocess;endrtl;【7】libraryieee;useieee.std_logic_1164.all;useieee.std_logic_unsigned.all;entityunlock_ledisport(state,unlock,clk_1k:instd_logic; led_r_temp2,led_g_temp2:outstd_logic);end;architecturertlofunlock_ledisbeginprocess(clk_1k,state)beginif(clk_1k'eventandclk_1k='1')thenif(state='1')then if(unlock='1')then led_r_temp2<='0';led_g_temp2<='1'; elseled_r_temp2<='1';led_g_temp2<='0'; endif;endif;endif;endprocess;end;【8】libraryieee;useieee.std_logic_1164.all;useieee.std_logic_unsigned.all;entityunlock_soundisport(clk,unlock,clk_1k:instd_logic; speaker_temp1:outstd_logic);end;architecturertlofunlock_soundissignalcount_2:std_logic_vector(1downto0);signaltemp:std_logic;beginprocess(clk)beginif(clk'eventandclk='1')then if(unlock='1')then if(count_2="10")then count_2<="10";temp<='0'; elsecount_2<=count_2+1;temp<='1'; endif; endif;endif;endprocess;speaker_temp1<=clk_1kandtemp;end;【9】libraryieee;useieee.std_logic_1164.all;useieee.std_logic_unsigned.all;entityalertisport(state,clk,clk_1k,set,unlock:instd_logic; led_r_temp3,speaker_temp2:outstd_logic);end;architecturertlofalertissignalcount_20:std_logic_vector(4downto0);signaltemp:std_logic;beginprocess(clk)beginif(clk'eventandclk='1')thenif(set='0')thentemp<='0';elsif(set='1')then if(state='0')then if(count_20="10100")then count_20<="10100";temp<='0'; elsecount_20<=count_20+1;temp<
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(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)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 育兒用工合同范本
- Gepirone-hydrochloride-生命科學(xué)試劑-MCE
- CZY43-生命科學(xué)試劑-MCE
- 中央2025年全國婦聯(lián)所屬在京事業(yè)單位招聘93人筆試歷年參考題庫附帶答案詳解
- 東莞2025年廣東東莞市應(yīng)急管理局自主招聘特別聘員筆試歷年參考題庫附帶答案詳解
- 道具采購合同范本
- 三亞2025年海南三亞口腔醫(yī)學(xué)中心校園招聘67人筆試歷年參考題庫附帶答案詳解
- 汽車金融中的客戶細(xì)分與個(gè)性化服務(wù)策略
- 2025長虹美菱股份有限公司招聘操作工等崗位310人(四川)筆試參考題庫附帶答案詳解
- 科技產(chǎn)品的生命周期與市場分析
- DB11T 1035-2013 城市軌道交通能源消耗評價(jià)方法
- 2024新能源光伏電站運(yùn)行規(guī)程和檢修規(guī)程
- 供應(yīng)室課件大全
- 有機(jī)化學(xué)完整版本
- 銀行存管三方協(xié)議書
- 2024義務(wù)教育道德與法治課程標(biāo)準(zhǔn)(2022版)
- 2024年新人教版化學(xué)九年級上冊全冊課件(新版教材)
- 智能體脂秤市場洞察報(bào)告
- 教科版 二年級科學(xué)上冊第一單元第6課《不同的季節(jié)》同步練習(xí)(附答案解析)
- 山東省東營市2024年中考英語真題【附真題答案】
- 2024義務(wù)教育英語新課標(biāo)課程標(biāo)準(zhǔn)2022年版考試真題附答案
評論
0/150
提交評論