EDA电子密码锁课程设计报告_第1页
EDA电子密码锁课程设计报告_第2页
EDA电子密码锁课程设计报告_第3页
EDA电子密码锁课程设计报告_第4页
EDA电子密码锁课程设计报告_第5页
已阅读5页,还剩25页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

-.z.概述在当今社会中,人们对于隐私的保护和对物品安全的重视程度与日俱增。因此,使用了现代电子技术的电子密码锁便有了广泛的应用前景。本次所设计的电子密码锁,能够实现该六位十进制并行密码保护,当输入的密码与锁密码一致时,绿灯亮,开锁;当输入的密码与锁的密码不一致时,红灯亮,不能开锁。密码锁的密码可由用户自行设置,并可在液晶显示屏上显示所输入的密码。为人们的财产、信息安全提供了可靠地保障。本次设计基于VHDL语言,对并行六位电子密码锁进行设计,并对设计过程进行了详细描述。采用VHDL语言进行电子密码锁的设计可使设计工作简洁直观,快速实现既定功能。电子密码锁在对财产安全保护等方面都有着重要作用,应用前景非常广泛。开锁代码为六位十进制数,当输入代码的位数和位值与锁给定的密码一致,且按规定程序开锁时,方可开锁,并点亮开锁指示灯。否则,系统进入“错误”状态,并发出报警信号。开锁程序由设计者确定,并要求锁给定的密码是可调的,且预置方便,性好。并行数字锁的报警方式是点亮指示灯,并使喇叭鸣叫来报警,直到按下复位开关,报警才停止。此时,数字锁又自动进入等待下一次开锁的状态。一、设计主要容密码锁串行输入几位十进制数字口令输入口令全部正确即开锁并有绿灯显示口令输入最大次数3次,要求在完全输入六位之后进行判断口令正确与否;输入3次之后还不能开锁,进入死锁状态并报警有相应的显示功能开锁后能再次上锁二、系统设计方案作为通用电子密码锁,主要由三个部分组成:数字密码输入电路、密码锁控制电路和密码锁显示电路。(1)密码锁输入电路包括时序产生电路、键盘扫描电路、键盘译码电路等几个小的功能电路。(2)密码锁控制电路包括按键数据的缓冲存储电路,密码的清除、存储、激活电锁电路(寄存器清除信号发生电路),密码核对(数值比较电路),解锁电路(开/关门锁电路)等几个小的功能电路。(3)密码显示电路主要是在液晶显示屏显示输入的数值。2.1密码锁输入电路的设计是电子密码锁的输入电路框图,由键盘扫描电路、弹跳消除电路、键盘译码电路、按键数据缓存器,加上外接的一个4×4矩阵式键盘组成。798798按键数据键盘输入465按键数据键盘输入465工作时钟脉冲信号键盘扫描信号弹跳消除电路键盘译码电路按键数据缓存器0321工作时钟脉冲信号键盘扫描信号弹跳消除电路键盘译码电路按键数据缓存器0321键盘扫描电路键盘扫描电路图1-1密码锁的输入电路框图1.矩阵式键盘的工作原理KC1KC2矩阵式键盘是一种常见的输入装置,在日常的生活中,矩阵式键盘在计算机、、手机、微波炉等各式电子产品上已经被广泛应用。图1-2是一个3×4矩阵式键盘的面板配置图,其中数字0~9作为密码数字输入按键。KC1KC2KC0KC0KR0(11)KR1(10)KR2(01)KR3(00)01111011110111103021654798KR0(11)KR1(10)KR2(01)KR3(00)01111011110111103021654798图1-24×4矩阵式键盘的面板配置2.2密码锁输入电路各主要功能模块的设计1)时序产生电路本时序产生电路中使用了三种不同频率的工作脉冲波形:系统时钟脉冲(它是系统部所有时钟脉冲的源头,且其频率最高)、弹跳消除取样信号、键盘扫描信号。2)键盘扫描电路扫描电路的作用是用来提供键盘扫描信号的,扫描信号变化的顺序依次为1110-1101-1011-0111-1110......依序地周而复始。3)弹跳消除电路由于本设计中采用的矩阵式键盘是机械开关结构,因此在开关切换的瞬间会在接触点出现信号来回弹跳的现象,对于电子密码锁这种灵敏度较高的电路这种弹跳将很可能会造成误动作输入,从而影响到密码锁操作的正确性。从图1-3中可以观察出弹跳现象产生的原因,虽然只是按下按键一次然后放掉,然而实际产生的按键信号却不止跳动一次,经过取样信号的检查后,将会造成误判断,以为键盘按了两次。如果调整抽样频率(如图4.5所示),可以发现弹跳现象获得了改善。图1-3弹跳现象产生错误的抽样结果图1-4调整抽样频率后得到的抽样结果4)键盘译码电路上述键盘中的按键可分为数字按键和文字按键,每一个按键可能负责不同的功能,例如清除数码、退位、激活电锁、开锁等。5)按键存储电路因为每次扫描会产生新的按键数据,可能会覆盖前面的数据,所以需要一个按键存储电路,将整个键盘扫描完毕后的结果记录下来。按键存储电路可以使用移位寄存器构成。图1-5输入电路仿真波形图2.3密码锁控制电路的设计密码锁的控制电路是整个电路的控制中心,主要完成对数字按键输入和功能按键输入的响应控制。1.数字按键输入的响应控制(1)如果按下数字键,第一个数字会从显示器的最右端开始显示,此后每新按一个数字时,显示器上的数字必须左移一格,以便将新的数字显示出来。(2)假如要更改输入的数字,可以按倒退按键来清除前一个输入的数字,或者按清除键清除所有输入的数字,再重新输入六位数。(3)由于这里设计的是一个六位的电子密码锁,所以当输入的数字键超过四个时,电路不予理会,而且不再显示第六个以后的数字。2.4功能按键输入的响应控制(1)清除键:清除所有的输入数字,即做归零动作。(2)激活电锁键:按下此键时可将密码锁的门上锁。(上锁前必须预先设定一个六位的数字密码。)(3)解除电锁键:按下此键会检查输入的密码是否正确,若密码正确无误则开门。输入文字模式输入文字模式开始输入六位数字,在输入过程中可能用到删除键上锁工作模式密码锁激活上锁上锁工作模式密码锁激活上锁开锁工作模式检查输入的密码是否有效核对输入的密码是否有效都正确后解除电锁图1-5电子密码锁的三种模式及关系2.5密码锁显示电路的设计密码锁显示电路的设计比较复杂,这里直接采用12864液晶屏进行显示。2.6密码锁的整体组装设计将前面各个设计好的功能模块进行整合,可得到一个完整的电子密码锁系统的整体组装设计原理图,如图1-6所示。图1-6密码锁的整体组装设计原理图系统扩展思路(1)本系统基本达到作为数字密码锁的绝大部分功能,但还有许多不足或需完善的地方。比如说采用4×4的通用机械键盘受到键盘数量的限制,在很大的程度上限制了其功能的扩展。设计外围电路:系统用方波信号源,直流工作电源。可要求设计制作整个系统,包括PCB的制作。实验收获课程设计是培养学生综合运用所学知识,发现,提出,分析和解决实际问题,锻炼实践能力的重要环节,是对学生实际工作能力的具体训练和考察过程。随着科学技术发展的日新月异,FPGA已经成为当今计算机应用中空前活跃的领域,在生活中可以说无处不在。因此作为二十一世纪的大学来说掌握eda的开发技术是十分必要的。回顾此次课程设计,我感慨颇多,的确,从理论到实践,在很长的一段时间里,可以说是苦多于甜,但确实学到了很多东西,不仅可以巩固以前学到的知识,还学到许多没学过的知识。通过此次课程设计,使我了解了理论与实际结合的重要性,只有理论知识是远远不够的。在设计的过程中,发现自己以前学习的知识理解不够深刻,掌握不够牢固等等。通过这次课设之后,一定要把以前学习的知识温故知新。这次的课设终于完成,通过老师的细心讲解,我解决了很多问题。在这里,感老师的细心指导。同时对于帮助我的同学,也表示衷心感。附录液晶显示程序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",--进入死锁状态*"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;--动态显示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;工作状态选择libraryIEEE;useIEEE.std_logic_1164.all;useIEEE.std_logic_unsigned.all;--包含库--useIEEE.std_logic_arith.all;entitykong_zhi_qiisport(SDIN:INstd_logic;--串行数据输入trig:INstd_logic;--触发时钟lock:instd_logic;--上锁信号sec:instd_logic;--选择消隐输出CR:INstd_logic;--确认输入SET:INstd_logic;--设口令CRACK:INstd_logic;--解锁din:outintegerrange15downto0;--输入的数据进行显示n_err:outstd_logic_vector(1downto0);--错误次数n_cr:outstd_logic_vector(2downto0);--输入数据个数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;--输入数据累加器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. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论