EDA电子密码锁1Word文件下载.docx

上传人:b****2 文档编号:5803532 上传时间:2023-05-05 格式:DOCX 页数:24 大小:302.02KB
下载 相关 举报
EDA电子密码锁1Word文件下载.docx_第1页
第1页 / 共24页
EDA电子密码锁1Word文件下载.docx_第2页
第2页 / 共24页
EDA电子密码锁1Word文件下载.docx_第3页
第3页 / 共24页
EDA电子密码锁1Word文件下载.docx_第4页
第4页 / 共24页
EDA电子密码锁1Word文件下载.docx_第5页
第5页 / 共24页
EDA电子密码锁1Word文件下载.docx_第6页
第6页 / 共24页
EDA电子密码锁1Word文件下载.docx_第7页
第7页 / 共24页
EDA电子密码锁1Word文件下载.docx_第8页
第8页 / 共24页
EDA电子密码锁1Word文件下载.docx_第9页
第9页 / 共24页
EDA电子密码锁1Word文件下载.docx_第10页
第10页 / 共24页
EDA电子密码锁1Word文件下载.docx_第11页
第11页 / 共24页
EDA电子密码锁1Word文件下载.docx_第12页
第12页 / 共24页
EDA电子密码锁1Word文件下载.docx_第13页
第13页 / 共24页
EDA电子密码锁1Word文件下载.docx_第14页
第14页 / 共24页
EDA电子密码锁1Word文件下载.docx_第15页
第15页 / 共24页
EDA电子密码锁1Word文件下载.docx_第16页
第16页 / 共24页
EDA电子密码锁1Word文件下载.docx_第17页
第17页 / 共24页
EDA电子密码锁1Word文件下载.docx_第18页
第18页 / 共24页
EDA电子密码锁1Word文件下载.docx_第19页
第19页 / 共24页
EDA电子密码锁1Word文件下载.docx_第20页
第20页 / 共24页
亲,该文档总共24页,到这儿已超出免费预览范围,如果喜欢就下载吧!
下载资源
资源描述

EDA电子密码锁1Word文件下载.docx

《EDA电子密码锁1Word文件下载.docx》由会员分享,可在线阅读,更多相关《EDA电子密码锁1Word文件下载.docx(24页珍藏版)》请在冰点文库上搜索。

EDA电子密码锁1Word文件下载.docx

LibraryIEEE;

useIEEE.std_logic_1164.all;

useIEEE.std_logic_unsigned.all;

entitykeyis

port(key_in1,key_in2,key_in3,key_in4,key_in5,key_in6:

instd_logic;

clk:

str:

resert:

clk20:

ds:

key_out:

outstd_logic_vector(5downto0);

key_read:

outstd_logic;

key_resert:

key_r:

outstd_logic);

endkey;

architecturekey_mimaofkeyis

signalm:

std_logic_vector(5downto0);

signalsa:

signaldd:

std_logic:

='

0'

;

signaldd1:

std_logic;

signalcount:

std_logic_vector(3downto0);

signalcount2:

signalcount3:

begin

c0:

process(resert,key_in1,key_in2,key_in3,key_in4,key_in5,key_in6)

begin

ifresert='

1'

thendd<

--全部清零

elseifkey_in1='

orkey_in2='

orkey_in3='

orkey_in4='

orkey_in5='

orkey_in6='

endif;

--只要有键按下,dd将为高电平不变

key_r<

=dd;

endprocessc0;

cc:

process(key_in5,key_in6,clk,resert)

ifclk'

eventandclk='

then

ifds='

then--保持ds='

持续5秒高电平5秒后产生低电平,第5秒为低电平

--按下键八5秒后读取密码

ifcount<

6then

key_read<

;

count<

=count+1;

elsecount<

=count;

endif;

ifcount=5thenkey_read<

elsecount<

="

0000"

key_read<

endprocesscc;

cc2:

process(key_in1,key_in2,clk,resert)

then--保持ds='

持续3秒高电平3秒后产生低电平,第3秒为低电平

--按下按下键八三秒后对错误复位

ifcount2<

4then

key_resert<

count2<

=count2+1;

elsecount2<

=count2;

ifcount2=3thenkey_resert<

elsecount2<

key_resert<

endprocesscc2;

c1:

process(key_in1,str,sa)--按键1输入

ifstr='

orsa(0)='

thenm(0)<

else

ifkey_in1'

eventandkey_in1='

=notm(0);

endprocessc1;

c2:

process(key_in2,str,sa)--按键2输入

ifstr='

orsa

(1)='

thenm

(1)<

ifkey_in2'

eventandkey_in2='

=notm

(1);

endprocessc2;

c3:

process(key_in3,str,sa)--按键3输入

orsa

(2)='

thenm

(2)<

else

ifkey_in3'

eventandkey_in3='

=notm

(2);

endprocessc3;

c4:

process(key_in4,str,sa)--按键4输入

orsa(3)='

thenm(3)<

ifkey_in4'

eventandkey_in4='

=notm(3);

endprocessc4;

c5:

process(key_in5,str,sa)--按键5输入

orsa(4)='

thenm(4)<

ifkey_in5'

eventandkey_in5='

=notm(4);

endprocessc5;

c6:

process(key_in6,str,sa)--按键6输入

orsa(5)='

thenm(5)<

ifkey_in6'

eventandkey_in6='

=notm(5);

endprocessc6;

v22:

process(resert,clk20)

ifclk20'

eventandclk20='

ifcount3=7thencount3<

=count3;

else

count3<

=count3+1;

sa<

000000"

ifcount3=5thensa<

111111"

elsesa<

elsecount3<

endprocessv22;

