📄 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 + -