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

📄 lock.vhd

📁 以QuatusⅡ为平台
💻 VHD
字号:
LIBRARY ieee;
USE ieee.std_logic_1164.ALL;
USE ieee.std_logic_unsigned.ALL;

entity lock is
port(
     clk:in std_logic;
     keyin:in std_logic_vector(7 downto 0);
     lockon: in std_logic;
     lockoff:in std_logic;
     keychange:in std_logic;
     reset:in std_logic;
     ledr:out std_logic;
     ledg:out std_logic
);
end lock;

architecture lock of lock is


begin
     process(reset,clk)
     variable lockflag:std_logic:='0';
     variable key:std_logic_vector(7 downto 0):="00000001";
     begin
        if reset='0'then
          key:="00000001";
          ledg<='1';
          ledr<='0';
          lockflag:='0';
        else
            if clk'event and clk='1' then
                 if lockon='0' then
                      if keyin=key or lockflag='1' then
                          ledg<='1';
                          ledr<='0';
                          lockflag:='1';
                          if keychange='0' then
                             key:=keyin;
                             ledg<='1';
                             ledr<='0';
                          end if;
                       else
                           ledg<='0';
                           ledr<='1';
                           lockflag:='0';
                       end if;
                  elsif lockoff='0' then
                        ledg<='0';
                        ledr<='1';
                        lockflag:='0';
                  else
                        ledg<=lockflag;
                        ledr<=not lockflag;
                  end if;         
             end if;
        end if;
    end process;
end lock;

⌨️ 快捷键说明

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