密码锁设计(不完整)-VHDL

小白萌新,思路仅供参考,问题较多,有待改善

  1. 设计要求
    4个按键为密码输入键,可以用另一个按键作为复位,当按下复位按键时可以重新开始输入新的密码。利用一位数码管显示输入密码的次数,另一位显示正确与否,如果正确数码管显示“H”,如果错误,数码管显示“E”.当超过3次时如果密码仍然输入不正确
  2. 程序
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;
use ieee.std_logic_misc.all;
-- **************************************
entity Lock is
generic
(
	mima:std_logic_vector(7 downto 0):="11011001"  --默认密码
);
port
(
	clk:in std_logic;								--时钟
	key:in std_logic_vector(3 downto 0);	--按键输入
	reset: in std_logic;							--按键复位
	beep:out std_logic;							--蜂鸣器
	tf:out std_logic_vector(6 downto 0);	--正确错误信息
	num:out std_logic_vector(6 downto 0)	--次数
);
end Lock;
-- **************************************
architecture behv of Lock is
type state is(st0,st1,st2,st3,st4,st5,ss0,ss1,ss2,ss3);				--状态1
signal current_state,next_state:state:=st0;		--当前状态,下一状态
signal secret_temp:std_logic_vector(7 downto 0):="00000000";
signal tf_cnt:integer range 0 to 7:=0; --错误计数
signal beep_cnt:integer range 0 to 7:=0 ; --错误计数
signal key_temp:std_logic;--按键释放

begin
	COM1:process(clk)			--时钟					
	begin 
		if clk'event and clk='1' then
			current_state<=next_state;	
		end if;
	end process COM1;
-- **************************************	
	COM2:<
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值