77范文网 - 专业文章范例文档资料分享平台

EDA4位密码锁的课程设计(2)

来源:网络收集 时间:2021-09-24 下载这篇文档 手机版
说明:文章内容仅供预览,部分内容可能不全,需要完整文档或者需要复制内容,请下载word后使用。下载word有问题请添加微信号:或QQ: 处理(尽可能给您提供完整文档),感谢您的支持与谅解。点击这里给我发消息

architecture one of funcinput is signal state: signal mem: begin process(clk) begin if clk'event and clk='1' then if constate/=state then state<=constate; std_logic; std_logic_vector(7 downto 0);

完整版的EDA课程设计

if mem/=funcin then with funcin select when "11100111" , --清除键 when "11101101",--改密键 when "11101110", --上锁键 when "11101011" , --解锁键 when others;

conout<="001" "010" "011" "100" "000" mem<=funcin;

设

else conout<="000"; end if; end if; end if;

计

end process; end one; (2)功能按键输入模块仿真图:

过

程图 2.3 功能按键输入模块仿真图

由图可知:当功能按键输入模块的输入依次为“11100111”、 “ 11101101”、“ 11101110”、“ 11101011”时,conout 输出依次为 “001”、“010”、“011”、“100”, 当为其他按键输入时,conout 输出均为“000”。 (3)功能按键输入模块--funcinput 符号文件:

完整版的EDA课程设计

图 2.4 功能按键输入模块 --funcinput 符号文件

核

心处理模块--core 设核心处理模块将根据输入(数字按键输入以及功能按键输入)来改变存储器 状态、数码管显示以及LED灯显示(红灯亮为上锁,绿灯亮为解锁) 。

(1)Core--核心处理程序: library ieee;

计

use ieee.std_logic_1164.all; entity core is port( numin: conin: in std_logic_vector(3 downto 0); in std_logic_vector(2 downto 0); in std_logic; out std_logic_vector(3 downto 0); out std_logic);

过

clk:

dataa,datab,datac,datad: ledr,ledg,numout,conout: end entity;

程

architecture one of core is type lockstate is (unlock,locked); signal numa,numb,numc,numd,codea,codeb,codec,coded:std_logic_vector(3 downto 0); signal numstate,constate: signal locksta: begin process(clk,numin,conin) std_logic; lockstate;

完整版的EDA课程设计

if clk'event and clk='1' then--上升沿 if numin/="1010" then--当不是其他键时 numd<=numc; numc<=numb; numb<=numa; numa<=numin;---移位 end if; if conin/="000" then

设

if conin="001" then--清除键按下 numa<="0000";--全部清零 numb<="0000"; numc<="0000";

计

numd<="0000"; elsif conin="010" then --改密键按下 if locksta/=locked then--锁并不是上锁状态 codea<=numa;

过

codeb<=numb; codec<=numc; coded<=numd; end if;

程

elsif conin="011" then

--上锁键按下

if locksta/=locked then numa<="0000"; numb<="0000"; numc<="0000"; numd<="0000"; locksta<=locked; end if; elsif conin="100" then --解锁键按下 --锁定密码锁

完整版的EDA课程设计

if locksta=locked then if numa=codea and numb=codeb then 码 if numc=codec and numd=coded then locksta<=unlock; --锁开 end if; end if; end if; --输入正确密

设

end if; end if; if locksta=locked then ledr<='1'; --若锁锁定 --led 等高电平,红灯闪烁

计else

ledg<='0';

ledr<='0'; ledg<='1';

过

end if; dataa<=numa; datab<=numb; datac<=numc;

程

datad<=numd; if numstate='1' then numstate<='0'; else numstate<='1'; end if; if constate='1' then constate<='0'; else constate<='1'; end if; numout<=numstate; conout<=constate;

完整版的EDA课程设计

end if; end process; end one;

(2)核心处理模块仿真图: 当数字按键输入为有效输入(即输入的按键为数字按键 0~9 时) , 此时虽输入 9 位数字,但只有前四位有效,所以密码应为“1234” 若 。 conin 输入为“011” (即按下上锁键) ,此时可以看到 ledr 为高电平,所

设

以此时红灯闪烁一次,表示密码锁已上锁。仿真波形图如下:

计

过图 2.5 核心处理模块仿真图(一)

程

图 2.6 核心处理模块仿真图(二)

由图可知:若 conin 输入为“100”时(解锁时) ,当再次输入密码 “1234” 并此时 ledg 输出为低电平 , (绿灯亮) Dataa 输出密码 。 “1234” , 则表示此时密码锁已解锁。 (3)核心处理模块--core 符号文件:

完整版的EDA课程设计

图 2.7 处理核心模块--core 符号文件

设

输出处理模块—allout对处理核心模块—core 输出的数据进行刷新,使数码管及时显示刷 新的

数字。

计

(1)Allout--输出处理程序: library ieee; use ieee.std_logic_1164.all; entity allout is

过

port( dataa,datab,datac,datad: clk: dataout: 0);

in std_logic_vector(3 downto 0); in std_logic; out std_logic_vector(3 downto

程end allout; architecture one of allout is signal timer: begin process(clk) begin

outsel: 0));

out std_logic_vector(1 downto

std_logic_vector(1 downto 0);

if clk'event and clk='1' then--上升沿

完整版的EDA课程设计

if timer="00" then dataout<=dataa; outsel<="00"; timer<="01"; elsif timer="01" then dataout<=datab; outsel<="01"; timer<="10";

设

elsif timer="10" then dataout<=datac; outsel<="10"; timer<="11";

计

else ataout<=datad; outsel<="11"; timer<="00";

百度搜索“77cn”或“免费范文网”即可找到本站免费阅读全部范文。收藏本站方便下次阅读,免费范文网,提供经典小说公务员考试EDA4位密码锁的课程设计(2)在线全文阅读。

EDA4位密码锁的课程设计(2).doc 将本文的Word文档下载到电脑,方便复制、编辑、收藏和打印 下载失败或者文档不完整,请联系客服人员解决!
本文链接:https://www.77cn.com.cn/wenku/gongwuyuan/1247880.html(转载请注明文章来源)

相关推荐:

Copyright © 2008-2022 免费范文网 版权所有
声明 :本网站尊重并保护知识产权,根据《信息网络传播权保护条例》,如果我们转载的作品侵犯了您的权利,请在一个月内通知我们,我们会及时删除。
客服QQ: 邮箱:tiandhx2@hotmail.com
苏ICP备16052595号-18
× 注册会员免费下载(下载后可以自由复制和排版)
注册会员下载
全站内容免费自由复制
注册会员下载
全站内容免费自由复制
注:下载文档有可能“只有目录或者内容不全”等情况,请下载之前注意辨别,如果您已付费且无法下载或内容有问题,请联系我们协助你处理。
微信: QQ: