代码
LIBRARY ieee;
USE ieee.std_logic_1164.all;
ENTITY H2_test IS
END H2_test;
ARCHITECTURE H2_arch OF H2_test IS
-- constants
-- signals
SIGNAL CLK1 : STD_LOGIC;
SIGNAL DATA1 : STD_LOGIC_VECTOR(7 DOWNTO 0);
SIGNAL LOAD1 : STD_LOGIC;
SIGNAL M1 : STD_LOGIC;
SIGNAL Q1 : STD_LOGIC_VECTOR(7 DOWNTO 0);
SIGNAL RESET1 : STD_LOGIC;
CONSTANT CLK_P: TIME:=200 ns;
COMPONENT H2
PORT (
CLK : IN STD_LOGIC;
DATA : IN STD_LOGIC_VECTOR(7 DOWNTO 0);
LOAD : IN STD_LOGIC;
M : IN STD_LOGIC;
RESET : IN STD_LOGIC;
Q : OUT STD_LOGIC_VECTOR(7 DOWNTO 0)
);
END COMPONENT;
BEGIN
U1 : H2
PORT MAP (
CLK => CLK1,
DATA => DATA1,
LOAD => LOAD1,
M => M1,
Q => Q1,
RESET => RESET1
);
PROCESS --时钟进程
BEGIN
CLK1<='0'; WAIT FOR CLK_P;
CLK1<='1'; WAIT FOR CLK_P;
END PROCESS ;
RESET1<='0', '1' AFTER 400 ns, '0' AFTER 8000 ns; --清零
LOAD1<='0', '1' AFTER 300 ns, '0' AFTER 800 ns; --置数使能
DATA1<="00000000", "10011101" AFTER 250 ns, "00000000" AFTER 1200 ns; --置数
M1<='0', '1' AFTER 3300 ns, '0' AFTER 5600 ns;
END H2_arch;