?? cornaa.vhd
字號:
library ieee;
use ieee.std_logic_1164.all;
entity cornaa is -----LOAD 為設置密碼的開關
port(clk,k1,k0,clr,load:in std_logic; -----K1,K0 分別是代表1和0的按鍵開關
lt:inout std_logic; -----CLR用來清除報警信號和關鎖
lamp:out std_logic_vector(7 downto 0); ------LAMP接發光二極管,用來顯示已經輸入密碼的個數
lf,alm:out std_logic);
end cornaa;
architecture corn_arc of cornaa is
signal shift,lock:std_logic_vector(7 downto 0);
signal lam:std_logic_vector(7 downto 0);
signal la:std_logic;
begin
process(clk,clr)
begin
if clr='0' then
la<='0';
elsif clk'event and clk='1' then
if load ='0' then
la<='1';
end if;
end if;
end process;
process(clk,clr)
variable a:integer range 0 to 8;
begin
if clr='0' then
lam<="00000000";
shift<="00000000";
a:=0;
lt<='0';
lf<='0';
alm<='0';
elsif clk'event and clk='1' then
if lt='0' then
if a/=8 then
if k1='0' then
shift<='1' & shift (7 downto 1); ------輸入一位密碼“1”
lam<='1' & lam (7 downto 1); ------顯示輸入了一位密碼
a:=a+1;
elsif k0='0' then
shift<='0' & shift (7 downto 1); -----輸入一位密碼“0”
lam<='1' & lam (7 downto 1);
a:=a+1;
end if;
else
a:=0;
if shift=lock then ------密碼正確
lt<='1';
else -----密碼錯誤
lf<='1';
alm<='1';
end if;
end if;
elsif la='1' then
if k1='0' then
lock<='1' & lock(7 downto 1); ------設置一位密碼為“1”
lam<='0' & lam(7 downto 1); ------顯示設置了一位密碼
elsif k0='0' then
lock<='0' & lock(7 downto 1); ------設置了一位密碼為“0”
lam<='0' & lam(7 downto 1);
end if;
end if;
end if;
end process;
lamp<=lam;
end corn_arc;
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -