EDA技术(机械)实验报告--数字锁.docx
实验报告(计算机类)开课学院及实验室:实验时间:年月日学生姓名学号成绩学生所在学院年级/专业/班课程名称EDA技术(机械)课程代码实验项目名称数字锁项目代码指导教师项目学分一、实验目的1 .了解VHDL语言编程方法,学会熟练运用quartus软件2 .了解数字锁的运作原理3 .了解如何使用VHDL设计一个数字锁二、内容与设计思想1 .数字锁即电子密码锁,锁内有若干密码,所用密码可由用户自己选定。2 .数字锁有两类:一类是并行接收数据称为并行锁;另一类是串行接收数据,称为串行锁。如果输入代码与锁内密码一致,锁被打开;否则封闭开锁电路并发出警报。3 .设计一个8位串行数字锁:(1)开锁代码为8位二进制数,当输入代码的位数和位值与锁内给定的密码一致,且按规定程序开锁,方可开锁,并点亮指示灯LT。否则系统进入“错误状态”并发出警报信号。(2)开锁程序由设计者确定,并要求锁内给定的密码是可调的,且预置方便,保密性好。(3)串行数字锁的报警方式是点亮指示灯LF,并使喇叭鸣叫报警,直到按下复位键,报警才停止。此时,数字锁自动进入等待下一次开锁状态。三、使用环境WinXP或Win7QUartUSii编程环境四、核心代码及调试过程数字锁分频模块一占空比1:10000方波,用于消除抖动Iibraryieee;useieee.std_Iogic_1164.aII;useieee.std_Iogic_unsigned.all;useieee.std_Iogic_arith.aII;entityfenisport(elk:instd_logic;cIk1:outstd_logic);endfen;architecturebhvoffenisbeginprocess(cIk)variabIeent:integerrange0to9999;beginifcIk,eventandcIk='1,thenifent=9999thenent:=0;clk1<=,1'ent:=cnt+1;clk1<=,0,;endif;endif;endprocess;endbhv;消抖同步模块Iibraryieee;useieee.std_Iogic_1164.aII;useieee.std_Iogic_unsigned.all;useieee.std_logic_arith.all;entityxiaoproisport(a,cIk1:instd_logic;b:outstd_logic);endxiaopro;architecturebhv1ofxiaoproissignaItmp1:std_logic;beginprocess(cIk1,a)variabIetmp2,tmp3:std_logic;beginifcIk1'eventandcIk1='0,thentmp1<=a;tmp2:=tmp1;tmp3:=nottmp2;endif;b<-tmp1andtmp3andcIk1;endprocess;endbhv1:逻辑功能模块程序核心Iibraryieee;useieee.std_Iogic_1164.all;useieee.std_Iogic_unsigned.all;useieee.std_Iogic_arith.all;entityCORNAAisport(elk,clrk,k1,load:instd_logic;Clr用于清除报警信号和关锁,k1,k代表1和。的按键开关,load为设置密码的开关11:inoutstd_logic;Iamp:outstd_Iogic_vector(7downto0);1amp接发光二极管,用于显示已经输入密码的个数If,alm:outstd_logic);endCORNAA;architecturebhv2ofCORNAAissignaIshift,Iock:std_Iogic_vector(7downto0);signaIIam:std_Iogic_vector(7downto0);signaIIa:std_logic;beginprocess(cIk,cIr)beginifclr='0'thenla<=,0'eIsifcIk,eventandcIk='1,thenifIoad='0,thenla<=,;endif;endif;endprocess;process(elk,clr)variabIea:integerrange0to8;beginifcIr='0'thenlam<="00000000"shift<="00000000"a:=0;lt<=,0'lf<=,01;alm<=,0'eIsifclk'eventandcIk='1,theniflt=,0,thenifa-8thenifk1=10,thenshift<='1,&shift(7downto1);输入一位密码"1"显示输入了一位密码输入一位密码“0"Iam<='1,&Iam(7downto1);a:=a+1;eIsifk='0,thenshift<=,0"&shift(7downto1);lam<='1'&lam(7downto1);a:=a+1;endif;eIsea:=0;ifshift=lockthent<=,;一密码正确eIseK='一密码错误aIm<=,11;endif;endif;eIsifIa=,1,thenifk1='0,thenlock<='1'&lock(7downto1);Iam<='0,&lam(7downto1);eIsifk='0,thenlock<='0'&lock(7downto1);Iam<=<0,&Iam(7downto1);endif;endif;endif;endprocess;Iamp<=lam;endbhv2;总体框图:五、总结六、附录(仿真结果)