




版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)
文檔簡(jiǎn)介
-.z.概述在當(dāng)今社會(huì)中,人們對(duì)于隱私的保護(hù)和對(duì)物品安全的重視程度與日俱增。因此,使用了現(xiàn)代電子技術(shù)的電子密碼鎖便有了廣泛的應(yīng)用前景。本次所設(shè)計(jì)的電子密碼鎖,能夠?qū)崿F(xiàn)該六位十進(jìn)制并行密碼保護(hù),當(dāng)輸入的密碼與鎖密碼一致時(shí),綠燈亮,開鎖;當(dāng)輸入的密碼與鎖的密碼不一致時(shí),紅燈亮,不能開鎖。密碼鎖的密碼可由用戶自行設(shè)置,并可在液晶顯示屏上顯示所輸入的密碼。為人們的財(cái)產(chǎn)、信息安全提供了可靠地保障。本次設(shè)計(jì)基于VHDL語言,對(duì)并行六位電子密碼鎖進(jìn)行設(shè)計(jì),并對(duì)設(shè)計(jì)過程進(jìn)行了詳細(xì)描述。采用VHDL語言進(jìn)行電子密碼鎖的設(shè)計(jì)可使設(shè)計(jì)工作簡(jiǎn)潔直觀,快速實(shí)現(xiàn)既定功能。電子密碼鎖在對(duì)財(cái)產(chǎn)安全保護(hù)等方面都有著重要作用,應(yīng)用前景非常廣泛。開鎖代碼為六位十進(jìn)制數(shù),當(dāng)輸入代碼的位數(shù)和位值與鎖給定的密碼一致,且按規(guī)定程序開鎖時(shí),方可開鎖,并點(diǎn)亮開鎖指示燈。否則,系統(tǒng)進(jìn)入“錯(cuò)誤”狀態(tài),并發(fā)出報(bào)警信號(hào)。開鎖程序由設(shè)計(jì)者確定,并要求鎖給定的密碼是可調(diào)的,且預(yù)置方便,性好。并行數(shù)字鎖的報(bào)警方式是點(diǎn)亮指示燈,并使喇叭鳴叫來報(bào)警,直到按下復(fù)位開關(guān),報(bào)警才停止。此時(shí),數(shù)字鎖又自動(dòng)進(jìn)入等待下一次開鎖的狀態(tài)。一、設(shè)計(jì)主要容密碼鎖串行輸入幾位十進(jìn)制數(shù)字口令輸入口令全部正確即開鎖并有綠燈顯示口令輸入最大次數(shù)3次,要求在完全輸入六位之后進(jìn)行判斷口令正確與否;輸入3次之后還不能開鎖,進(jìn)入死鎖狀態(tài)并報(bào)警有相應(yīng)的顯示功能開鎖后能再次上鎖二、系統(tǒng)設(shè)計(jì)方案作為通用電子密碼鎖,主要由三個(gè)部分組成:數(shù)字密碼輸入電路、密碼鎖控制電路和密碼鎖顯示電路。(1)密碼鎖輸入電路包括時(shí)序產(chǎn)生電路、鍵盤掃描電路、鍵盤譯碼電路等幾個(gè)小的功能電路。(2)密碼鎖控制電路包括按鍵數(shù)據(jù)的緩沖存儲(chǔ)電路,密碼的清除、存儲(chǔ)、激活電鎖電路(寄存器清除信號(hào)發(fā)生電路),密碼核對(duì)(數(shù)值比較電路),解鎖電路(開/關(guān)門鎖電路)等幾個(gè)小的功能電路。(3)密碼顯示電路主要是在液晶顯示屏顯示輸入的數(shù)值。2.1密碼鎖輸入電路的設(shè)計(jì)是電子密碼鎖的輸入電路框圖,由鍵盤掃描電路、彈跳消除電路、鍵盤譯碼電路、按鍵數(shù)據(jù)緩存器,加上外接的一個(gè)4×4矩陣式鍵盤組成。798798按鍵數(shù)據(jù)鍵盤輸入465按鍵數(shù)據(jù)鍵盤輸入465工作時(shí)鐘脈沖信號(hào)鍵盤掃描信號(hào)彈跳消除電路鍵盤譯碼電路按鍵數(shù)據(jù)緩存器0321工作時(shí)鐘脈沖信號(hào)鍵盤掃描信號(hào)彈跳消除電路鍵盤譯碼電路按鍵數(shù)據(jù)緩存器0321鍵盤掃描電路鍵盤掃描電路圖1-1密碼鎖的輸入電路框圖1.矩陣式鍵盤的工作原理KC1KC2矩陣式鍵盤是一種常見的輸入裝置,在日常的生活中,矩陣式鍵盤在計(jì)算機(jī)、、手機(jī)、微波爐等各式電子產(chǎn)品上已經(jīng)被廣泛應(yīng)用。圖1-2是一個(gè)3×4矩陣式鍵盤的面板配置圖,其中數(shù)字0~9作為密碼數(shù)字輸入按鍵。KC1KC2KC0KC0KR0(11)KR1(10)KR2(01)KR3(00)01111011110111103021654798KR0(11)KR1(10)KR2(01)KR3(00)01111011110111103021654798圖1-24×4矩陣式鍵盤的面板配置2.2密碼鎖輸入電路各主要功能模塊的設(shè)計(jì)1)時(shí)序產(chǎn)生電路本時(shí)序產(chǎn)生電路中使用了三種不同頻率的工作脈沖波形:系統(tǒng)時(shí)鐘脈沖(它是系統(tǒng)部所有時(shí)鐘脈沖的源頭,且其頻率最高)、彈跳消除取樣信號(hào)、鍵盤掃描信號(hào)。2)鍵盤掃描電路掃描電路的作用是用來提供鍵盤掃描信號(hào)的,掃描信號(hào)變化的順序依次為1110-1101-1011-0111-1110......依序地周而復(fù)始。3)彈跳消除電路由于本設(shè)計(jì)中采用的矩陣式鍵盤是機(jī)械開關(guān)結(jié)構(gòu),因此在開關(guān)切換的瞬間會(huì)在接觸點(diǎn)出現(xiàn)信號(hào)來回彈跳的現(xiàn)象,對(duì)于電子密碼鎖這種靈敏度較高的電路這種彈跳將很可能會(huì)造成誤動(dòng)作輸入,從而影響到密碼鎖操作的正確性。從圖1-3中可以觀察出彈跳現(xiàn)象產(chǎn)生的原因,雖然只是按下按鍵一次然后放掉,然而實(shí)際產(chǎn)生的按鍵信號(hào)卻不止跳動(dòng)一次,經(jīng)過取樣信號(hào)的檢查后,將會(huì)造成誤判斷,以為鍵盤按了兩次。如果調(diào)整抽樣頻率(如圖4.5所示),可以發(fā)現(xiàn)彈跳現(xiàn)象獲得了改善。圖1-3彈跳現(xiàn)象產(chǎn)生錯(cuò)誤的抽樣結(jié)果圖1-4調(diào)整抽樣頻率后得到的抽樣結(jié)果4)鍵盤譯碼電路上述鍵盤中的按鍵可分為數(shù)字按鍵和文字按鍵,每一個(gè)按鍵可能負(fù)責(zé)不同的功能,例如清除數(shù)碼、退位、激活電鎖、開鎖等。5)按鍵存儲(chǔ)電路因?yàn)槊看螔呙钑?huì)產(chǎn)生新的按鍵數(shù)據(jù),可能會(huì)覆蓋前面的數(shù)據(jù),所以需要一個(gè)按鍵存儲(chǔ)電路,將整個(gè)鍵盤掃描完畢后的結(jié)果記錄下來。按鍵存儲(chǔ)電路可以使用移位寄存器構(gòu)成。圖1-5輸入電路仿真波形圖2.3密碼鎖控制電路的設(shè)計(jì)密碼鎖的控制電路是整個(gè)電路的控制中心,主要完成對(duì)數(shù)字按鍵輸入和功能按鍵輸入的響應(yīng)控制。1.?dāng)?shù)字按鍵輸入的響應(yīng)控制(1)如果按下數(shù)字鍵,第一個(gè)數(shù)字會(huì)從顯示器的最右端開始顯示,此后每新按一個(gè)數(shù)字時(shí),顯示器上的數(shù)字必須左移一格,以便將新的數(shù)字顯示出來。(2)假如要更改輸入的數(shù)字,可以按倒退按鍵來清除前一個(gè)輸入的數(shù)字,或者按清除鍵清除所有輸入的數(shù)字,再重新輸入六位數(shù)。(3)由于這里設(shè)計(jì)的是一個(gè)六位的電子密碼鎖,所以當(dāng)輸入的數(shù)字鍵超過四個(gè)時(shí),電路不予理會(huì),而且不再顯示第六個(gè)以后的數(shù)字。2.4功能按鍵輸入的響應(yīng)控制(1)清除鍵:清除所有的輸入數(shù)字,即做歸零動(dòng)作。(2)激活電鎖鍵:按下此鍵時(shí)可將密碼鎖的門上鎖。(上鎖前必須預(yù)先設(shè)定一個(gè)六位的數(shù)字密碼。)(3)解除電鎖鍵:按下此鍵會(huì)檢查輸入的密碼是否正確,若密碼正確無誤則開門。輸入文字模式輸入文字模式開始輸入六位數(shù)字,在輸入過程中可能用到刪除鍵上鎖工作模式密碼鎖激活上鎖上鎖工作模式密碼鎖激活上鎖開鎖工作模式檢查輸入的密碼是否有效核對(duì)輸入的密碼是否有效都正確后解除電鎖圖1-5電子密碼鎖的三種模式及關(guān)系2.5密碼鎖顯示電路的設(shè)計(jì)密碼鎖顯示電路的設(shè)計(jì)比較復(fù)雜,這里直接采用12864液晶屏進(jìn)行顯示。2.6密碼鎖的整體組裝設(shè)計(jì)將前面各個(gè)設(shè)計(jì)好的功能模塊進(jìn)行整合,可得到一個(gè)完整的電子密碼鎖系統(tǒng)的整體組裝設(shè)計(jì)原理圖,如圖1-6所示。圖1-6密碼鎖的整體組裝設(shè)計(jì)原理圖系統(tǒng)擴(kuò)展思路(1)本系統(tǒng)基本達(dá)到作為數(shù)字密碼鎖的絕大部分功能,但還有許多不足或需完善的地方。比如說采用4×4的通用機(jī)械鍵盤受到鍵盤數(shù)量的限制,在很大的程度上限制了其功能的擴(kuò)展。設(shè)計(jì)外圍電路:系統(tǒng)用方波信號(hào)源,直流工作電源??梢笤O(shè)計(jì)制作整個(gè)系統(tǒng),包括PCB的制作。實(shí)驗(yàn)收獲課程設(shè)計(jì)是培養(yǎng)學(xué)生綜合運(yùn)用所學(xué)知識(shí),發(fā)現(xiàn),提出,分析和解決實(shí)際問題,鍛煉實(shí)踐能力的重要環(huán)節(jié),是對(duì)學(xué)生實(shí)際工作能力的具體訓(xùn)練和考察過程。隨著科學(xué)技術(shù)發(fā)展的日新月異,F(xiàn)PGA已經(jīng)成為當(dāng)今計(jì)算機(jī)應(yīng)用中空前活躍的領(lǐng)域,在生活中可以說無處不在。因此作為二十一世紀(jì)的大學(xué)來說掌握eda的開發(fā)技術(shù)是十分必要的?;仡櫞舜握n程設(shè)計(jì),我感慨頗多,的確,從理論到實(shí)踐,在很長(zhǎng)的一段時(shí)間里,可以說是苦多于甜,但確實(shí)學(xué)到了很多東西,不僅可以鞏固以前學(xué)到的知識(shí),還學(xué)到許多沒學(xué)過的知識(shí)。通過此次課程設(shè)計(jì),使我了解了理論與實(shí)際結(jié)合的重要性,只有理論知識(shí)是遠(yuǎn)遠(yuǎn)不夠的。在設(shè)計(jì)的過程中,發(fā)現(xiàn)自己以前學(xué)習(xí)的知識(shí)理解不夠深刻,掌握不夠牢固等等。通過這次課設(shè)之后,一定要把以前學(xué)習(xí)的知識(shí)溫故知新。這次的課設(shè)終于完成,通過老師的細(xì)心講解,我解決了很多問題。在這里,感老師的細(xì)心指導(dǎo)。同時(shí)對(duì)于幫助我的同學(xué),也表示衷心感。附錄液晶顯示程序libraryieee;useieee.std_logic_1164.all;useieee.std_logic_unsigned.all;useIEEE.STD_LOGIC_ARITH.ALL;entityclock_lcd_dispisgeneric(divide_to_100k:integer:=500);port(clk:instd_logic;DATAIN:instd_logic_vector(31downto0);din:inINTEGERRANGE15DOWNTO0;rw,rs,e,lcd_rst:outstd_logic;lcd_data:outstd_logic_vector(7downto0));endclock_lcd_disp;architecturetclofclock_lcd_dispissignalmima:std_logic_vector(31downto0):="1000";signalclk_100k:std_logic;signalclkout:std_logic;signaltemp:std_logic_vector(7downto0);typestateis(s0,s1,s2,s3,s4,s5,s6,s7,s8,s9,s10,s11,s12,s13,s14,s15,s16,s17,s18,s19,s20,s21,s22,s23,s24,s25,s26,s27,s28,s29,s30,s31);signalcurrent_s:state;typedata_bufferisarray(0to15)ofstd_logic_vector(7downto0);typedata_buffer1isarray(0to7)ofstd_logic_vector(7downto0);signaltime:std_logic_vector(23downto0);signaldisp_time:data_buffer1:=(*"31",*"32",*"3a",*"33",*"34",*"3a",*"35",*"36");constantdata_buf0:data_buffer:=(*"20",*"20",*"bb",*"aa",--華科武昌分校80*"bf",*"c6",*"ce",*"e4",*"b2",*"fd",*"b7",*"d6",*"d0",*"a3",*"20",*"20");constantdata_buf1:data_buffer:=(*"20",*"20",*"b5",*"e7",--電子密碼鎖90*"d7",*"d3",*"c3",*"dc",*"c2",*"eb",*"cb",*"f8",*"20",*"20",*"20",*"20");constantdata_buf2:data_buffer:=(*"20",*"20",*"c7",*"eb",*"ca",*"e4",*"c8",*"eb",--請(qǐng)輸入密碼:88*"c3",*"dc",*"c2",*"eb",*"3a",*"20",*"20",*"20");constantdata_buf3:data_buffer:=(*"20",*"20",*"d6",*"d8",*"d0",*"c2",*"ca",*"e4",--重新輸入*"c8",*"eb",*"20",*"20",*"20",*"20",*"20",*"20");constantdata_buf4:data_buffer:=(*"20",*"20",*"bd",*"e2",*"cb",*"f8",*"b3",*"c9",--解鎖成功*"b9",*"a6",*"20",*"20",*"20",*"20",*"20",*"20");constantdata_buf5:data_buffer:=(*"20",*"20",--進(jìn)入死鎖狀態(tài)*"bd",*"f8",*"c8",*"eb",*"cb",*"c0",*"cb",*"f8",*"d7",*"b4",*"cc",*"ac",*"20",*"20");constantdata_buf6:data_buffer:=(*"20",*"20",*"bd",*"e2",--*"cb",*"f8",*"b3",*"c9",*"b9",*"a6",*"21",*"20",*"20",*"20",*"20",*"20");begin--U1:divclk1portmap(clk,clk_100k);process(clk)variablet:integerrange0todivide_to_100k;beginif(clk'eventandclk='1')thent:=t+1;if(t=divide_to_100k)thent:=0;endif;if(t<divide_to_100k/2)thenclk_100k<='0';elseclk_100k<='1';endif;endif;endprocess;div_1Hz:process(clk)variablettemp:integerrange0to49999999;beginifclk='1'andclk'eventthenifttemp=49999999thenttemp:=0;elseifttemp<25000000thenclkout<='1';elseclkout<='0';endif;ttemp:=ttemp+1;endif;endif;endprocessdiv_1Hz;disp_time(7)<=DATAIN(3downto0)+*"30";disp_time(6)<=DATAIN(7downto4)+*"30";disp_time(5)<=DATAIN(11downto8)+*"30";disp_time(4)<=DATAIN(15downto12)+*"30";disp_time(3)<=DATAIN(19downto16)+*"30";disp_time(2)<=DATAIN(23downto20)+*"30";disp_time(1)<=DATAIN(27downto24)+*"30";disp_time(0)<=DATAIN(31downto28)+*"30";read_time:process(time)beginendprocess;process(clk_100k)variablet1:integerrange0to10000;variablet_1:integerrange0to1000;variablecode_t:integerrange0to13;variabledata_t:integerrange0to480;beginif(clk_100k'eventandclk_100k='1')thencasecurrent_siswhens0=>rw<='1';rs<='1';e<='1';t1:=t1+1;ift1<500thenlcd_rst<='0';elsift1<1000thenlcd_rst<='1';elsift1=1000thenlcd_rst<='1';t1:=0;current_s<=s1;endif;whens1=>t_1:=t_1+1;ift_1<1*3thene<='1';rs<='0';rw<='0';elsift_1<2*3thenlcd_data<=*"0c";elsift_1<10*3thene<='0';elsift_1=10*3thent_1:=0;current_s<=s2;endif;whens2=>t_1:=t_1+1;ift_1<1*3thene<='1';rs<='0';rw<='0';elsift_1<2*3thenlcd_data<=*"90";elsift_1<10*3thene<='0';elsift_1=10*3thent_1:=0;current_s<=s3;endif;whens3=>ift_1<1*3thene<='1';rs<='1';rw<='0';elsift_1<2*3thenlcd_data<=data_buf1(data_t);elsift_1=2*3thendata_t:=data_t+1;elsift_1<100thene<='0';endif;t_1:=t_1+1;ift_1=100thent_1:=0;ifdata_t=16thencurrent_s<=s4;data_t:=0;endif;endif;whens4=>t_1:=t_1+1;ift_1<1*3thene<='1';rs<='0';rw<='0';elsift_1<2*3thenlcd_data<=*"88";elsift_1<10*3thene<='0';elsift_1=10*3thent_1:=0;current_s<=s5;endif;whens5=>ift_1<1*3thene<='1';rs<='1';rw<='0';elsift_1<2*3thenlcd_data<=data_buf2(data_t);elsift_1=2*3thendata_t:=data_t+1;elsift_1<100thene<='0';endif;t_1:=t_1+1;ift_1=100thent_1:=0;ifdata_t=16thencurrent_s<=s6;data_t:=0;endif;endif;whens6=>t_1:=t_1+1;ift_1<1*3thene<='1';rs<='0';rw<='0';elsift_1<2*3thenlcd_data<=*"80";elsift_1<10*3thene<='0';elsift_1=10*3thent_1:=0;current_s<=s7;endif;whens7=>ift_1<1*3thene<='1';rs<='1';rw<='0';elsift_1<2*3thenlcd_data<=data_buf0(data_t);elsift_1=2*3thendata_t:=data_t+1;elsift_1<100thene<='0';endif;t_1:=t_1+1;ift_1=100thent_1:=0;ifdata_t=16thencurrent_s<=s8;data_t:=0;endif;endif;--動(dòng)態(tài)顯示whens8=>t_1:=t_1+1;ift_1<1*3thene<='1';rs<='0';rw<='0';elsift_1<2*3thenlcd_data<=*"9a";elsift_1<10*3thene<='0';elsift_1=10*3thent_1:=0;current_s<=s9;endif;whens9=>ift_1<1*3thene<='1';rs<='1';rw<='0';elsift_1<2*3thenlcd_data<=disp_time(data_t);elsift_1=2*3thendata_t:=data_t+1;elsift_1<100thene<='0';endif;t_1:=t_1+1;ift_1=100thent_1:=0;ifdata_t=8thencurrent_s<=s10;data_t:=0;endif;endif;--------------------------------------------------------------whens10=>t_1:=t_1+1;ifdin<=10thenift_1<1*3thene<='1';rs<='0';rw<='0';elsift_1<2*3thenlcd_data<=*"88";elsift_1<10*3thene<='0';elsift_1=10*3thent_1:=0;current_s<=s11;endif;elsecurrent_s<=s12;endif;whens11=>ift_1<1*3thene<='1';rs<='1';rw<='0';elsift_1<2*3thenlcd_data<=data_buf4(data_t);elsift_1=2*3thendata_t:=data_t+1;elsift_1<100thene<='0';endif;t_1:=t_1+1;ift_1=100thent_1:=0;ifdata_t=8thencurrent_s<=s0;data_t:=0;endif;endif;whens12=>t_1:=t_1+1;ift_1<1*3thene<='1';rs<='0';rw<='0';elsift_1<2*3thenlcd_data<=*"88";elsift_1<10*3thene<='0';elsift_1=10*3thent_1:=0;current_s<=s13;endif;whens13=>ift_1<1*3thene<='1';rs<='1';rw<='0';elsift_1<2*3thenlcd_data<=data_buf3(data_t);elsift_1=2*3thendata_t:=data_t+1;elsift_1<100thene<='0';endif;t_1:=t_1+1;ift_1=100thent_1:=0;ifdata_t=8thencurrent_s<=s14;data_t:=0;endif;endif;whens14=>t_1:=t_1+1;ift_1<1*3thene<='1';rs<='0';rw<='0';elsift_1<2*3thenlcd_data<=*"98";elsift_1<10*3thene<='0';elsift_1=10*3thent_1:=0;current_s<=s15;endif;whens15=>ift_1<1*3thene<='1';rs<='1';rw<='0';elsift_1<2*3thenlcd_data<=disp_time(data_t);elsift_1=2*3thendata_t:=data_t+1;elsift_1<100thene<='0';endif;t_1:=t_1+1;ift_1=100thent_1:=0;ifdata_t=8thencurrent_s<=s16;data_t:=0;endif;endif;------------------------------------------------------------------------------------------------whens16=>t_1:=t_1+1;ifdin<=10thenift_1<1*3thene<='1';rs<='0';rw<='0';elsift_1<2*3thenlcd_data<=*"88";elsift_1<10*3thene<='0';elsift_1=10*3thent_1:=0;current_s<=s17;endif;elsecurrent_s<=s18;endif;whens17=>ift_1<1*3thene<='1';rs<='1';rw<='0';elsift_1<2*3thenlcd_data<=data_buf4(data_t);elsift_1=2*3thendata_t:=data_t+1;elsift_1<100thene<='0';endif;t_1:=t_1+1;ift_1=100thent_1:=0;ifdata_t=8thencurrent_s<=s0;data_t:=0;endif;endif;whens18=>t_1:=t_1+1;ift_1<1*3thene<='1';rs<='0';rw<='0';elsift_1<2*3thenlcd_data<=*"88";elsift_1<10*3thene<='0';elsift_1=10*3thent_1:=0;current_s<=s19;endif;whens19=>ift_1<1*3thene<='1';rs<='1';rw<='0';elsift_1<2*3thenlcd_data<=data_buf3(data_t);elsift_1=2*3thendata_t:=data_t+1;elsift_1<100thene<='0';endif;t_1:=t_1+1;ift_1=100thent_1:=0;ifdata_t=8thencurrent_s<=s20;data_t:=0;endif;endif;whens20=>t_1:=t_1+1;ift_1<1*3thene<='1';rs<='0';rw<='0';elsift_1<2*3thenlcd_data<=*"98";elsift_1<10*3thene<='0';elsift_1=10*3thent_1:=0;current_s<=s21;endif;whens21=>ift_1<1*3thene<='1';rs<='1';rw<='0';elsift_1<2*3thenlcd_data<=disp_time(data_t);elsift_1=2*3thendata_t:=data_t+1;elsift_1<100thene<='0';endif;t_1:=t_1+1;ift_1=100thent_1:=0;ifdata_t=8thencurrent_s<=s22;data_t:=0;endif;endif;------------------------------------------------------------------------------whens22=>t_1:=t_1+1;ifdin<=10thenift_1<1*3thene<='1';rs<='0';rw<='0';elsift_1<2*3thenlcd_data<=*"88";elsift_1<10*3thene<='0';elsift_1=10*3thent_1:=0;current_s<=s23;endif;elsecurrent_s<=s24;endif;whens23=>ift_1<1*3thene<='1';rs<='1';rw<='0';elsift_1<2*3thenlcd_data<=data_buf4(data_t);elsift_1=2*3thendata_t:=data_t+1;elsift_1<100thene<='0';endif;t_1:=t_1+1;ift_1=100thent_1:=0;ifdata_t=8thencurrent_s<=s0;data_t:=0;endif;endif;whens24=>t_1:=t_1+1;ift_1<1*3thene<='1';rs<='0';rw<='0';elsift_1<2*3thenlcd_data<=*"88";elsift_1<10*3thene<='0';elsift_1=10*3thent_1:=0;current_s<=s25;endif;whens25=>ift_1<1*3thene<='1';rs<='1';rw<='0';elsift_1<2*3thenlcd_data<=data_buf3(data_t);elsift_1=2*3thendata_t:=data_t+1;elsift_1<100thene<='0';endif;t_1:=t_1+1;ift_1=100thent_1:=0;ifdata_t=8thencurrent_s<=s26;data_t:=0;endif;endif;whens26=>t_1:=t_1+1;ift_1<1*3thene<='1';rs<='0';rw<='0';elsift_1<2*3thenlcd_data<=*"98";elsift_1<10*3thene<='0';elsift_1=10*3thent_1:=0;current_s<=s27;endif;whens27=>ift_1<1*3thene<='1';rs<='1';rw<='0';elsift_1<2*3thenlcd_data<=disp_time(data_t);elsift_1=2*3thendata_t:=data_t+1;elsift_1<100thene<='0';endif;t_1:=t_1+1;ift_1=100thent_1:=0;ifdata_t=8thencurrent_s<=s28;data_t:=0;endif;endif;--------------------------------------------------------------------------------------whens28=>t_1:=t_1+1;ifdin<=10thenift_1<1*3thene<='1';rs<='0';rw<='0';elsift_1<2*3thenlcd_data<=*"88";elsift_1<10*3thene<='0';elsift_1=10*3thent_1:=0;current_s<=s29;endif;elsecurrent_s<=s30;endif;whens29=>ift_1<1*3thene<='1';rs<='1';rw<='0';elsift_1<2*3thenlcd_data<=data_buf4(data_t);elsift_1=2*3thendata_t:=data_t+1;elsift_1<100thene<='0';endif;t_1:=t_1+1;ift_1=100thent_1:=0;ifdata_t=8thencurrent_s<=s0;data_t:=0;endif;endif;whens30=>t_1:=t_1+1;ift_1<1*3thene<='1';rs<='0';rw<='0';elsift_1<2*3thenlcd_data<=*"88";elsift_1<10*3thene<='0';elsift_1=10*3thent_1:=0;current_s<=s31;endif;whens31=>ift_1<1*3thene<='1';rs<='1';rw<='0';elsift_1<2*3thenlcd_data<=data_buf4(data_t);elsift_1=2*3thendata_t:=data_t+1;elsift_1<100thene<='0';endif;t_1:=t_1+1;ift_1=100thent_1:=0;ifdata_t=8thencurrent_s<=s30;data_t:=0;endif;endif;whenothers=>current_s<=s0;endcase;endif;endprocess;endtcl;鍵盤控制子程序LIBRARYieee;USEieee.std_logic_1164.all;USEieee.std_logic_unsigned.all;useieee.std_logic_arith.all;ENTITYbian_ma0IS------編碼PORT(en,clk:INstd_logic;kr3,kr2,kr1,kr0:INstd_logic;kc3,kc2,kc1:INstd_logic;SDIN,lock,sec,CR,set,crack:outstd_logic;dout:OUTstd_logic);ENDbian_ma0;ARCHITECTUREoneOFbian_ma0ISsignaldata:std_logic_vector(5downto0);signalker:std_logic_vector(3downto0);signalkec:std_logic_vector(2downto0);BEGINker<=kr3&kr2&kr1&kr0;kec<=kc3&kc2&kc1;PROCESS(ker)BEGINif(ker="1111")thencasekeciswhenothers=>data<=data;endcase;elsif(ker="1110")thencasekeciswhen"100"=>data<="000001";when"010"=>data<="000010";when"001"=>data<="000100";whenothers=>data<=data;endcase;elsif(ker="1101")thencasekeciswhen"001"=>data<="001000";whenothers=>data<=data;endcase;elsif(ker="1011")thencasekeciswhen"001"=>data<="010000";whenothers=>data<=data;endcase;elsif(ker="0111")thencasekeciswhen"001"=>data<="100000";whenothers=>data<=data;endcase;endif;dout<=((notkr3)or(notkr2)or(notkr1)or(notkr0));endPROCESS; SDIN<=data(5);lock<=data(4);sec<=data(3);CR<=data(2);set<=data(1);crack<=data(0);ENDone;LIBRARYieee;USEieee.std_logic_1164.all;USEieee.std_logic_unsigned.all;useieee.std_logic_arith.all;ENTITYbian_maIS------編碼PORT(en,clk:INstd_logic;kr3,kr2,kr1,kr0:INstd_logic;kc2,kc1,kc0:INstd_logic;kk:outstd_logic_vector(31downto0);dout:OUTstd_logic);ENDbian_ma;ARCHITECTUREoneOFbian_maISsignaldata:std_logic_vector(3downto0);signalker:std_logic_vector(3downto0);signald7,d6,d5,d4,d3,d2,d1,d0:std_logic_vector(3downto0);signalkec:std_logic_vector(2downto0);BEGINker<=kr3&kr2&kr1&kr0;kec<=kc2&kc1&kc0;PROCESS(ker)BEGINif(ker="1111")thencasekeciswhenothers=>data<=data;endcase;elsif(ker="1110")thencasekeciswhen"001"=>data<="1010";whenothers=>data<=data;endcase;elsif(ker="1101")thencasekeciswhen"001"=>data<="0001";when"010"=>data<="0010";when"100"=>data<="0011";whenothers=>data<=data;endcase;elsif(ker="1011")thencasekeciswhen"001"=>data<="0100";when"010"=>data<="0101";when"100"=>data<="0110";whenothers=>data<=data;endcase;elsif(ker="0111")thencasekeciswhen"001"=>data<="0111";when"010"=>data<="1000";when"100"=>data<="1001";whenothers=>data<=data;endcase;endif;dout<=((notkr3)or(notkr2)or(notkr1)or(notkr0));endPROCESS; d7<=data; d6<=data; d5<=data; d4<=data;d3<=data;d2<=data;d1<=data;d0<=data;kk<=d7&d6&d5&d4&d3&d2&d1&d0;ENDone;工作狀態(tài)選擇libraryIEEE;useIEEE.std_logic_1164.all;useIEEE.std_logic_unsigned.all;--包含庫--useIEEE.std_logic_arith.all;entitykong_zhi_qiisport(SDIN:INstd_logic;--串行數(shù)據(jù)輸入trig:INstd_logic;--觸發(fā)時(shí)鐘lock:instd_logic;--上鎖信號(hào)sec:instd_logic;--選擇消隱輸出CR:INstd_logic;--確認(rèn)輸入SET:INstd_logic;--設(shè)口令CRACK:INstd_logic;--解鎖din:outintegerrange15downto0;--輸入的數(shù)據(jù)進(jìn)行顯示n_err:outstd_logic_vector(1downto0);--錯(cuò)誤次數(shù)n_cr:outstd_logic_vector(2downto0);--輸入數(shù)據(jù)個(gè)數(shù)ALERT:OUTstd_logic;--報(bào)警輸出REDL:outstd_logic;--上鎖顯示標(biāo)志sc:outstd_logic;--消隱顯示標(biāo)志dead_lock:outstd_logic;--死鎖標(biāo)志GREL:outstd_logic--解鎖顯示標(biāo)志);endentitykong_zhi_qi;architecturebehvofkong_zhi_qiis--signal聲明signalpW_reg0:INTEGERRANGE15DOWNTO0;--口令寄存器signalpW_reg1:INTEGERRANGE15DOWNTO0;signalpW_reg2:INTEGERRANGE15DOWNTO0;signalpW_reg3:INTEGERRANGE15DOWNTO0;signalpW_reg4:INTEGERRANGE15DOWNTO0;signalpW_reg5:INTEGERRANGE15DOWNTO0;signalpW_reg6:INTEGERRANGE15DOWNTO0;signalpW_reg7:INTEGERRANGE15DOWNTO0;signalpc_reg0:INTEGERRANGE15DOWNTO0;--解鎖暫存器signalpc_reg1:INTEGERRANGE15DOWNTO0;signalpc_reg2:INTEGERRANGE15DOWNTO0;signalpc_reg3:INTEGERRANGE15DOWNTO0;signalpc_reg4:INTEGERRANGE15DOWNTO0;signalpc_reg5:INTEGERRANGE15DOWNTO0;signalpc_reg6:INTEGERRANGE15DOWNTO0;signalpc_reg7:INTEGERRANGE15DOWNTO0;signaldata_t:integerrange15downto0;--輸入數(shù)據(jù)累加器signalcr_t:std_logic_vector(2downto0);signalerr_t:std_logic_vector(1downto0);signaltag:std_logic;signalsb:std_logic;--signalbff:INTEGERRANGE15DOWNTO0;beginprocess(trig)beginiftrig'eventandtrig='1'thenifsec='0'thensb<=notsb;sc<=sb;--消隱控制endif;iflock='0'thenREDL<='0';GREL<='1';ALERT<='1';--上鎖endif;iftag='1'
溫馨提示
- 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(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ǔ)空間,僅對(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ì)自己和他人造成任何形式的傷害或損失。
最新文檔
- 《數(shù)圖形的學(xué)問》(教案)四年級(jí)上冊(cè)數(shù)學(xué)北師大版
- 五年級(jí)上冊(cè)數(shù)學(xué)教案-3.2 除數(shù)是小數(shù)的除法 第二課時(shí)-西師大版
- 五年級(jí)下冊(cè)數(shù)學(xué)教案-4 異分母分?jǐn)?shù)加減法 ︳西師大版
- 《三角形的內(nèi)角和》(教學(xué)設(shè)計(jì))-2024-2025學(xué)年青島版四年級(jí)數(shù)學(xué)下冊(cè)
- (高清版)DB45∕T 808-2021 城鎮(zhèn)建筑有線電視網(wǎng)絡(luò)建設(shè)技術(shù)規(guī)范
- 2025年吉林省吉林市單招職業(yè)傾向性測(cè)試題庫新版
- 2024年智能壓力校驗(yàn)儀項(xiàng)目投資申請(qǐng)報(bào)告
- 歷史-云南省三校2025屆高三2月高考備考聯(lián)考卷(六)試題和答案
- 2025年度荒山荒溝土地承包與林業(yè)生態(tài)補(bǔ)償機(jī)制合同
- 2025年度工程尾款支付與質(zhì)量保證協(xié)議書
- 公鐵兩用牽引車市場(chǎng)發(fā)展預(yù)測(cè)和趨勢(shì)分析
- 兒童繪本故事《我的情緒小怪獸》
- 部編版六年級(jí)下冊(cè)道德與法治全冊(cè)教案
- 3.1 導(dǎo)數(shù)的概念 課件 《高等數(shù)學(xué)》
- 2024版《供電營(yíng)業(yè)規(guī)則》學(xué)習(xí)考試題庫500題(含答案)
- 供貨送貨服務(wù)承諾書
- G -B- 43630-2023 塔式和機(jī)架式服務(wù)器能效限定值及能效等級(jí)(正式版)
- EPC項(xiàng)目質(zhì)量保證措施
- 2022-2023學(xué)年北京中橋外國(guó)語學(xué)校 高一數(shù)學(xué)文上學(xué)期摸底試題含解析
- 2023-2024學(xué)年安徽省合肥市瑤海區(qū)八年級(jí)(下)期中數(shù)學(xué)試卷(含解析)
- 物業(yè)小區(qū)安全生產(chǎn)隱患排查治理表
評(píng)論
0/150
提交評(píng)論