?? dis.vhd
字號:
library IEEE;
use IEEE.std_logic_1164.all;
use IEEE.std_logic_unsigned.all; --庫包含
entity DIS is
port(din : in std_logic_vector(3 downto 0); -- 顯示口令數據
cr_cnt :in std_logic_vector(1 downto 0); -- 顯示數據個數
err_cnt:in std_logic_vector(1 downto 0); -- 顯示錯誤次數
set_crack: in std_logic_vector(1 downto 0); --顯示設置或解鎖狀態
disclk: in std_logic; -- 顯示掃描時鐘
sec : in std_logic; -- 消隱控制標志
lock: in std_logic; -- 上鎖標志
dout: out std_logic_vector(7 downto 0); -- 顯示數據輸出
encode: out std_logic_vector(2 downto 0) -- LED選擇編碼輸出
);
end entity DIS;
architecture behv of DIS is
--signal 聲明
signal cnt : std_logic_vector(2 downto 0);
signal c : std_logic;
begin
process(din,c,disclk)
begin
if disclk'event and disclk = '1' then
if cnt = "100" then cnt <= "000"; else cnt <= cnt + '1'; -- 編碼計數器
end if;
if cnt = "000" then encode <= "000"; -- 口令數據顯示
if c = '0' then
case din is
when "0000" => dout <= "11111100";
when "0001" => dout <= "01100000";
when "0010" => dout <= "11011010";
when "0011" => dout <= "11110010";
when "0100" => dout <= "01100110";
when "0101" => dout <= "10110110";
when "0110" => dout <= "00111110";
when "0111" => dout <= "11100000";
when "1000" => dout <= "11111110";
when "1001" => dout <= "11100110";
when "1010" => dout <= "11101111"; -- 10 解鎖成功 'A'
when "1011" => dout <= "01111111"; --
when others => dout <= "11111111";
end case;
else dout <= "00000000";
end if;
else if cnt = "001" then encode <= "001"; -- 輸入數據個數顯示
case cr_cnt is
when "00" => dout<= "01100000";
when "01" => dout<= "11011010";
when "10" => dout<= "11110010";
when "11" => dout<= "01100110";
when others => NULL;
end case;
else if cnt = "010" then encode <= "010"; -- 解鎖錯誤次數顯示
case err_cnt is
when "00" => dout<= "11111100";
when "01" => dout<= "01100000";
when "10" => dout<= "11011010";
when "11" => dout<= "11110010";
when others => NULL;
end case;
else if cnt = "011" then encode <= "011"; -- 設置解鎖狀態標志
case set_crack is
when "01" => dout <= "11000000";
when "10" => dout <= "00011000";
when others => dout <= "00000000";
end case;
else if cnt = "100" then encode <= "100"; -- 上鎖和開鎖顯示
if lock = '0' then dout <= "00000001"; --鎖
else dout <= "11111111"; --開鎖
end if;
end if;
end if;
end if ;
end if;
end if;
end if;
end process;
process(sec) --檢測消隱信號
begin
if sec'event and sec = '1' then c <= not c;
end if;
end process;
end behv;
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -