EDA考试设计报告—电子锁码器_第1页
EDA考试设计报告—电子锁码器_第2页
EDA考试设计报告—电子锁码器_第3页
EDA考试设计报告—电子锁码器_第4页
EDA考试设计报告—电子锁码器_第5页
已阅读5页,还剩23页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

广广 东东 海海 洋洋 大大 学学 EDAEDA 考试设计报告考试设计报告 调研题目 电子锁码器电子锁码器 院系班级 信息学院电子系电子信息学院电子系电子 10811081 班 班 小组成员 袁伟龙袁伟龙 指导教师 郭晓云 郭晓云 时 间 2011 5 142011 5 14 联系方式6666 ywl050511 ywl050511 评阅成绩 电子锁码器 Electronic lock transcoder abstract in response to the requirements of the test subjects teachers do design This design can realize the eight decimal number lock code lock within a output that can signal high level effective key words lock code decimal make can 摘要 为响应科目老师对考试的要求而做的设计 本设计能实现八位 十进制数以内的锁码 锁定一个输出使能信号 高电平有效 关键词 锁码 十进制 使能 引言引言 该锁码器分主状态分三个 待机状态 密码状态 结束状态 密码状态再 分三个次状态 输入状态 修改状态 运行状态 能够设置 8 位以内十进制数 的任何密码 每个状态都有不同的状态灯显示 当输入密码正确可以选择改变 密码或者调至运行状态输出一个使能信号 正文正文 一 待机状态 待机状态中 除输入正确状态灯外的四个状态灯显示为 0001 当使用者 拨动回车键 enter 上升沿有效 使 go 信号置 1 锁码器会从待机状态进入 密码状态 进行输码 改码等功能 二 密码状态 密码状态可用的前提是 go 信号为高电平 且密码输入状态立即可用 1 密码输入状态 密码输入状态的四个状态灯显示为 0010 当状态灯这样显示时使用者可 以输入想要输入的八位以内的十进制数然后拨动回车键 当输入的临时数 temp password 等于已存储的密码 password 时 正确输入状态灯亮 当 输入的临时数不等于已存储的锁定密码 正确输入状态灯不亮且立即跳至主状 态中的结束状态 当正确输入状态灯亮时 有两种选择 拨动回车键调至运行状态 拨 动改变键 change password 上升沿有效 进入密码修改状态 2 密码修改状态 密码修改状态的四个状态灯显示为 0100 这是正确输入状态灯依然在亮 当状态灯这样显示时使用者可以输入想要的八位以内的十进制数 当输入完成 时 使用者有两个选择 拨动改变键 把已输入的数存储为密码 拨动回 车键 直接进入运行状态 因为正确输入状态灯依然亮 正确输入仍然有效 当使用者觉得所修改的密码不合适情况下需要用到 当使用者输入完成 并拨动改变键把想要的密码存储完后 拨动回车键就 可进入运行状态 只要正确输入状态灯亮时 拨动回车键都能是锁码器进入运 行状态 3 运行状态 运行状态的四个状态灯显示为 1000 这时正确输入状态灯已熄灭 当锁 码器处于运行状态时 锁定的输出使能信号为 1 当使用者觉得已经完成运 行时拨动回车键就能使锁码器进入主状态中的结束状态 并使输出使能信号 go 信号置 0 且使次状态回到输入状态 三 结束状态 结束状态没有任何操作 会有一个简单的流水灯效果 倒数一段不长的时 间后自动返回待机状态 四 结束语四 结束语 在设计基本完成时 还存在很多细节上的问题 例如在正确输入之后想要 进入改变密码状态而未拨动改变键时 如果拨动数字选项键 会使到进入改变 状态后临时数的初始值不为空 全 0 虽然比较繁琐 不过经过一步步耐心的 在 modelsim 仿真验证后 基本上已经能让使用者正常 方便的使用该锁码器了 由于 de2 板上的开关存在严重的抖动现象 所以该锁码器中除了电平触发的复 位键外 其他全部使用到的开关都带有去抖动功能 最后 感谢郭晓云老师的 悉心指导 参考文献 EDA 技术与应用 张建 邓桃丽 邓锐 朱旭东 编著 单片机技术及系统设计 周美娟 肖来胜 编著 源程序 模块名称 程序包模块 模块功能 设置设计中使用到的两个类型 library ieee use ieee std logic 1164 all packageMy package is type state1 is standby state password state end state type state2 is input state change state run state end My package 模块名称 待机状态 密码输入准备状态 结束状态转换 模块功能 在待机状态下按一下回车键进入密码输入准备状态 在密码输入准备状态下发出一个 complete 的信号进入结束状态 结束状态中自动计数一秒后回到待机状态 library ieee use ieee std logic 1164 all use work My package all entity Standby password end transition is port clk in std logic 时钟输入 reset in std logic 复位键 enter in std logic 回车键 complete in std logic 完成运行信号 lkd state buffer state1 模块状态信号 go out std logic 密码输入模块准许信号 end Standby password end transition architecture behavior of Standby password end transition is signal starting std logic 0 待机到密码输入准备状态的允许信号 signal finishing std logic 0 密码输入准备状态到结束状态的允许信号 signal ending std logic 0 结束状态到待机状态的的允许信号 signal count integer range 0 to 49999999 0 计数器 signal count delay integer range 0 to 999999 0 signal start std logic 0 begin 进程名称 三状态转换控制进程 进程功能 在不同的准许信号下三状态转换 process reset clk starting finishing lkd state begin if reset 1 then lkd state 待机状态的处理 if starting 1 then lkd state password state else lkd state 密码准备状态的处理 if finishing 1 then lkd state end state else lkd state 结束状态的处理 if ending 1 then lkd state standby state else lkd state end state end if end case end if end process 进程名称 starting 允许信号的控制 进程功能 starting 允许信号的控制 附去抖动 process enter lkd state reset begin if reset 1 then start 0 elsif lkd state standby state then if rising edge enter then start 1 end if else start 0 end if end process process clk start count delay enter begin if rising edge clk then if start 1 then if count delay 999999 then count delay count delay 1 elsif enter 1 then starting 1 else starting 0 end if else count delay 0 starting 0 end if end if end process 进程名称 go 信号的控制 进程功能 go 信号的控制 process lkd state begin if lkd state password state then go 1 else go 0 end if end process 进程名称 finishing 信号的控制 进程功能 finishing 信号的控制 process lkd state complete begin if lkd state password state then if rising edge complete then finishing 1 end if else finishing 0 end if end process 进程名称 ending 信号的控制 进程功能 ending 信号的控制 process lkd state clk reset count begin if rising edge clk then if lkd state end state then if count 49999999then count count 1 else count 0 ending 1 end if else ending 0 count 0 end if end if end process end behavior 模块名称 解码锁码 模块功能 按回车键 若密码输入正确可选择改变密码或直接运行 run 按回车键跳结束状态 end state 不正确转至结束状态 锁定新密码后按回车键跳到运行状态 按回车键调至借宿状态 library ieee use ieee std logic 1164 all use work My package all entity Unlock is port clk in std logic 时钟输入 change password in std logic 改变密码键 上升沿有效 enter in std logic 回车键 上升沿有效 reset in std logic 复位开关 高电平电平有效 run out std logic 运行允许信号 高电平有效 Standby password end transition 模块信号 go in std logic 密码输入模块准许信号 complete out std logic 运行完毕信号 临时密码模块用信号 password allow out std logic 密码输入允许 clr t out std logic 临时密码清零信号 ok buffer std logic 回车键信号 change buffer std logic change password 信号 count pn enable out std logic count pn 使能信号 set count pn out std logic count pn 置数信号 password buffer std logic vector 31 downto 0 设定的密码 temp password in std logic vector 31 downto 0 临时密码 p state buffer state2 Unlock 状态信号 correct input in std logic 密码输入正确信号 d complete in std logic complete 控制信号 end Unlock architecture behavior2 of Unlock is signal clr o std logic 0 ok 清零信号 signal clr c std logic 1 change 清零信号 signal clr cpl std logic 1 complete 清零 signal set cpl std logic 0 complete 置数 signal pass word std logic vector 31 downto 0 00000000000000000000000000000000 过渡密码 signal count delay1 integer range 0 to 999999 0 signal count delay2 integer range 0 to 999999 0 signal oo std logic 0 signal clr oo std logic 0 signal cc std logic 0 signal clr cc std logic 0 begin 进程名称 输入状态 改变状态 运行状态转换 进程功能 输入状态 改变状态 运行状态的控制 处理 process clk reset p state go correct input change ok temp passwor d begin if rising edge clk then if reset 1 then 复位 p state input state clr cpl 1 set cpl 0 clr t 1 run 0 pass word 00000000000000000000000000000000 count pn enable 0 set count pn 输入 状态的处理 run 0 clr cpl 0 set cpl 0 count pn enable 1 set count pn 0 clr t 0 if correct input 1 then count pn enable 0 set count pn 1 if ok 1 then p state run state clr t 1 set count pn 0 elsif change 1 then p state change state set count pn 0 clr t 改变 状态的处理 clr t 0 count pn enable 1 if ok 1 then p state run state clr t 1 count pn enable 0 elsif change 1 then pass word temp password if ok 1 then p state run state clr t 1 count pn enable 运行状 态的处理 run 1 clr t 0 if ok 1 then run 0 clr cpl 0 set cpl 1 p state input state clr t 1 end if end case else go 不等 于 1 时的处理 run 0 clr cpl 1 set cpl 0 p state input state count pn enable 0 set count pn 0 end if end if end process 进程名称 ok 信号的控制 进程功能 通过回车键控制 ok 信号置 1 通过 clr o 置零 附去抖动 process enter reset clr oo go begin if reset 1 then oo 0 elsif clr oo 1 then oo 0 elsif go 1 then if rising edge enter then oo 1 end if end if end process process clk clr o oo count delay1 enter begin if rising edge clk then if go 1 then if clr o 1 then ok 0 clr o 0 elsif oo 1 then if count delay1 999999 then count delay1 count delay1 1 elsif enter 1 then ok 1 clr o 1 clr oo 1 else ok 0 clr o 1 clr oo 1 end if else count delay1 0 clr o 0 clr oo 0 end if else ok 0 clr o 0 clr oo 0 end if end if end process 进程名称 complete 信号的控制 进程功能 complete 信号的控制 process clr cpl set cpl clk d complete begin if rising edge clk then if clr cpl 1 then complete 0 elsif set cpl 1 then complete 1 else complete d complete end if end if end process 进程名称 password allow 信号的控制 进程功能 password allow 信号的控制 process p state reset begin if reset 1 then password allow 0 elsif p state run state then password allow 0 else password allow 1 end if end process 进程名称 change 信号的控制 进程功能 change 信号的控制 附去抖动 process reset change password clr cc begin if reset 1 then cc 0 elsif clr cc 1 then cc 0 elsif rising edge change password then cc 1 end if end process process clk clr c cc count delay2 change password begin if rising edge clk then if clr c 1 then change 0 clr c 0 elsif cc 1 then if count delay2 999999 then count delay2 count delay2 1 elsif change password 1 then change 1 clr cc 1 clr c 1 else change 0 clr cc 1 clr c 1 end if else count delay2 0 clr cc 0 clr c 0 end if end if end process 进程名称 密码 password 的控制 进程功能 密码 password 的控制 process reset pass word begin if reset 1 then password 00000000000000000000000000000000 else password pass word end if end process end behavior2 模块名称 临时密码模块 模块功能 根据数字输入模块送来的 option code 产生临时密码 并对 Unlock 模块及 Numeric input 模块中信号进行控制 处理 library ieee use ieee std logic 1164 all use work My package all entity Temp password is port reset clk go in std logic Unlock 模块用信号 password allow in std logic clr t in std logic ok in std logic change in std logic count pn enable in std logic set count pn in std logic password in std logic vector 31 downto 0 temp password buffer std logic vector 31 downto 0 p state in state2 correct input out std logic d complete out std logic Numeric input 模块用信号 temp no in std logic option code in std logic vector 3 downto 0 d temp no out std logic clr temp no out std logic clr n out std logic Display 模块用信号 count pn buffer integer 临时密码位数计数信号 end Temp password architecture behavior of Temp password is signal clr tt std logic 0 临时密码清零信号 signal set correct input std logic 0 correct input 置位信号 signal clr count pn std logic 0 correct input 清零信号 signal set clr temp no std logic 0 clr temp no 置位信号 begin 进程名称 p state 处于 input state 或 change state 时的数据处理 进程功能 p state 处于 input state 或 change state 时的数据处理 process reset ok clk temp no go password allow p state temp passw ord password begin if rising edge clk then if reset 1 then correct input 0 d complete 0 d temp no 0 clr tt 1 elsif go 1 then if password allow 1 then if ok 1 then if p state input state then if temp password password then correct input 1 else d complete 1 clr tt 1 clr count pn 1 end if end if else d temp no 1 d complete 0 end if else d temp no 0 correct input 0 d complete 0 clr count pn 1 end if else correct input 0 d complete 0 d temp no 0 clr tt 0 clr count pn 0 end if end if end process 进程名称 密码输入 进程功能 拨动开关改变临时密码并产生相应的信号处理 process clr t clr tt count pn temp no clk go password allow begin if rising edge clk then if clr t 1 then temp password 00000000000000000000000000000000 elsif clr tt 1 then temp password 00000000000000000000000000000000 elsif go 1 then if password allow 1 then if temp no 1 then if count pn 8 then temp password temp password 27 downto 0 set clr temp no 1 clr n 1 else set clr temp no 1 clr n 1 end if else set clr temp no 0 clr n 0 end if else clr n 1 end if else clr n 1 end if end if end process 进程名称 密码输入位数处理 进程功能 密码输入位数处理 上限为八 并产生相应的信号处理 process count pn clr count pn clk temp no reset count pn enable s et count pn begin if rising edge clk then if reset 1 then count pn 0 elsif clr count pn 1 then count pn 0 elsif count pn enable 1 then if temp no 1 then if count pn 8 then count pn count pn 1 end if end if elsif set count pn 1 then count pn 9 else count pn 0 end if end if end process 进程名称 clr temp no 信号的控制 进程功能 clr temp no 信号的控制 给 clr temp no 加一个复位 process set clr temp no reset begin if reset 1 then clr temp no 0 elsif set clr temp no 1 then clr temp no 1 else clr temp no 0 end if end process end behavior 模块名称 数字输入模块 模块功能 拨动 0 9 号开关 输出 0 9 相应的四位二进制码 并处理 temp no 控制信号 library ieee use ieee std logic 1164 all entity Numeric input is port clk in std logic reset in std logic 复位开关 高电平电平有效 numeric option in std logic vector 9 DOWNTO 0 数字选项 上升沿有效 clr n in std logic temp 清零信号 d temp no in std logic temp no 信号控制 clr temp no in std logic temp no 信号控制 temp no out std logic temp no 控制信号 option code out std logic vector 3 DOWNTO 0 拨动数字选项开关生成的四位二进制码 END Numeric input architecture behavior of Numeric input is signal temp std logic vector 9 downto 0 0000000000 signal s std logic 0 signal ss std logic 0 signal count delay integer range 0 to 999999 0 signal n integer range 0 to 10 0 signal clr no std logic 0 begin 进程名称 temp 信号的输出 进程功能 根据开关的拨动情况和 clr n 控制 temp 信号的输出 lable1 for i in 9 downto 0 generate begin process numeric option clr n clr no begin if clr n 1 then temp i 0 elsif clr no 1 then temp i 0 elsif rising edge numeric option i then temp i option code 0000 n option code 0001 n option code 0010 n option code 0011 n option code 0100 n option code 0101 n option code 0110 n option code 0111 n option code 1000 n option code 1001 n option code ZZZZ n 10 end case end process 进程名称 temp no 信号的控制 进程功能 temp no 信号的控制 附数字键去抖动 p1 process temp begin s temp 0 or temp 1 or temp 2 or temp 3 or temp 4 or temp 5 or temp 6 or temp 7 or temp 8 or temp 9 end process p2 process clk s count delay numeric option begin if rising edge clk then if s 1 then if count delay 9 then count delay count delay 1 elsif numeric option n 1 then ss 1 else clr no 1 end if else clr no 0 ss 0 count delay 0 end if end if end process p3 process d temp no clr temp no ss reset begin if reset 1 then temp no 0 elsif clr temp no 1 then temp no 0 elsif rising edge ss then temp no led 3 downto 0 case p state is when input state led 3 downto 0 led 3 downto 0 led 3 downto 0 led 3 downto 0 led 3 downto 0 srl 1 end case end if end process process clk count begin if rising edge clk then if count 9999999 then count count 1 else clk led not clk led count 0 en

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论