key_out<

=mand(notsa);

endkey_mima;

图4密码输入模块

密码输入模块仿真如下(图5):

3.3显示模块

1、本设计要求输入正确密码时,绿灯亮、红灯熄灭;

当输入错误密码时,5S后红灯亮绿灯灭,同时要求发出20S的报警。

为此我们设计发光二极管D7和D8分别表示红灯和绿灯,并用蜂鸣器作为报警电路。

2、LED显示电路的VHDL程序如下:

entityledis

port(r:

str:

str5:

ar:

endled;

architectureled_mimaofledis

signals1:

std_logic:

b1:

process(str,r,str5)

ifr'

eventandr='

thenifstr5='

thens1<

elses1<

endprocessb1;

ar<

=s1;

endled_mima;

图6LED显示模块

LED显示模块仿真如下(图7):

3、报警电路程序设计如下:

entitysoundis

port(str:

clk:

sound_out:

endsound;

architecturexd_soundofsoundis

signalss:

std_logic;

process(str,clk)--产生20报警电路,需要str为高电平20秒

then

ss<

=clk;

elsess<

sound_out<

=ss;

endprocess;

endxd_sound;

图8报警模块

报警模块仿真如下(图9):

3.4延时模块

1、针对本设计中要求的输入错误密码后5S报错和20S报警,我们设计了5S和20S的两个延时模块。

2、延时5S程序设计:

entitymcis

clk:

key_out:

endmc;

architecturemc_mimaofmcis

process(str,clk)

then--保持str为1,5秒高电平5秒后产生低电平,第6秒为低电平

6thenkey_out<

count<

ifcount=5thenkey_out<

endprocess;

endmc_mima;

图10延时5秒模块

延时5秒模块仿真如下(图11):

3、延时20S程序如下:

entitym20is

port(str:

endm20;

architecturem20_mimaofm20is

std_logic_vector(4downto0);

then--保持str为1,20秒高电平20秒后产生低电平,第21秒为低电平

21thenkey_out<

ifcount=20thenkey_out<

00000"

endm20_mima;

图12延时20秒模块

延时20秒模块仿真如下(图13):

3.5设置密码以及验证模块

1、中要求密码可以设置,为了更清晰的了解密码,我们除了设计密码设置键外,还设置了数码管显示设置好的密码。

该模块采用VHDL语言设计而成。

2、设置密码输入程序如下:

entityledwis

port(ee:

aw:

endledw;

architectureledw_mimaofledwis

process(str,ee,str5)

ifstr5'

eventandstr5='

ifee='

s1<

aw<

endledw_mima;

图14密码及验证模块

密码及验证模块仿真如下(图15):

3、密码电路程序如下:

LIBRARYieee;

USEIEEE.STD_LOGIC_1164.ALL;

entitymimais

PORT(clk_mima:

INSTD_LOGIC;

key:

INSTD_LOGIC_VECTOR(5downto0);

mima_out:

OUTSTD_LOGIC_VECTOR(5downto0));

endmima;

ARCHITECTUREoneOFmimaIS

signals:

begin

process(clk_mima,key)

ifclk_mima='

then

s<

=key;

elsenull;

mima_out<

=s;

endprocess;

endone;

4、密码校对电路程序设计如下:

entityxdis--密码校对

a:

instd_logic_vector(5downto0);

b:

endxd;

architecturexd_mimaofxdis

signalss:

process(a(0),a

(1),a

(2),a(3),a(4),a(5),str)

ifa=bthen

elsess<

endxd_mima;

图16密码校对模块

密码校对模块的仿真如下(图17):

4.系统仿真

将程序下载Cyclone系列芯片中,同时在EDA试验箱上进行硬件验证。

本文提出的电子密码锁由于采用VHDL语言设计,用一片FPGA实现,因而体积小,功耗低,稍加修改就可以改变密码的位数和输入密码的次数,具有较好的应用前景。

但由于结构还比较简单,有待进一步完善。

电子密码锁整个系统的仿真如图18

图18电子密码锁整个电路系统仿真图

5.结束语

通过两星期的紧张工作,最后完成了我的设计任务——基于VHDL语言的智能密码锁设计。

通过本次课程设计的学习,我深深的体会到设计课的重要性和目的性所在。

本次设计课不仅仅培养了我们实际操作能力,也培养了我们灵活运用课本知识,理论联系实际,独立自主的进行设计的能力。

它不仅仅是一个学习新知识新方法的好机会,同时也是对我所学知识的一次综合的检验和复习,使我明白了自己的缺陷所在,从而查漏补缺。

希望学校以后多安排一些类似的实践环节。

附录

主控制程序参考如下:

USEieee.std_logic_1164.all;

USEieee.std_logic_unsigned.all;

LIBRARYwork;

ENTITYlockIS

INSTD_LOGIC;

clk1:

key_1:

INSTD_LOGIC_VECTOR(5downto0);

green:

OUTSTD_LOGIC;

red:

sound_1:

xianshi:

display:

OUTSTD_LOGIC_VECTOR(5downto0);

key_tell:

OUTSTD_LOGIC_VECTOR(5downto0));

ENDlock;

ARCHITECTUREoneOFlockIS

componentled

PORT(r:

str:

str5:

ar:

OUTSTD_LOGIC);

endcomponent;

componentsound

PORT(str:

clk:

sound_out:

componentmc

key_out:

componentxd

a:

b:

componentmima

key

展开阅读全文
相关资源
猜你喜欢
相关搜索
资源标签

当前位置:首页 > 小学教育 > 小学作文

copyright@ 2008-2023 冰点文库 网站版权所有

经营许可证编号:鄂ICP备19020893号-2