




已阅读5页,还剩12页未读, 继续免费阅读
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
Vhdl短学期实验密码锁设计小组成员:04008230 李黎04008228 陈宗渊04008211 周炳宇一、课题描述:用于模仿密码锁的工作过程。完成密码锁的核心控制功能。二、功能要求:设计一个密码锁,平时处于等待状态。管理员可以设置或更该密码。如果不预置密码,密码缺省为“999999”。用户如果需要开锁,按相应的按键进入输入密码状态,输入6位密码,按下确定键后,若密码正确,锁打开,若密码错误,将提示密码错误,要求重新输入,三次输入都错误,将发出报警信号。报警后,只有管理员作相应的处理才能停止报警。用户输入密码时,若输入错误,在按下确定键之前,可以通过按取消键重新输入。正确开锁后,用户处理完毕后,按下确定键,系统回到等待状态。系统操作过程中,只要密码锁没有打开,如果60秒没有对系统操作,系统回到等待状态。注意:输入按键信号时必须一个按键一个按键输入,不得6个按键一起输入。三、设计流程:1结构框图:控制器比较器器计数器寄存器按键输入;复位(设置缺省密码);等待状态工作状态修改密码提醒错误及报警开锁恢复等待2模块设计: 控制模块:实现输入输出,实现等待工作的转换,实现开锁及报警; 比较模块:比较输入密码与正确密码寄存模块:存放密码计数及使能模块:(1)输入个数为6,多于无效自动忽略; (2)60s的空闲时间,无操作返回等待;(3)错误次数为3(4)进入工作状态,是能段即打开,直到进入等待。四、具体实现:控制模块:library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;entity ctrl isport(change,vers,keysign: in std_logic;ok,cancel: in std_logic;clk: in std_logic;result: in std_logic;wt: in std_logic;enable: out std_logic);end ctrl;architecture ctrl_behave of ctrl issignal sec : integer range 0 to 60;beginprocess(clk)beginif (clkevent and clk=1) thenif (vers=1) thenenable=1;end if;if (wt=1 and result=1) thenenable=0;sec=0;end if;if (change=0 and vers=0 and keysign=0 and ok=0 and cancel=0) thensec=sec+1;if (sec=59) thenenable=0;sec=0;end if;elsesec=0;end if;end if;end process;end ctrl_behave; 比较模块:library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;entity ver isport(dt1,dt2,dt3,dt4,dt5,dt6: in std_logic_vector(3 downto 0);cd1,cd2,cd3,cd4,cd5,cd6: in std_logic_vector(3 downto 0);vers: in std_logic;ready: in std_logic;clk: in std_logic;stopalarm: in std_logic;en: in std_logic;result: out std_logic;wrong: out std_logic;alarm: out std_logic);end ver;architecture ver_behave of ver issignal alarmnum : integer range 0 to 3;signal vering : std_logic;signal wronging: std_logic;beginprocess(clk)beginif (clkevent and clk=1) thenif (en=0) thenresult=0;end if;if (stopalarm=1) thenalarmnum=0;end if;if (wronging=1) thenwronging=0;vering=1;end if;if (alarmnum3) thenalarm=0;elsealarm=1;end if;if (vers=1) thenvering=1;end if;if (vering=1) thenif (ready=1) thenif (cd1=dt1 and cd2=dt2 and cd3=dt3 and cd4=dt4 and cd5=dt5 and cd6=dt6) thenresult=1;elseresult=0;wronging=1;if (alarmnum3) thenalarmnum=alarmnum+1;end if;end if;vering=0;end if;end if;elsif (clkevent and clk=0) thenif (wronging=1) thenwrong=1;elsif (wronging=0) thenwrong=0;end if;end if;end process;end ver_behave;寄存模块:library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;entity code isport(dt1,dt2,dt3,dt4,dt5,dt6: in std_logic_vector(3 downto 0);change: in std_logic;ready: in std_logic;ok: in std_logic;clk: in std_logic;result: in std_logic;reset: in std_logic;wt: out std_logic;cd1,cd2,cd3,cd4,cd5,cd6: out std_logic_vector(3 downto 0);end code;architecture code_behave of code issignal alarmnum : integer range 0 to 3;signal changing : std_logic;signal changed: std_logic;signal wting: std_logic;beginprocess(clk)beginif (clkevent and clk=1) thenif (ok=1 and changing=0 and result=1) thenwting=1;elsewting=0;end if;if (reset=1) thencd1=1001;cd2=1001;cd3=1001;cd4=1001;cd5=1001;cd6=1001;end if;if (change=1) thenchanging=1;end if;if (changing=1) thenif (ready=1) thenif (result=1) thencd1=dt1;cd2=dt2;cd3=dt3;cd4=dt4;cd5=dt5;cd6=dt6;wting=1;end if;changing=0;end if;end if;elsif (clkevent and clk=0) thenif (wting=1) thenwt=1;elsewt=0;end if;end if;end process;end code_behave;计数及使能模块:1library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;entity keyboard isport(a3,a2,a1,a0: in std_logic;a: out std_logic_vector(3 downto 0);k: in std_logic;keysign: out std_logic;clk: in std_logic);end keyboard;architecture keyboard_behave of keyboard isbeginprocess(clk)beginif (clkevent and clk=0) thena(3)=a3;a(2)=a2;a(1)=a1;a(0)=a0;keysign=k;end if;end process;end keyboard_behave;2library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;entity keyin isport(en: in std_logic;clk: in std_logic;a: in std_logic_vector(3 downto 0);keysign: in std_logic;ok: in std_logic;cancel: in std_logic;ver: in std_logic;ready: out std_logic;dt1,dt2,dt3,dt4,dt5,dt6: out std_logic_vector(3 downto 0);end keyin;architecture keyin_behave of keyin issignal count : integer range 0 to 7;signal cready : std_logic;beginprocess(en,clk,keysign)beginif (en=1) thenif (clkevent and clk=1) thenif (keysign=1 and count6) thencount=count+1;if (count=0) thendt1=a;elsif(count=1) thendt2=a;elsif(count=2) thendt3=a;elsif(count=3) thendt4=a;elsif(count=4) thendt5=a;elsif(count=5) thendt6=a;end if;end if;if (ver=1) thencount=0;end if;if (cancel=1) thencount=0;dt1=1111;dt2=1111;dt3=1111;dt4=1111;dt5=1111;dt6=1111;end if;if (ok=1) thencount=0;cready=1;elsecready=0;end if;elsif (clkevent and clk=0) thenif (cready=1) thenready=1;elseready=0;end if;end if;end if;end process;end keyin_behave;各个模块与设计存在出入,但基本要求都达到,主要是小组分工时,没有能完全按照模块分块设计计数器模块分散开没有单独形成模块具体信号意义见仿真Block图:计数器比较器寄存器控制器五、仿真:Reset:重置(缺省)A:输入k:判断有效输入OK:确认Cancel:取消Ver:进入工作(比较)Change:修改密码Clk:时钟信号Result:开锁En-out:使能Wrong:报错Alarm:报警Stopalarm:停止操作(管理员使用)1验证缺省密码为999999(reset键);2验证输入错误取消输入,重新输入(cancel键);3.验证60秒无操作自动返回等待界面(en-out和result归零);4.验证有效按键“k”,只有k为高电平有效;5验证用户操作完成,再次按ok键,自动返回等待键;6验证输入密码错误发出提示信号,连续三次输入错误,发出报警信号,只有按下stopalarm才能停止。7验证只取前六位输入,其它无效(再次验证无操作60自动返回等待)六、小组分工:组长李黎完成框架设计代码的编写,完成主要代码编写;陈宗渊完成代码的编写与完善及block图的连接;周炳宇完成代码的校错及仿真。小组一起完成实验报告,每人约占1/3。七、小结:在短学期差不多一个月的时间里,我们经过自己的努力用VHDL编写了密码锁,学到了很多的知识,当然也总结了很多的经验和教训。在程序编写的过程中,我们遇到很多困难,但是我们一点也没有放弃,坚持了下来,最终编写出了程序,完成基本的要求。我们总结,要学会使用图书馆等网络资源,当我们编写程序遇到一些无法理解得错误时,我们最终都可以从书上找到前人的经验和教训。因此我们认为不能闭门造车,要多学习别人的经验和教训。在编写程序之前要有一个清晰的框架,自己要实现哪些功能,以及要实现哪些功能得需要哪些方法来实现,只有在自己脑子里有一个很清晰的框架之后,然后再进行编写,我们在编写开始时由于没有一个清晰的框架,导致在程序编写到一半是才发现有些功能
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 代理出票合同标准文本
- 企业购买劳动合同标准文本
- 买卖佣金合同样本
- 中标服务费合同样本
- 委托代理进口合同二零二五年
- 含回购条款的股权转让协议二零二五年
- 公司给干股股份协议书
- 公司内部股权无偿赠与转让协议
- 二零二五版国家拆迁补偿协议
- 修补砂浆出售合同样本
- 2025年从大模型、智能体到复杂AI应用系统的构建报告-以产业大脑为例-浙江大学(肖俊)
- 厂房电费收租合同范例
- 2024年南京市事业单位专项招聘退役大学生士兵笔试真题
- 2025年浙江省金华市中考一模数学模拟试题(含答案)
- 增资扩股方案模板
- 鹅产业绿色循环发展-深度研究
- “三新”背景下高中文言文教学难点突破策略
- (完整版)Camtasia-Studio使用教程
- 供应商考核管理制度
- 监理月报(水利工程)
- 2025年军队文职考试《公共科目》试题与参考答案
评论
0/150
提交评论