




已阅读5页,还剩11页未读, 继续免费阅读
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
数字系统设计数字系统设计 课程设计报告课程设计报告 数字密码锁数字密码锁 专 业 08 级信息工程 姓 名 1 班 杨志忠 2 班 邓伟兴 2 班 邓鑫灏 一 一 题目要求题目要求 用 EasyFPGA030 开发套件实现密码锁的功能 扩展必要的硬件电路 完成 FPGA 实现密码锁 算法的程序代码设计 完成文档写作 格式参照文档写作规范和提供的参考范文 具体实 现的功能有 1 重置密码功能 能实现密码锁重新设置新密码 2 密码开锁功能 模拟出输入正确密码后 密码锁能顺利打开 利用实验板上的数码管显 示相应的成功开锁提示 3 输入清除功能 要求在输入密码的时候可以随时清除输入的密码重新输入 4 警报功能 要求实现密码开锁时 连续输入三次错误密码后 开启警报 用实验板的 蜂鸣器实现 二 二 设计方案 或设计分析 设计方案 或设计分析 1 系统结构 结合实际实验板的资源分配和考虑到数字密码锁的实现较为简易 故整个系统的设计根据 功能要求 将系统分为 keyread stating showing 三个进程 2 设计思路 利用实验本上的四个按键实现四个密码数列的输入以及密码输入的最终确认 这部分功能 的实现由进程keyread实现完成 利用实验本上四个拨码开关的不同组合区分密码锁的不同功能状态 包括密码重置 密码 重置清除 密码输入 密码输入清除 密码锁锁闭 这部分由进程 stating 实现 进程 stating 还实现了相应状态下 蜂鸣器 数码管 led 灯控制信号的输出以实现相应提示和 显示 进程 showing 根据进程 stating 产生的不同状态和控制信号 采用动态扫描方式实 现不同状态相应显示和提示 三 三 模块实现模块实现 1 keyread进程 keyread process clk code variable cnt integer range 0 to 2500000 begin if clk event and clk 1 then if cnt 2500000 then cnt 0 buffer code code else cnt cnt 1 end if key release not buffer code 3 and buffer code 2 and buffer code 1 and buffer code 0 end if end process 2 stating进程 stating process key release control hand lock led d8 led d7 ring variable cnt integer range 0 to 4 variable cnt1 integer range 0 to 3 variable code input std logic vector 15 downto 0 begin if control 0101 then led d7 0000 led d8 0000 ring 1 cntf 0 cnt 0 code store 0000000000000000 lock open 0 hand lock 0 we 0 elsif control 1100 then led d7 0000 led d8 0000 cntf 0 cnt 0 code input 0000000000000000 lock open 0 hand lock 0 we 0 elsif control 1010 then if hand lock 1 then hand lock 0 lock open 1 we 0 cnt1 0 ring 1 led d7 1111 led d8 1111 end if elsif control 1111 then led d7 0000 led d8 0000 cnt 0 cnt1 0 cntf 0 lock open 0 elsif key release event and key release 1 then if lock open 0 then if cnt 4 then cnt cnt 1 led d8 0000 code input code input 11 downto 0 cntfled d7led d7led d7led d7led d7lock open 0 hand lock 0 ring 1 we 0 code store code input led d8lock open 0 hand lock 0 led d8 0000 if cnt1 3 then if code store code input then cnt1 0 lock open 1 led d8 1111 ring 1 else cnt1 cnt1 1 if cnt1 1 then led d8 1000 elsif cnt1 2 then led d82 then ring 0 wenull end case end if end if end if led d led d8 alarmd0 11111111 d1 11111111 d2 11111111 d3 11111111 when 1 d0 00110000 d1 11111111 d2 11111111 d3 11111111 when 2 d0 00110000 d1 00110000 d2 11111111 d3 11111111 when 3 d0 00110000 d1 00110000 d2 00110000 d3 11111111 when 4 d0 00110000 d1 00110000 d2 00110000 d3 00110000 end case if lock open 1 then if cnt1 50000 then cnt1 0 led list list if list 1110 then led 7 00110010 list 1101 elsif list 1101 then led 7 00011001 list 1011 elsif list 1011 then led 7 00010011 list 0111 elsif list 0111 then led 7 00110000 list 1110 end if else cnt1 cnt1 1 end if elsif we 1 then if cnt 25000000 then cnt 0 led list list if list 1110 then led 7 11011111 list 1101 elsif list 1101 then led 7 11011111 list 1011 elsif list 1011 then led 7 11011111 list 0111 elsif list 0111 then led 7if cnt 25000000 then cnt 0 led list list if list 1110 then led 7 11011111 list 1101 elsif list 1101 then led 7 11011111 list 1011 elsif list 1011 then led 7 11011111 list 0111 elsif list 0111 then led 7if cnt1 50000 then cnt1 0 led list list if list 1110 then led 7 d0 list 1101 elsif list 1101 then led 7 d1 list 1011 elsif list 1011 then led 7 d2 list 0111 elsif list 0111 then led 7 d3 list 1110 end if else cnt1 cnt1 1 end if end case end if end if end process 4 整体源程序代码 library ieee use ieee std logic 1164 all use ieee std logic unsigned all entity lock is port clk in std logic code in std logic vector 3 downto 0 control in std logic vector 3 downto 0 led 7 out std logic vector 7 downto 0 led d out std logic vector 7 downto 0 led list out std logic vector 3 downto 0 alarm out std logic end entity architecture behave of lock is signal cntf integer range 0 to 4 0 signal buffer code std logic vector 3 downto 0 1111 signal code store std logic vector 15 downto 0 0111101111011110 signal lock open std logic signal hand lock std logic signal led d7 std logic vector 3 downto 0 signal led d8 std logic vector 3 downto 0 signal ring std logic 1 signal key release std logic signal we std logic begin keyread process clk code variable cnt integer range 0 to 2500000 begin if clk event and clk 1 then if cnt 2500000 then cnt 0 buffer code code else cnt cnt 1 end if key release not buffer code 3 and buffer code 2 and buffer code 1 and buffer code 0 end if end process stating process key release control hand lock led d8 led d7 ring variable cnt integer range 0 to 4 variable cnt1 integer range 0 to 3 variable code input std logic vector 15 downto 0 begin if control 0101 then led d7 0000 led d8 0000 ring 1 cntf 0 cnt 0 code store 0000000000000000 lock open 0 hand lock 0 we 0 elsif control 1100 then led d7 0000 led d8 0000 cntf 0 cnt 0 code input 0000000000000000 lock open 0 hand lock 0 we 0 elsif control 1010 then if hand lock 1 then hand lock 0 lock open 1 we 0 cnt1 0 ring 1 led d7 1111 led d8 1111 end if elsif control 1111 then led d7 0000 led d8 0000 cnt 0 cnt1 0 cntf 0 lock open 0 elsif key release event and key release 1 then if lock open 0 then if cnt 4 then cnt cnt 1 led d8 0000 code input code input 11 downto 0 cntfled d7led d7led d7led d7led d7lock open 0 hand lock 0 ring 1 we 0 code store code input led d8lock open 0 hand lock 0 led d8 0000 if cnt1 3 then if code store code input then cnt1 0 lock open 1 led d8 1111 ring 1 else cnt1 cnt1 1 if cnt1 1 then led d8 1000 elsif cnt1 2 then led d82 then ring 0 wenull end case end if end if end if led d led d8 alarmd0 11111111 d1 11111111 d2 11111111 d3 11111111 when 1 d0 00110000 d1 11111111 d2 11111111 d3 11111111 when 2 d0 00110000 d1 00110000 d2 11111111 d3 11111111 when 3 d0 00110000 d1 00110000 d2 00110000 d3 11111111 when 4 d0 00110000 d1 00110000 d2 00110000 d3 00110000 end case if lock open 1 then if cnt1 50000 then cnt1 0 led list list if list 1110 then led 7 00110010 list 1101 elsif list 1101 then led 7 00011001 list 1011 elsif list 1011 then led 7 00010011 list 0111 elsif list 0111 then led 7 00110000 list 1110 end if else cnt1 cnt1 1 end if elsif we 1 then if cnt 25000000 then cnt 0 led list list if list 1110 then led 7 11011111 list 1101 elsif list 1101 then led 7 11011111 list 1011 elsif list 1011 then led 7 11011111 list 0111 elsif list 0111 then led 7if cnt 25000000 then cnt 0 led list list if list 1110 then led 7 11011111 list 1101 elsif list 1101 then led 7 11011111 list 1011 elsif list 1011 then led 7 11011111 list 0111 elsif list 0111 then led 7if cnt1 50000 then cnt1 0 led list list if list 1110 then led 7 d0 list 1101 elsif list 1101 then led 7 d1 list 1011 elsif list 1011 then led 7 d2 list 0111 elsif list 0111 then led 7 d3 list 1110 end if else cnt1 cnt1 1 end if end case end if end if end process end behave 5 管脚分配图 6 程序实体图 四 四 仿真分析仿真分析 1 密码设置和密码输入 当 conrol 为 0111 表示为密码设置状态 coder 的数值表示所设密码为 0111 1011 1101 1110 最后一个 code 输入表示密码设置完毕 当control为1110表示为密码输入开锁状态 从图中可以看出 第一次输入为正确密码 故在第 5 次按键表示密码输入完毕时 lock open 变为了 1 表示锁已经打开了 2 密码输入错误 当输入三次错误密码后 警报响起 alarm 0 这种情况下即使再输入正
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 我的偶像人物描写(9篇)
- 描述公园美景写景作文10篇
- 某商超宣传策略规定
- 雨中的回忆描写一场雨的作文(15篇)
- 2025年初中化学九年级上册期中测试卷重点难点实战演练解析
- 2025年监理工程师职业能力测试卷:监理现场巡查与记录技巧试题集锦
- 2025年小学语文毕业升学考试全真模拟卷(文学名著阅读)之《西游记》人物关系分析试题
- 2025年建筑行业安全生产事故调查与分析试题库试卷
- 2025年激光治疗机项目提案报告
- 电力系统故障分析与排除试题及答案
- 病理生物安全管理制度
- 急性呼吸衰竭教学
- 土地执法知识课件
- 2025年护理管理学课程考试试题及答案
- 学习任务群下小学语文整本书阅读的实践研究
- 终端营销实战手册
- 毕业设计(论文)-自动展开晒衣架设计
- 2025至2030中国汽车微电机行业发展趋势分析与未来投资战略咨询研究报告
- 2025年内蒙古能源集团煤电板块所属单位招聘笔试参考题库含答案解析
- IP授权合作框架协议
- 人力资源许可证制度(服务流程、服务协议、收费标准、信息发布审查和投诉处理)
评论
0/150
提交评论