问答文章1 问答文章501 问答文章1001 问答文章1501 问答文章2001 问答文章2501 问答文章3001 问答文章3501 问答文章4001 问答文章4501 问答文章5001 问答文章5501 问答文章6001 问答文章6501 问答文章7001 问答文章7501 问答文章8001 问答文章8501 问答文章9001 问答文章9501

EDA电子密码锁程序 求分析

发布网友 发布时间:2022-05-10 04:07

我来回答

1个回答

热心网友 时间:2023-10-30 11:47

1、设计一个密码锁的控制电路,当输入正确代码时,输出开锁信号以推动执行机构工作,用红灯亮、绿灯熄灭表示关锁,用绿灯亮、红灯熄灭表示开锁;
2、在锁的控制电路中储存一个可以修改的4位二进制代码,当开锁按钮开关的输入代码等于储存代码时,开锁;
3、 从第一个按钮触动后的30秒内若未将锁打开,则电路长报警5S,若输入密码错误1或2次,则每次短报警1S,若输错三次密码则长报警。

library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;
entity lock is
port(clk_1k:in std_logic; --1024HZ频率输入管脚
enter_2,enter_1: in std_logic; --设密码确认及输入密码确认
datain:in std_logic_vector(3 downto 0); --密码数据输入
speaker:out std_logic; --喇叭
led_g,led_r:out std_logic); --绿灯及红灯
end entity lock;

architecture behave of lock is
signal ram:std_logic_vector(3 downto 0);
signal judge:std_logic;
signal clk:std_logic;
signal turn_on,turn_off:std_logic;
begin
process(Clk_1k)
variable clk_count:std_logic_vector(8 downto 0):="000000000";
begin
if clk_1k'event and clk_1k='1' then --分频
if clk_count<511 then
clk_count:=clk_count+1;
else
clk_count:="000000000";
clk<=not clk;
end if;
end if;
end process;

process(datain,enter_1) --设置密码
begin
if enter_1'event and enter_1='1' then
ram<=datain;
end if;
end process;

process(clk_1k) --判断第一位密码按下时开始计时
begin
if clk_1k'event and clk_1k='1' then
if enter_1='0' then
judge<='0';
end if;
if judge='0' and enter_1='1' then
if datain/=ram then judge<='1';end if;
end if;
end if;
end process;

process(judge,clk,enter_2)
variable count:std_logic_vector(4 downto 0):="00000"; --判断自第一个按键开始的时间是否超30秒
variable judge_sh:std_logic_vector(1 downto 0):="00"; --判断输入错误密码次数
variable switch:std_logic:='0'; --判断是否锁定键盘
begin
if clk'event and clk='1' then
if enter_1='0' then --数据复位
count:="00000";judge_sh:="00";switch:='0';
end if;
if switch='0' then
if judge='1' then
if count<"11110" then --30 秒计时
count:=count+1;
if enter_2='1' then
if datain = ram then
turn_on<='1';turn_off<='0';switch:='1'; --开锁
else
if judge_sh<"10" then
judge_sh:=judge_sh+1;turn_on<='1';turn_off<='1';switch:='0'; -
else
turn_on<='0';turn_off<='1';switch:='1'; -- 3次 end if;
end if;
else
turn_on<='0';turn_off<='0';switch:='0'; --等待下次输入
end if;
else
turn_on<='0';turn_off<='1';switch:='1';
end if;
end if;
end if;
end if;
end process;

