⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 lock.vhd

📁 四位密码锁
💻 VHD
字号:
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_signed.all;
entity lock is
port(a:in std_logic_vector(9 downto 0);
     b:in std_logic_vector(9 downto 0);
     en,clk:in std_logic;
     enl:in std_logic;
     c,d: out std_logic_vector(6 downto 0):="0111111"  ;
     k,m:out std_logic );
end lock;
architecture behave of lock is
signal e:std_logic_vector(3 downto 0);
signal f:std_logic_vector(3 downto 0);
signal g:std_logic_vector(3 downto 0);
signal h:std_logic_vector(3 downto 0);
signal count1,count2:std_logic:='0';
signal s:std_logic:='0';
begin 
process(a,e)
begin 
if(a(9 downto 0)="0000000000")
then c(6 downto 0)<="0111111";
elsif(a(0)='1')then
e<="0000";c(6 downto 0)<="0111111";
elsif(a(1)='1')then
e<="0001";c(6 downto 0)<="0000110";
elsif(a(2)='1')then
e<="0010";c(6 downto 0)<="1011011";
elsif(a(3)='1')then
e<="0011";c(6 downto 0)<="1001111";
elsif(a(4)='1')then
e<="0100";c(6 downto 0)<="1100110";
elsif(a(5)='1')then
e<="0101";c(6 downto 0)<="1101101";
elsif(a(6)='1')then
e<="0110";c(6 downto 0)<="1111100";
elsif(a(7)='1')then
e<="0111";c(6 downto 0)<="0000111";
elsif(a(8)='1')then
e<="1000";c(6 downto 0)<="1111111";
elsif(a(9)='1')then
e<="1001";c(6 downto 0)<="1100111";
end if;
end process;
process(b,f)
begin 
if(b(9 downto 0)="0000000000")then
d(6 downto 0)<="0111111";
elsif(b(0)='1')then
f<="0000";d(6 downto 0)<="0111111";
elsif(b(1)='1')then
f<="0001";d(6 downto 0)<="0000110";
elsif(b(2)='1')then
f<="0010";d(6 downto 0)<="1011011";
elsif(b(3)='1')then
f<="0011";d(6 downto 0)<="1001111";
elsif(b(4)='1')then
f<="0100";d(6 downto 0)<="1100110";
elsif(b(5)='1')then
f<="0101";d(6 downto 0)<="1101101";
elsif(b(6)='1')then
f<="0110";d(6 downto 0)<="1111100";
elsif(b(7)='1')then
f<="0111";d(6 downto 0)<="0000111";
elsif(b(8)='1')then
f<="1000";d(6 downto 0)<="1111111";
elsif(b(9)='1')then
f<="1001";d(6 downto 0)<="1100111";
end if;
end process;
process(clk)
begin
if(s='1')and(en='1')and(count1='0')then
g(3 downto 0)<=e(3 downto 0);
h(3 downto 0)<=f(3 downto 0);
count1<=not(count1);
end if;
if(enl='1')and(count2='0')then
if(e(3 downto 0)=g(3 downto 0)and f(3 downto 0)=h(3 downto 0))then
k<='1';
s<='1';
else
k<='0';
m<='1';
end if;
count2<=not(count2);
end if;
if(en='0')and(enl='0')then
count1<='0';
count2<='0';
k<='0';s<='0';m<='0';
end if;
if(en='0'and s='1')then
count1<='0';
end if;
end process;
end behave;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -