EDA電子密碼鎖課程設(shè)計報告_第1頁
EDA電子密碼鎖課程設(shè)計報告_第2頁
EDA電子密碼鎖課程設(shè)計報告_第3頁
EDA電子密碼鎖課程設(shè)計報告_第4頁
EDA電子密碼鎖課程設(shè)計報告_第5頁
已閱讀5頁,還剩25頁未讀 繼續(xù)免費閱讀

下載本文檔

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

文檔簡介

-.z.概述在當今社會中,人們對于隱私的保護和對物品安全的重視程度與日俱增。因此,使用了現(xiàn)代電子技術(shù)的電子密碼鎖便有了廣泛的應(yīng)用前景。本次所設(shè)計的電子密碼鎖,能夠?qū)崿F(xiàn)該六位十進制并行密碼保護,當輸入的密碼與鎖密碼一致時,綠燈亮,開鎖;當輸入的密碼與鎖的密碼不一致時,紅燈亮,不能開鎖。密碼鎖的密碼可由用戶自行設(shè)置,并可在液晶顯示屏上顯示所輸入的密碼。為人們的財產(chǎn)、信息安全提供了可靠地保障。本次設(shè)計基于VHDL語言,對并行六位電子密碼鎖進行設(shè)計,并對設(shè)計過程進行了詳細描述。采用VHDL語言進行電子密碼鎖的設(shè)計可使設(shè)計工作簡潔直觀,快速實現(xiàn)既定功能。電子密碼鎖在對財產(chǎn)安全保護等方面都有著重要作用,應(yīng)用前景非常廣泛。開鎖代碼為六位十進制數(shù),當輸入代碼的位數(shù)和位值與鎖給定的密碼一致,且按規(guī)定程序開鎖時,方可開鎖,并點亮開鎖指示燈。否則,系統(tǒng)進入“錯誤”狀態(tài),并發(fā)出報警信號。開鎖程序由設(shè)計者確定,并要求鎖給定的密碼是可調(diào)的,且預置方便,性好。并行數(shù)字鎖的報警方式是點亮指示燈,并使喇叭鳴叫來報警,直到按下復位開關(guān),報警才停止。此時,數(shù)字鎖又自動進入等待下一次開鎖的狀態(tài)。一、設(shè)計主要容密碼鎖串行輸入幾位十進制數(shù)字口令輸入口令全部正確即開鎖并有綠燈顯示口令輸入最大次數(shù)3次,要求在完全輸入六位之后進行判斷口令正確與否;輸入3次之后還不能開鎖,進入死鎖狀態(tài)并報警有相應(yīng)的顯示功能開鎖后能再次上鎖二、系統(tǒng)設(shè)計方案作為通用電子密碼鎖,主要由三個部分組成:數(shù)字密碼輸入電路、密碼鎖控制電路和密碼鎖顯示電路。(1)密碼鎖輸入電路包括時序產(chǎn)生電路、鍵盤掃描電路、鍵盤譯碼電路等幾個小的功能電路。(2)密碼鎖控制電路包括按鍵數(shù)據(jù)的緩沖存儲電路,密碼的清除、存儲、激活電鎖電路(寄存器清除信號發(fā)生電路),密碼核對(數(shù)值比較電路),解鎖電路(開/關(guān)門鎖電路)等幾個小的功能電路。(3)密碼顯示電路主要是在液晶顯示屏顯示輸入的數(shù)值。2.1密碼鎖輸入電路的設(shè)計是電子密碼鎖的輸入電路框圖,由鍵盤掃描電路、彈跳消除電路、鍵盤譯碼電路、按鍵數(shù)據(jù)緩存器,加上外接的一個4×4矩陣式鍵盤組成。798798按鍵數(shù)據(jù)鍵盤輸入465按鍵數(shù)據(jù)鍵盤輸入465工作時鐘脈沖信號鍵盤掃描信號彈跳消除電路鍵盤譯碼電路按鍵數(shù)據(jù)緩存器0321工作時鐘脈沖信號鍵盤掃描信號彈跳消除電路鍵盤譯碼電路按鍵數(shù)據(jù)緩存器0321鍵盤掃描電路鍵盤掃描電路圖1-1密碼鎖的輸入電路框圖1.矩陣式鍵盤的工作原理KC1KC2矩陣式鍵盤是一種常見的輸入裝置,在日常的生活中,矩陣式鍵盤在計算機、、手機、微波爐等各式電子產(chǎn)品上已經(jīng)被廣泛應(yīng)用。圖1-2是一個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è)計1)時序產(chǎn)生電路本時序產(chǎn)生電路中使用了三種不同頻率的工作脈沖波形:系統(tǒng)時鐘脈沖(它是系統(tǒng)部所有時鐘脈沖的源頭,且其頻率最高)、彈跳消除取樣信號、鍵盤掃描信號。2)鍵盤掃描電路掃描電路的作用是用來提供鍵盤掃描信號的,掃描信號變化的順序依次為1110-1101-1011-0111-1110......依序地周而復始。3)彈跳消除電路由于本設(shè)計中采用的矩陣式鍵盤是機械開關(guān)結(jié)構(gòu),因此在開關(guān)切換的瞬間會在接觸點出現(xiàn)信號來回彈跳的現(xiàn)象,對于電子密碼鎖這種靈敏度較高的電路這種彈跳將很可能會造成誤動作輸入,從而影響到密碼鎖操作的正確性。從圖1-3中可以觀察出彈跳現(xiàn)象產(chǎn)生的原因,雖然只是按下按鍵一次然后放掉,然而實際產(chǎn)生的按鍵信號卻不止跳動一次,經(jīng)過取樣信號的檢查后,將會造成誤判斷,以為鍵盤按了兩次。如果調(diào)整抽樣頻率(如圖4.5所示),可以發(fā)現(xiàn)彈跳現(xiàn)象獲得了改善。圖1-3彈跳現(xiàn)象產(chǎn)生錯誤的抽樣結(jié)果圖1-4調(diào)整抽樣頻率后得到的抽樣結(jié)果4)鍵盤譯碼電路上述鍵盤中的按鍵可分為數(shù)字按鍵和文字按鍵,每一個按鍵可能負責不同的功能,例如清除數(shù)碼、退位、激活電鎖、開鎖等。5)按鍵存儲電路因為每次掃描會產(chǎn)生新的按鍵數(shù)據(jù),可能會覆蓋前面的數(shù)據(jù),所以需要一個按鍵存儲電路,將整個鍵盤掃描完畢后的結(jié)果記錄下來。按鍵存儲電路可以使用移位寄存器構(gòu)成。圖1-5輸入電路仿真波形圖2.3密碼鎖控制電路的設(shè)計密碼鎖的控制電路是整個電路的控制中心,主要完成對數(shù)字按鍵輸入和功能按鍵輸入的響應(yīng)控制。1.數(shù)字按鍵輸入的響應(yīng)控制(1)如果按下數(shù)字鍵,第一個數(shù)字會從顯示器的最右端開始顯示,此后每新按一個數(shù)字時,顯示器上的數(shù)字必須左移一格,以便將新的數(shù)字顯示出來。(2)假如要更改輸入的數(shù)字,可以按倒退按鍵來清除前一個輸入的數(shù)字,或者按清除鍵清除所有輸入的數(shù)字,再重新輸入六位數(shù)。(3)由于這里設(shè)計的是一個六位的電子密碼鎖,所以當輸入的數(shù)字鍵超過四個時,電路不予理會,而且不再顯示第六個以后的數(shù)字。2.4功能按鍵輸入的響應(yīng)控制(1)清除鍵:清除所有的輸入數(shù)字,即做歸零動作。(2)激活電鎖鍵:按下此鍵時可將密碼鎖的門上鎖。(上鎖前必須預先設(shè)定一個六位的數(shù)字密碼。)(3)解除電鎖鍵:按下此鍵會檢查輸入的密碼是否正確,若密碼正確無誤則開門。輸入文字模式輸入文字模式開始輸入六位數(shù)字,在輸入過程中可能用到刪除鍵上鎖工作模式密碼鎖激活上鎖上鎖工作模式密碼鎖激活上鎖開鎖工作模式檢查輸入的密碼是否有效核對輸入的密碼是否有效都正確后解除電鎖圖1-5電子密碼鎖的三種模式及關(guān)系2.5密碼鎖顯示電路的設(shè)計密碼鎖顯示電路的設(shè)計比較復雜,這里直接采用12864液晶屏進行顯示。2.6密碼鎖的整體組裝設(shè)計將前面各個設(shè)計好的功能模塊進行整合,可得到一個完整的電子密碼鎖系統(tǒng)的整體組裝設(shè)計原理圖,如圖1-6所示。圖1-6密碼鎖的整體組裝設(shè)計原理圖系統(tǒng)擴展思路(1)本系統(tǒng)基本達到作為數(shù)字密碼鎖的絕大部分功能,但還有許多不足或需完善的地方。比如說采用4×4的通用機械鍵盤受到鍵盤數(shù)量的限制,在很大的程度上限制了其功能的擴展。設(shè)計外圍電路:系統(tǒng)用方波信號源,直流工作電源??梢笤O(shè)計制作整個系統(tǒng),包括PCB的制作。實驗收獲課程設(shè)計是培養(yǎng)學生綜合運用所學知識,發(fā)現(xiàn),提出,分析和解決實際問題,鍛煉實踐能力的重要環(huán)節(jié),是對學生實際工作能力的具體訓練和考察過程。隨著科學技術(shù)發(fā)展的日新月異,F(xiàn)PGA已經(jīng)成為當今計算機應(yīng)用中空前活躍的領(lǐng)域,在生活中可以說無處不在。因此作為二十一世紀的大學來說掌握eda的開發(fā)技術(shù)是十分必要的?;仡櫞舜握n程設(shè)計,我感慨頗多,的確,從理論到實踐,在很長的一段時間里,可以說是苦多于甜,但確實學到了很多東西,不僅可以鞏固以前學到的知識,還學到許多沒學過的知識。通過此次課程設(shè)計,使我了解了理論與實際結(jié)合的重要性,只有理論知識是遠遠不夠的。在設(shè)計的過程中,發(fā)現(xiàn)自己以前學習的知識理解不夠深刻,掌握不夠牢固等等。通過這次課設(shè)之后,一定要把以前學習的知識溫故知新。這次的課設(shè)終于完成,通過老師的細心講解,我解決了很多問題。在這里,感老師的細心指導。同時對于幫助我的同學,也表示衷心感。附錄液晶顯示程序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",--請輸入密碼: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",--進入死鎖狀態(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;--動態(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ā)時鐘lock:instd_logic;--上鎖信號sec:instd_logic;--選擇消隱輸出CR:INstd_logic;--確認輸入SET:INstd_logic;--設(shè)口令CRACK:INstd_logic;--解鎖din:outintegerrange15downto0;--輸入的數(shù)據(jù)進行顯示n_err:outstd_logic_vector(1downto0);--錯誤次數(shù)n_cr:outstd_logic_vector(2downto0);--輸入數(shù)據(jù)個數(shù)ALERT:OUTstd_logic;--報警輸出REDL:outstd_logic;--上鎖顯示標志sc:outstd_logic;--消隱顯示標志dead_lock:outstd_logic;--死鎖標志GREL:outstd_logic--解鎖顯示標志);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等.壓縮文件請下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預覽,若沒有圖紙預覽就沒有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負責。
  • 6. 下載文件中如有侵權(quán)或不適當內(nèi)容,請與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。

評論

0/150

提交評論