compare.vhd
来自「4位二进制密码锁,可能会对别人有点帮助,大家下来看看把」· VHDL 代码 · 共 32 行
VHD
32 行
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;
entity compare is
port(ok,clk : in std_logic;--计时时钟
d,e : in std_logic_vector(5 downto 0);--开锁时输入的密码
f: out std_logic_vector(5 downto 0);--锁的原始密码
g: out std_logic); --密码正确与否的输出
end;
architecture behave of compare is
signal f0 : std_logic_vector (5 downto 0);
signal g0 : std_logic :='0';
--signal ok: std_logic := '0';
begin
process( d,e,clk)
begin
if clk'event and clk = '1' then
if d(5 downto 0)= e (5 downto 0) then
--f0(5 downto 0) <= d (5 downto 0);
g0 <= '1';
else
g0 <= '0';
--ok0 <= '1';
end if;
end if;
if ok = '1' then f0(5 downto 0) <= d (5 downto 0);
end if;
end process;
f(5 downto 0) <= f0 (5 downto 0);
g <= g0;
end behave;
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?