EDA4位密碼鎖的課程設(shè)計(jì)_第1頁
EDA4位密碼鎖的課程設(shè)計(jì)_第2頁
EDA4位密碼鎖的課程設(shè)計(jì)_第3頁
EDA4位密碼鎖的課程設(shè)計(jì)_第4頁
EDA4位密碼鎖的課程設(shè)計(jì)_第5頁
已閱讀5頁,還剩19頁未讀, 繼續(xù)免費(fèi)閱讀

下載本文檔

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

文檔簡介

1、信息技術(shù)學(xué)院可編程邏輯器件原理及應(yīng)用課程綜合設(shè)計(jì)報(bào)告書姓 名: 景顯冬 班 級: B1106 學(xué) 號: 04 時(shí) 間: 2013.12.31 指導(dǎo)教師: 李海成 設(shè)計(jì)題目密碼鎖設(shè)計(jì)設(shè)計(jì)要求和任務(wù)數(shù)據(jù)輸入:每按一個(gè)數(shù)字鍵,就輸入一個(gè)數(shù)值,并在顯示器上的最右方顯示出該數(shù)值,并將先前已經(jīng)輸入的數(shù)據(jù)依序左移一個(gè)數(shù)字位置。數(shù)碼清除:按下此鍵可清除前面所有的輸入值,清除成為“0000”。密碼更改:按下此鍵時(shí)將目前的數(shù)字設(shè)定成新的密碼。激活電鎖:按下此鍵可將密碼鎖上鎖。解除電鎖:按下此鍵會(huì)檢查輸入的密碼是否正確,密碼正確即開鎖。設(shè)計(jì)過程設(shè)計(jì)方案 本系統(tǒng)采用模塊化的設(shè)計(jì),整個(gè)系統(tǒng)分為數(shù)字按鍵輸入、時(shí)鐘輸入、功

2、能按鍵輸入、數(shù)字譯碼塊、功能譯碼模塊、核心處理模塊、輸出處理模塊、顯示譯碼電路八個(gè)模塊。整體電路如圖1.1所示。數(shù)字按鍵輸入時(shí)鐘模塊功能按鍵輸入數(shù)字譯碼模塊功能譯碼模塊核心處理模塊輸出處理模塊顯示譯碼電路圖1.1 數(shù)字密碼鎖總方框圖硬件電路的設(shè)計(jì)4位數(shù)字密碼鎖包括五個(gè)基本邏輯模塊,分別為:數(shù)字按鍵輸入模塊(numinput)、功能按鍵輸入模塊(funcinput)、核心處理模塊(core)、輸出處理模塊(allout)、七段譯碼器模塊(dataout)。數(shù)字按鍵輸入-numinput說明:讀取數(shù)字鍵09。按鍵為矩陣形式,高電平表示按鍵未按下,低電平表示按鍵按下。經(jīng)數(shù)字按鍵輸入模塊處理后輸出4位

3、二進(jìn)制代碼,“0000”“1001”分別表示09,用“1010”表示其他無效輸入。如表2.1所示。設(shè)計(jì)過程表2.1 數(shù)字按鍵輸入模塊(numinput)的數(shù)據(jù)輸入輸出按鍵數(shù)字按鍵掃描輸出Numinput二進(jìn)制輸出對應(yīng)十進(jìn)制數(shù)字01101111000000101111101000112011111100010231011011100113410111011010045101111010101561011111001106711010111011178110110111000891101110110019其他按鍵其他101010(1)numinput-數(shù)字按鍵輸入模塊程序:library ieee

4、;use ieee.std_logic_1164.all;entity numinput isport(numin :IN std_logic_vector(7 downto 0);numstate,clk :IN std_logic;numout :OUT std_logic_vector(3 downto 0);end numinput;architecture one of numinput issignal state :std_logic;signal mem :std_logic_vector(7 downto 0);beginprocess(clk)beginif clkeven

5、t and clk=1 then設(shè)計(jì)過程if state/=numstate thenif mem/=numin thencase numin iswhen 11011110 = numout numout numout numout numout numout numout numout numout numout numout=1010;end case;state=numstate;else numout=1010;end if;mem=numin;end if;end if;end process;end one;(2)數(shù)字按鍵輸入模塊仿真圖:設(shè)計(jì)過程圖2.1 數(shù)字按鍵輸入模塊仿真圖由

6、圖可知,當(dāng)數(shù)字按鍵輸入模塊的輸入依次為11011110、01111101、01111110、10110111、10111011、10111101、10111110、11010111、11011011、11011101時(shí),numout輸出依次輸出“0000”、“0001”、“0010”、“0011”、“0100”、“0101”、“0110”、“0111”、“1000”、“1001”;當(dāng)為其他按鍵輸入時(shí),numout輸出均為“1010”。(3)數(shù)字按鍵輸入-numinput符號文件:圖2.2 數(shù)字按鍵輸入-numinput符號文件功能按鍵輸入模塊 - funcinput讀取矩陣按鍵區(qū)控制功能按鍵

7、清除鍵、改密鍵、上鎖鍵、解鎖鍵。高電平表示按鍵未按下,低電平表示按鍵按下。按照“清除,改設(shè)計(jì)過程密,上鎖,解鎖”順序讀取按鍵時(shí),只能輸出一位控制信號。輸出的信號為3位二進(jìn)制代碼,“001”“100”,依次表示“清除按鍵、改密按鍵、上鎖,解鎖”,用“000”表示輸入不為功能按鍵信號。表2.2 控制功能按鍵輸入模塊(funcinput)的輸出輸入數(shù)據(jù)功能按鍵功能按鍵掃描輸出Funcinput二進(jìn)制輸出對應(yīng)十進(jìn)制數(shù)字清除鍵111001110011改密鍵111011010102上鎖鍵111011100113解鎖鍵111010111004其他按鍵其他0000(1)Funcinput-功能按鍵輸入模塊程序

8、:library ieee;use ieee.std_logic_1164.all;entity funcinput isport( funcin:IN std_logic_vector(7 downto 0);constate,clk:IN std_logic;conout:OUT std_logic_vector(2 downto 0);end funcinput;architecture one of funcinput issignal state:std_logic;signal mem:std_logic_vector(7 downto 0);beginprocess(clk)be

9、ginif clkevent and clk=1 thenif constate/=state thenstate=constate;設(shè)計(jì)過程if mem/=funcin then with funcin selectconout=001 when 11100111 , -清除鍵010 when 11101101,-改密鍵011 when 11101110, -上鎖鍵100 when 11101011 , -解鎖鍵000 when others;mem=funcin;else conout=000;end if;end if;end if;end process;end one;(2)功能按鍵

10、輸入模塊仿真圖:圖2.3 功能按鍵輸入模塊仿真圖由圖可知:當(dāng)功能按鍵輸入模塊的輸入依次為“11100111”、“ 11101101”、“ 11101110”、“ 11101011”時(shí),conout輸出依次為“001”、“010”、“011”、“100”, 當(dāng)為其他按鍵輸入時(shí),conout輸出均為“000”。(3)功能按鍵輸入模塊-funcinput符號文件:設(shè)計(jì)過程圖2.4 功能按鍵輸入模塊 -funcinput符號文件 核心處理模塊-core核心處理模塊將根據(jù)輸入(數(shù)字按鍵輸入以及功能按鍵輸入)來改變存儲(chǔ)器狀態(tài)、數(shù)碼管顯示以及LED燈顯示(紅燈亮為上鎖,綠燈亮為解鎖)。(1)Core-核心處

11、理程序:library ieee;use ieee.std_logic_1164.all;entity core isport( numin:in std_logic_vector(3 downto 0);conin:in std_logic_vector(2 downto 0);clk:in std_logic;dataa,datab,datac,datad:out std_logic_vector(3 downto 0);ledr,ledg,numout,conout:out std_logic);end entity;architecture one of core istype loc

12、kstate is (unlock,locked);signal numa,numb,numc,numd,codea,codeb,codec,coded:std_logic_vector(3 downto 0);signal numstate,constate:std_logic;signal locksta:lockstate;beginprocess(clk,numin,conin)設(shè)計(jì)過程if clkevent and clk=1 then-上升沿if numin/=1010 then-當(dāng)不是其他鍵時(shí)numd=numc;numc=numb;numb=numa;numa=numin;-移位

13、end if;if conin/=000 thenif conin=001 then-清除鍵按下numa=0000;-全部清零numb=0000;numc=0000;numd=0000;elsif conin=010 then -改密鍵按下if locksta/=locked then-鎖并不是上鎖狀態(tài)codea=numa;codeb=numb;codec=numc;coded=numd;end if;elsif conin=011 then -上鎖鍵按下if locksta/=locked thennuma=0000;numb=0000;numc=0000;numd=0000;locksta

14、=locked; -鎖定密碼鎖end if;elsif conin=100 then -解鎖鍵按下設(shè)計(jì)過程if locksta=locked then if numa=codea and numb=codeb then -輸入正確密碼if numc=codec and numd=coded thenlocksta=unlock; -鎖開end if;end if;end if;end if;end if;if locksta=locked then -若鎖鎖定ledr=1; -led等高電平,紅燈閃爍ledg=0;elseledr=0;ledg=1;end if;dataa=numa;data

15、b=numb;datac=numc;datad=numd;if numstate=1 then numstate=0;else numstate=1;end if;if constate=1 then constate=0;else constate=1;end if;numout=numstate;conout=constate;設(shè)計(jì)過程end if;end process;end one;(2)核心處理模塊仿真圖:當(dāng)數(shù)字按鍵輸入為有效輸入(即輸入的按鍵為數(shù)字按鍵09時(shí)),此時(shí)雖輸入9位數(shù)字,但只有前四位有效,所以密碼應(yīng)為“1234”。 若conin輸入為“011”(即按下上鎖鍵),此時(shí)可以

16、看到ledr為高電平,所以此時(shí)紅燈閃爍一次,表示密碼鎖已上鎖。仿真波形圖如下:圖2.5 核心處理模塊仿真圖(一)圖2.6 核心處理模塊仿真圖(二)由圖可知:若conin輸入為“100”時(shí)(解鎖時(shí)),當(dāng)再次輸入密碼“1234”,并此時(shí)ledg輸出為低電平(綠燈亮)。Dataa輸出密碼“1234”,則表示此時(shí)密碼鎖已解鎖。(3)核心處理模塊-core符號文件:設(shè)計(jì)過程圖2.7 處理核心模塊-core符號文件 輸出處理模塊allout對處理核心模塊core輸出的數(shù)據(jù)進(jìn)行刷新,使數(shù)碼管及時(shí)顯示刷新的數(shù)字。(1)Allout-輸出處理程序:library ieee;use ieee.std_logic_

17、1164.all;entity allout isport( dataa,datab,datac,datad:in std_logic_vector(3 downto 0);clk:in std_logic;dataout:out std_logic_vector(3 downto 0);outsel:out std_logic_vector(1 downto 0);end allout;architecture one of allout issignal timer:std_logic_vector(1 downto 0);beginprocess(clk)beginif clkevent

18、 and clk=1 then-上升沿設(shè)計(jì)過程if timer=00 thendataout=dataa;outsel=00;timer=01;elsif timer=01 thendataout=datab;outsel=01;timer=10;elsif timer=10 thendataout=datac;outsel=10;timer=11;elseataout=datad;outsel=11;timer dataout dataout dataout dataout dataout dataout dataout dataout dataout dataout dataout=000

19、0000; -不顯示end case;end process;end one;(2)Dataout-七段譯碼器模塊仿真圖:圖2.10 七段譯碼器模塊仿真圖由圖可知:當(dāng)七段譯碼器的輸入信號(datain)為“0000”、“0001”、“0010”、“0011”、“0100”、“0101”、“0110”、“0111”、“1000”、“1001”,輸出信號(dataout)依次為:“1111110”、“ 0110000”、“ 1101101”、“ 1111001”、“ 0110011”、“ 1011011”、“ 1011111”、“ 1110000”、 “1111111”、“ 1111011”,當(dāng)c

20、onin輸入信號為其他時(shí),譯碼輸出為“0000000”。表2.3 七段譯碼器的輸入及譯碼對照表設(shè)計(jì)過程二進(jìn)制譯碼輸入二進(jìn)制譯碼輸出數(shù)碼管顯示數(shù)字000011111100000101100001001011011012001111110013010001100114010110110115011010111116011111100007100011111118100111110119其他輸入0000000無顯示(3)輸出處理模塊Dataout符號文件:圖2.11 輸出處理模塊allout符號文件 軟件設(shè)計(jì)四位密碼鎖的電路設(shè)計(jì)原理圖如下:設(shè)計(jì)過程設(shè)計(jì)過程 圖3.1 四位密碼鎖的電路設(shè)計(jì)原理圖系統(tǒng)仿

21、真該四位數(shù)字密碼鎖的設(shè)計(jì)是一個(gè)實(shí)時(shí)的系統(tǒng),對于每一個(gè)按鍵的操作都是在時(shí)鐘的上升沿完成的,是一個(gè)動(dòng)態(tài)的邏輯關(guān)系;而系統(tǒng)輸出為數(shù)碼管顯示的實(shí)時(shí)輸出,不便于分析該系統(tǒng)電路的功能,且系統(tǒng)電路中存在自動(dòng)刷新的功能模塊,因而電路仿真時(shí)不能較好地觀察輸出結(jié)果,為了解決這一問題,故修改電路的原理圖如下:圖4.1 便于觀察輸出結(jié)果的原理圖圖4.2 系統(tǒng)仿真圖(一)設(shè)計(jì)過程由圖可知,當(dāng)功能按鍵的輸入(funcin)為“11100111”(即按下功能按鍵“清除鍵”)時(shí),系統(tǒng)輸出(dataa,datab,datac,datad)均為“0000”,表示密碼鎖的密碼已清除,數(shù)碼管顯示輸出為“1111110”,即此時(shí)4個(gè)數(shù)碼管均顯示數(shù)字“0”。圖4.3 系統(tǒng)仿真圖(二)由圖可知,功能按鍵的輸入(funcin)

溫馨提示

  • 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

提交評論