process(clk,clk_1k,turn_on)
variable count:std_logic_vector(3 downto 0):="0000"; --长报警时间
variable count_sh:std_logic_vector(1 downto 0):="00"; --短报警时间
variable temp,temp_sh:std_logic:='0'; --判断是短报警或长报警
begin
if clk'event and clk='1' then
if enter_1='0' then --数据复位
count:="0000";count_sh:="00";temp:='0';temp_sh:='0';
end if;
if turn_on='0' and turn_off='1' then
if count<"0101" then --响5秒
count:=count+1;
temp:='1';
led_g<='0';led_r<='1';
else
temp:='0';
end if;
elsif turn_on='1' and turn_off='0' then
led_g<='1';led_r<='0';
elsif turn_on='1' and turn_off='1' then
temp_sh:='1'; --响1秒
elsif turn_on='0' and turn_off='0' then
led_g<='0';led_r<='1';temp_sh:='0';
else null;
end if;
end if;
speaker<=(temp or temp_sh) and clk_1k; --驱动喇叭
end process;
end behave;
声明声明:本网页内容为用户发布,旨在传播知识,不代表本网认同其观点,若有侵权等问题请及时与本网联系,我们将在第一时间删除处理。E-MAIL:11247931@qq.com
如何用易语言实现QQ登录器的QQ号空了就出现“QQ号为空,请输入QQ号... 介绍几首最新的网络歌手唱得网络红歌呗。。谢谢啊 求推荐几首好听的歌,要和徐良风格差不多的 ...男女合唱的】最好多推荐几首,试到一首好听的 有什么蛮好听的新歌吗?网络歌手、非主流的,像汪苏泷、徐良、阿悄他们的... 关于Guitar Rig 4的两个问题,求解答。。。 右脚跟疼是什么原因引起的 男人右脚后跟筋疼的原因 右脚跟痛 我右脚跟腱痛怎么治呀,两个多月前崴了一下,找人捏了几次,但现在跟腱一... 结婚婚假包括周末吗? 婚假是否包括双休日 婚假包括周末吗 婚假包含周末吗? 能判断是真假阿胶糕么? 微信群发好用吗? 在物理学中s=vt中的s,v,t各表示什么意思 在物理学中s=vt中的s、v、t各表示什么意思? 对平均速度定义式.v=st的理解,下列说法正确的是(  )A..v=st求出的是t时刻的速度B.此公式只适用于 在物理学中,把路程与时间之比叫做______,写成公式就是v=stv=st.我们把物体沿着直线且速度不变的运动叫 在物理中为什么v=st则h=vt? 物理学中把物体在单位时间内通过的路程叫速度,速度计算公式为:速度=路程时间路程时间,即v=stst,单位 速度表示物体______ 的物理量,它等于运动物体在______内通过的路程,公式表达为:v=stv=st,在国际单 计算速度的公式是stst,其中s表示___,t表示___,v表示___ 速度的计算公式:v=stv=st,它的单位:__ 联想笔记本电脑,窗口打开多了以后就会变得很慢,还会提示虚拟内存不足,怎么办啊? 滑轮组中v=st是什么意思? 物理中stv代表什么 我是联想的电脑,512M内存,电脑最近老是提示内存不足和虚拟内存太低 联想电脑显示内存不足 英伟达为什么进不去 微信群发安全吗,比如我同时发10个人,他们能互相看到大家吗?还是像私聊一样都看不到彼此? 婚假15天包括周末吗 婚假包括双休日吗 飞利浦剃须刀s7370和9400区别 英伟达显卡登录不上去 英伟达死活登不上,但是官网登录成功了,求大佬指点 婚假一般包含双休日吗? vivo手机被狠狠的摔坏了,手机边边有点翘就那种这边薄那边厚的那种,内屏也碎了,可以修好嘛? 飞利浦剃须刀s5077和s5081哪个更好? 婚假是包含双休日的吗 你好,我的ViVo手机内屏坏了还可以修好吗? 股票k线图kmac怎么解?能具体说说吗? 法定婚假包括周末吗 飞利浦剃须刀 s系列为什么没有了 微信群发广告是放好还是放二维码 山楂、陈皮、枸杞、甘草、贡菊、茶叶可以一泡茶喝吗 普通话报名可以在手机上报名么 可以用手机报名普通话考试吗(照片是符合条件的) 亿播集团的网络直播带货为啥那么多人推荐?