ImageVerifierCode 换一换
格式:DOCX , 页数:32 ,大小:460.72KB ,
资源ID:6061544      下载积分:10 金币
快捷注册下载
登录下载
邮箱/手机:
温馨提示:
快捷下载时,用户名和密码都是您填写的邮箱或者手机号,方便查询和重复下载(系统自动生成)。 如填写123,账号就是123,密码也是123。
特别说明:
请自助下载,系统不会自动发送文件的哦; 如果您已付费,想二次下载,请登录后访问:我的下载记录
支付方式: 支付宝    微信支付   
验证码:   换一换

开通VIP
 

温馨提示:由于个人手机设置不同,如果发现不能下载,请复制以下地址【https://www.zixin.com.cn/docdown/6061544.html】到电脑端继续下载(重复下载【60天内】不扣币)。

已注册用户请登录:
账号:
密码:
验证码:   换一换
  忘记密码?
三方登录: 微信登录   QQ登录  

开通VIP折扣优惠下载文档

            查看会员权益                  [ 下载后找不到文档?]

填表反馈(24小时):  下载求助     关注领币    退款申请

开具发票请登录PC端进行申请

   平台协调中心        【在线客服】        免费申请共赢上传

权利声明

1、咨信平台为文档C2C交易模式,即用户上传的文档直接被用户下载,收益归上传人(含作者)所有;本站仅是提供信息存储空间和展示预览,仅对用户上传内容的表现方式做保护处理,对上载内容不做任何修改或编辑。所展示的作品文档包括内容和图片全部来源于网络用户和作者上传投稿,我们不确定上传用户享有完全著作权,根据《信息网络传播权保护条例》,如果侵犯了您的版权、权益或隐私,请联系我们,核实后会尽快下架及时删除,并可随时和客服了解处理情况,尊重保护知识产权我们共同努力。
2、文档的总页数、文档格式和文档大小以系统显示为准(内容中显示的页数不一定正确),网站客服只以系统显示的页数、文件格式、文档大小作为仲裁依据,个别因单元格分列造成显示页码不一将协商解决,平台无法对文档的真实性、完整性、权威性、准确性、专业性及其观点立场做任何保证或承诺,下载前须认真查看,确认无误后再购买,务必慎重购买;若有违法违纪将进行移交司法处理,若涉侵权平台将进行基本处罚并下架。
3、本站所有内容均由用户上传,付费前请自行鉴别,如您付费,意味着您已接受本站规则且自行承担风险,本站不进行额外附加服务,虚拟产品一经售出概不退款(未进行购买下载可退充值款),文档一经付费(服务费)、不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。
4、如你看到网页展示的文档有www.zixin.com.cn水印,是因预览和防盗链等技术需要对页面进行转换压缩成图而已,我们并不对上传的文档进行任何编辑或修改,文档下载后都不会有水印标识(原文档上传前个别存留的除外),下载后原文更清晰;试题试卷类文档,如果标题没有明确说明有答案则都视为没有答案,请知晓;PPT和DOC文档可被视为“模板”,允许上传人保留章节、目录结构的情况下删减部份的内容;PDF文档不管是原文档转换或图片扫描而得,本站不作要求视为允许,下载前可先查看【教您几个在下载文档中可以更好的避免被坑】。
5、本文档所展示的图片、画像、字体、音乐的版权可能需版权方额外授权,请谨慎使用;网站提供的党政主题相关内容(国旗、国徽、党徽--等)目的在于配合国家政策宣传,仅限个人学习分享使用,禁止用于任何广告和商用目的。
6、文档遇到问题,请及时联系平台进行协调解决,联系【微信客服】、【QQ客服】,若有其他问题请点击或扫码反馈【服务填表】;文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“【版权申诉】”,意见反馈和侵权处理邮箱:1219186828@qq.com;也可以拔打客服电话:0574-28810668;投诉电话:18658249818。

注意事项

本文(吴超电子密码锁改过后.docx)为本站上传会员【xrp****65】主动上传,咨信网仅是提供信息存储空间和展示预览,仅对用户上传内容的表现方式做保护处理,对上载内容不做任何修改或编辑。 若此文所含内容侵犯了您的版权或隐私,请立即通知咨信网(发送邮件至1219186828@qq.com、拔打电话4009-655-100或【 微信客服】、【 QQ客服】),核实后会尽快下架及时删除,并可随时和客服了解处理情况,尊重保护知识产权我们共同努力。
温馨提示:如果因为网速或其他原因下载失败请重新下载,重复下载【60天内】不扣币。 服务填表

吴超电子密码锁改过后.docx

1、一、设计思想 本设计采用EDA技术和VHDL语言设计了一种按键输入密码并数码管回显,当输入正确密码时轰动绿灯亮、红灯熄灭表示开锁,而当输入错误密码时,红灯亮、绿灯熄灭表示关锁。根据系统设计要求,系统设计采用自顶向下的设计方法。 1.基本原理 在本实验中采用的是VHDL编程,通过文本编辑方式建立模块,通过原理图方式将生成的图形符号连接,然后再下载,进行硬件的仿真。密码锁要达到的功能为: 为达到密码锁的以上功能,可将电子密码锁分为以下几个模块:密码锁输入电路、密码锁控制电路、LED输出显示电路。 ⑴、密码输入:每按下一个数字键,就输入一个数值,并在显示器上显示出该数值。同时将先前输入的数

2、据依次左移一个数字位置。程序下载后系统进入原始状态(原始密码000000),按下键8发光二极管8(绿灯)亮、法官二极管7(红灯)灭。当要重新设置密码时,直接输入自己想要设置的密码并按下键8,持续5S,数码管8由0变为1,此时7段数码管1、2、3、4、5、6对应显示新设置的密码。当要输入密码时,按下键7,先将密码清零,再随机输入一组6位密码,假如密码正确,发光二极管8(绿灯)立即亮;反之如不正确,等待5S,发光二极管7(红灯)亮并由蜂鸣器发出20S的报警信号。 ⑵、密码清除:按下清除键可清除前面所有的输入值,清除成为“0000”。 ⑶、密码更改:按下更改键可将目前数据设定为新的密码。 ⑷、

3、密码上锁:按下上锁键可将密码锁上锁。 ⑸、密码解除:按下解除键首先检查输入的密码是否正确,密码正确即解锁。 2.设计框图 为达到密码锁的以上功能,可将电子密码锁分为以下几个模块:密码锁输入电路、密码锁控制电路、LED输出显示电路。和报警电路等四部分组成顶层设计采用原理图设计方式,系统的整体组装设计原理图如图1所示。 密 码 模 块 校 对 模 块 5S延时脉冲模块 红灯灭绿灯亮 绿灯灭红灯亮 20S报警 20延时脉冲模块 关锁 开锁 图1 系统整体组装设计原理图 二、设计步骤和调试过程 1、模块设

4、计和相应模块代码 (1)分频 由于要产生5秒、20秒的计时信号,故对系统时钟clk_1k进行分频来得到1Hz的时钟clk。其模块及部分程序如下: 图2 分频模块 process(clk_1k) variable count:std_logic_vector(9 downto 0); begin if(clk_1k'event and clk_1k='1') then count:=count+1; end if; clk<=count(9); end process; 仿真波形如下: 图3 分频仿真图 (2) 设置密码 本模块主要是将设

5、置的密码锁存到中间变量ram中去,同时控制灯的变化,由于这里的灯并不能作为最终的输出,所以这里先用led_r_temp1、led_r_temp2代替。其模块及部分程序如下: 图4 设置密码模块 process(enter1,set) begin if(enter1'event and enter1='1') then if(set='0') then ram<=datain; led_r_temp1<='1';led_g_temp1<='0'; else led_r_temp1<='0';led_g_temp1<='0'; end if; end if; end pr

6、ocess; 仿真波形如下: 图5 设置密码仿真图 (3) 输入密码时第一个按键判断信号 本模块主要在密码输入下,当第一个按键按下时产生一个judge信号(高电平有效),其模块及部分程序如下: 图6 判断信号模块 process(set,clk_1k,datain) begin if(clk_1k'event and clk_1k='1') then if(set='0') then judge<='0'; elsif(set='1') then if((datain(0) or datain(1) or datain(2) or dat

7、ain(3))='0') then judge<='0'; els if((datain(0) or datain(1) or datain(2) or datain(3))='1') then judge<='1'; else judge<='0'; end if; end if; end if; end process; 仿真波形如下: 图7 判断信号仿真图 从仿真波形上看,当按键按下后judge信号由0变为1,但是当按键重新弹回0时,judge信号又回到0,所以需对judge高电平信号进行锁

8、存: 图8 锁存模块 signal temp:std_logic:='0'; begin process(judge) begin if(judge'event and judge='1') then temp<='1'; end if; end process; 仿真波形如下: 图9 锁存模块仿真图 (4) 5秒计时信号 该模块是产生一个5秒计时的信号state,5秒期间为‘1’,当5秒时间过去后state变为‘0’,并作为报警信号。其模块及部分程序

9、如下: 图10 5秒计时信号模块 signal count_5:std_logic_vector(2 downto 0); signal state1:std_logic; begin process(clk) begin if(clk'event and clk='1') then if(judge_load='1') then ——第一个按键按下 if(count_5="101") then count_5<="101"; else count_5<=count_5+1; end if; end if; end if; end pr

10、ocess; process(count_5) begin case count_5 is when "000"=>state1<='1'; when "001"=>state1<='1'; when "010"=>state1<='1'; when "011"=>state1<='1'; when "100"=>state1<='1'; when others=>state1<='0'; end case; end process; 确保在set置为‘1’而第一个按键没有按下时,state为高电平,即刚进入输入密码状态而第一个按键没有按下时state为高电

11、平。 仿真波形如下: 图11 5秒计时模块仿真图 根据仿真波形可以看出,set为‘0’时设置密码,当set为‘1’时,在judge_load(按键识别信号)为‘0’的情况下,state为‘1’,保证下面将要提及的报警模块不会工作,而只有当judge_load为‘1’,且5秒过后state变为‘0’时才有可能发出报警信号(密码输错的情况下)。 (5) 开锁信号的产生 本模块主要是对输入的密码进行判断,一旦密码输入正确,产生一个开锁信号unlock(高电平有效)。其模块与部分程序如下: 图12 开锁信号模块 process

12、enter2) begin if(enter2'event and enter2='1') then ——输入密码确认 if(set='1') then if(state='1') then ——5秒期间 if(datain=ram) then unlock<='1'; ——开锁信号 else unlock<='0'; end if; end if; end if; end if; end process; 输入正确密码仿真波形: 图13 开锁信号仿真图 输入错误密码仿真波形: 图14 开锁信号仿

13、真图 (6) 报警模块 本模块主要是在5秒限制时间结束时,如果还没有开锁,就产生报警信号。即长达20秒的声光信号。这里的报警信号指示灯用led_r_temp3表示,扬声器用speaker_temp2表示。其模块及部分程序如下: 图15 报警模块 signal count_20:std_logic_vector(4 downto 0); signal temp:std_logic; begin process(clk) begin if(clk'event and clk='1') then if(set='0')then t

14、emp<='0'; elsif(set='1') then if(state='0') then if(count_20="10100") then count_20<="10100";temp<='0'; else count_20<=count_20+1;temp<='1'; speaker_temp2<=clk_1k; end if; end if; end if; end if; end process; 仿真波形如下: 图16 报警模块仿真图 可见当state由‘1’变为‘0’且没有unlock信号时,输出20秒的声光信号以示报警。

15、 (7) 开锁信号控制指示灯变化模块 本模块是实现当开锁信号产生时,相应的指示灯由红亮绿灭变成红灭绿亮。这里同样先用led_r_temp2、led_g_temp2代表红灯和绿灯。其模块及部分程序如下: 图17 指示灯变化模块 process(clk_1k,state) begin if(clk_1k'event and clk_1k='1') then if(state='1') then if(unlock='1') then led_r_temp2<='0';led_g_temp2<='1'; else led_r_temp

16、2<='1';led_g_temp2<='0'; end if; end if; end if; end process; 仿真波形如下: 图18 指示灯变化仿真图 (8) 开锁信号产生2秒提示音模块 当开锁信号产生时,扬声器发出两秒的提示音。这里用speaker_temp2代替。其模块及部分程序如下: 图19 2秒提示音模块 signal count_2:std_logic_vector(1 downto 0); signal temp:std_logic; begin process(clk) begin

17、 if(clk'event and clk='1') then ——1秒Hz if(unlock='1') then if(count_2="10") then count_2<="10";temp<='0'; else count_2<=count_2+1;temp<='1'; end if; end if; end if; end process; 仿真波形如下: 图20 2秒提示音仿真图 (9) 指示灯综合输出模块 本模块主要是将led_r_temp1、led_g_temp1、led_r_temp2、led_g_temp2经过条件判断选择输出

18、设置密码(set=‘0’)时输出led_r_temp1、led_g_temp1,输入密码(set=‘1’)时输出led_r_temp2、led_g_temp2。其模块及部分程序如下: 图21 指示灯综合输出模块 if(set='0') then led_r<=led_r_temp1; led_g<=led_g_temp1; else led_r<=led_r_temp2; led_g<=led_g_temp2; end if; 仿真波形如下: 图22 指示灯

19、综合输出仿真图 (10)扬声器综合输出模块 本模块主要是将报警音speaker_temp1和开锁提示音speaker_temp2经过条件选择判断输出,set=‘0’时,输出为‘0’;当set=‘1’且unlock=‘0’时输出speaker_temp1,当unlock=1时,输出speaker_temp2。其模块及部分程序如下: 图23 扬声器综合输出模块 if(set='0') then speaker<='0'; elsif(unlock='1') then speaker<=speaker_temp1; else speaker

20、<=speaker_temp2; end if; 仿真波形如下: 图24 扬声器综合输出仿真图 2、仿真及仿真结果分析 将程序下载Cyclone系列芯片中,同时在EDA试验箱上进行硬件验证。本文提出的电子密码锁由于采用VHDL语言设计,用一片FPGA实现,因而体积小,功耗低,稍加修改就可以改变密码的位数和输入密码的次数,具有较好的应用前景。但由于结构还比较简单,有待进一步完善。 输入错误密码: 图25 输入错误密码仿真图 输入正确密码: 图26 输入正确密码仿真图 3、实验调试结果 密码锁的控制电路是

21、整个电路的控制中心,主要完成对数字按键输入和功能按键输入的响应控制。 ⑴、数字按键输入的响应控制 如果按下数字键,第一个数字会从显示器的最右端开始显示,此后每新按下一个数字时,显示器上的数字必须左移一位,一边将新的数字显示出来。 假如要更改输入的数字,可以按倒退按键来清除前一个输入的数字,或者按清除键清除所有输入的数字,再重新输入四位数。 由于这里设计的是一个四位的电子密码锁,所以当输入的数字键超过四个时,电路不予理会,而且不再显示第四个以后的数字。 ⑵、功能按键输入响应控制 清除键:清除所有的输入数字,即做归零动作。 上锁键:按下此键时可将密码锁的门上锁(上锁前必须先设定一个四

22、位的电子密码)。 电子密码锁的整合和验证。 三、结论及心得体会 本课程设计主要是基于VHDL文本输入法设计电子密码锁,随着社会物质财富的日益增长,安全防盗已成为全社会关注的问题。基于EDA技术设计的电子密码锁,以其价格便宜、安全可靠、使用方便,受到了人们的普遍关注。而以现场可编程逻辑器件(FPGA)为设计载体,以硬件描述语言(VHDE)为主要表达方式,以QuartusⅡ开发软件和GW48EDA开发系统为设计工具设计的电子密码锁,由于其能够实现数码输入、数码清除、密码解除、密码更改、密码上锁和密码解除等功能,因此,能够满足社会对安全防盗的要求。 通过本次课程设计我收获颇多,刚开始拿到题目

23、后,没有一个明确的方案,查了很多资料,大部分都用到了矩阵键盘,并且比较复杂,后来根据实验箱设计了该方案。这就要求我们要根据现实的条件去设计适合自己硬件的程序。 在这次课程设计中,最头疼的问题就是各个模块仿真正确后,最后的顶层文件却并没有达到预期的效果,很是令人灰心,并无从查找。后来我试着把每一个模块逐渐添加到顶层中,每添加一个就仿真一下,并留意中间信号量的变化,根据波形去调试相应的模块,最终得到了想要的波形。当然期间遇到了很多的困难,通过向老师同学请教,并积极思考,最终这些难题都得到了解决,这也让我懂得了团队的重要性。

24、 参考资料: [1] 潘松著.EDA技术实用教程(第二版). 北京:科学出版社,2005. [2] 康华光主编.电子技术基础 模拟部分. 北京:高教出版社,2006. [3] 阎石主编.数字电子技术基础. 北京:高教出版社,2003. [4] 谭会生、瞿遂春.EDA技术综合应用实例与分析.西安电子科技大学出版社,2004 [5] 高有堂.EDA技术及应用实践.清华大学出版社,2006 [6]候伯亨著.VHDL硬件描述语言与数字逻辑电路设计[M].西安:西安电子科技大学出版社,2009. [7]张昌凡著.可编程逻辑器件及VHDL设计技术[M].广州:华南理工大学出版

25、社,2001. [8]曹昕燕、周凤臣等.EDA技术实验与课程设计.清华大学出版社,2006 源程序: library ieee; use ieee.std_logic_1164.all; use ieee.std_logic_unsigned.all; entity fenpin is port(clk_1k:in std_logic; clk:out std_logic); end; architecture rtl of fenpin is begin process(c

26、lk_1k) variable count:std_logic_vector(9 downto 0); begin if(clk_1k'event and clk_1k='1') then count:=count+1; end if; clk<=count(9); end process; end rtl; library ieee; use ieee.std_logic_1164.all; use ieee.std_logic_unsigned.all; entity code_set is port(set,enter1:in std_logic; d

27、atain:in std_logic_vector(3 downto 0); ram:out std_logic_vector(3 downto 0); led_r_temp1,led_g_temp1:out std_logic); end; architecture rtl of code_set is begin process(enter1,set) begin if(enter1'event and enter1='1') then if(set='0') then ram<=datain; led_r_temp1<='1';led_g_tem

28、p1<='0'; else led_r_temp1<='0';led_g_temp1<='0'; end if; end if; end process; end; library ieee; use ieee.std_logic_1164.all; use ieee.std_logic_unsigned.all; entity judge is port(clk_1k,set:in std_logic; datain:in std_logic_vector(3 downto 0); judge:out std_logic); end; archite

29、cture rtl of judge is begin process(set,clk_1k,datain) begin if(clk_1k'event and clk_1k='1') then if(set='0') then judge<='0'; elsif(set='1') then if((datain(0) or datain(1) or datain(2) or datain(3))='0') then judge<='0'; elsif((datain(0) or datain(1) or datain(2) or datain(3))='1'

30、) then judge<='1'; else judge<='0'; end if; end if; end if; end process; end; library ieee; use ieee.std_logic_1164.all; use ieee.std_logic_unsigned.all; entity judge_load is port(judge:in std_logic; judge_load:out std_logic); end; architecture rtl of judge_load is signal tem

31、p:std_logic:='0'; begin process(judge) begin if(judge'event and judge='1') then temp<='1'; end if; end process; judge_load<=temp; end; library ieee; use ieee.std_logic_1164.all; use ieee.std_logic_unsigned.all; entity time_5 is port(clk,judge_load,set:in std_logic; state:out std_lo

32、gic); end; architecture rtl of time_5 is signal count_5:std_logic_vector(2 downto 0); signal state1:std_logic; begin process(clk) begin if(clk'event and clk='1') then if(judge_load='1') then if(count_5="101") then count_5<="101"; else count_5<=count_5+1; end if; end if;

33、 end if; end process; process(count_5) begin case count_5 is when "000"=>state1<='1'; when "001"=>state1<='1'; when "010"=>state1<='1'; when "011"=>state1<='1'; when "100"=>state1<='1'; when others=>state1<='0'; end case; end process; state<=state1 and set; end; library ieee; u

34、se ieee.std_logic_1164.all; use ieee.std_logic_unsigned.all; entity unlock is port(set,enter2,state:in std_logic; datain,ram:in std_logic_vector(3 downto 0); unlock:out std_logic); end; architecture rtl of unlock is begin process(enter2) begin if(enter2'event and enter2='1') then if(s

35、et='1') then if(state='1') then if(datain=ram) then unlock<='1'; else unlock<='0'; end if; end if; end if; end if; end process; end rtl; library ieee; use ieee.std_logic_1164.all; use ieee.std_logic_unsigned.all; entity unlock_led is port(state,unlock,clk_1k:in std_l

36、ogic; led_r_temp2,led_g_temp2:out std_logic); end; architecture rtl of unlock_led is begin process(clk_1k,state) begin if(clk_1k'event and clk_1k='1') then if(state='1') then if(unlock='1') then led_r_temp2<='0';led_g_temp2<='1'; else led_r_temp2<='1';led_g_temp2<='0'; end if; end

37、 if; end if; end process; end; library ieee; use ieee.std_logic_1164.all; use ieee.std_logic_unsigned.all; entity unlock_sound is port(clk,unlock,clk_1k:in std_logic; speaker_temp1:out std_logic); end; architecture rtl of unlock_sound is signal count_2:std_logic_vector(1 downto 0); sig

38、nal temp:std_logic; begin process(clk) begin if(clk'event and clk='1') then if(unlock='1') then if(count_2="10") then count_2<="10";temp<='0'; else count_2<=count_2+1;temp<='1'; end if; end if; end if; end process; speaker_temp1<=clk_1k and temp; end; library ieee; use iee

39、e.std_logic_1164.all; use ieee.std_logic_unsigned.all; entity alert is port(state,clk,clk_1k,set,unlock:in std_logic; led_r_temp3,speaker_temp2:out std_logic); end; architecture rtl of alert is signal count_20:std_logic_vector(4 downto 0); signal temp:std_logic; begin process(clk) begin

40、 if(clk'event and clk='1') then if(set='0')then temp<='0'; elsif(set='1') then if(state='0') then if(count_20="10100") then count_20<="10100";temp<='0'; else count_20<=count_20+1;temp<='1'; end if; end if; end if; end if; end process; led_r_temp3<=temp and clk and (not unlock

41、); speaker_temp2<=temp and clk_1k and (not unlock); end; library ieee; use ieee.std_logic_1164.all; entity led is port(led_r_temp1,led_r_temp2,led_g_temp1,led_g_temp2, set:in std_logic; led_r,led_g:out std_logic); end; architecture rtl of led is begin process(set) begin if(set='0') t

42、hen led_r<=led_r_temp1; led_g<=led_g_temp1; else led_r<=led_r_temp2; led_g<=led_g_temp2; end if; end process; end; library ieee; use ieee.std_logic_1164.all; entity speaker is port(unlock,speaker_temp1,speaker_temp2,set:in std_logic; speaker:out std_logic); end; architecture rtl of speaker is begin process(unlock) begin if(set='0') then speaker<='0'; elsif(unlock='1') then speaker<=speaker_temp1; else speaker<=speaker_temp2; end if; end process; end;

移动网页_全站_页脚广告1

关于我们      便捷服务       自信AI       AI导航        抽奖活动

©2010-2026 宁波自信网络信息技术有限公司  版权所有

客服电话:0574-28810668  投诉电话:18658249818

gongan.png浙公网安备33021202000488号   

icp.png浙ICP备2021020529号-1  |  浙B2-20240490  

关注我们 :微信公众号    抖音    微博    LOFTER 

客服