test_bench.vhd

来自「Xillinx 的8位MCU软核的源代码」· VHDL 代码 · 共 81 行

VHD
81
字号
-- Test Bench for kcpsm2_int_test.vhd
--
-- Ken Chapman - Xilinx Ltd - February 2002
--
--
LIBRARY ieee;
USE ieee.std_logic_1164.ALL;
USE ieee.numeric_std.ALL;

ENTITY testbench IS
END testbench;

ARCHITECTURE behavior OF testbench IS 

  -- Design to be tested

  COMPONENT kcpsm2_int_test
    Port (         counter : out std_logic_vector(7 downto 0);
                 waveforms : out std_logic_vector(7 downto 0);
           interrupt_event : in std_logic;
                       clk : in std_logic);
  END COMPONENT;

-- signals to connect kcpsm2_int_test 

SIGNAL counter : std_logic_vector(7 downto 0);
SIGNAL waveforms : std_logic_vector(7 downto 0);
SIGNAL interrupt_event : std_logic := '0';
SIGNAL clk : std_logic := '0';

BEGIN

-- Define the unit under test

   uut: kcpsm2_int_test 
   port map (         counter => counter,
                    waveforms => waveforms,
              interrupt_event => interrupt_event,
                          clk => clk);


-- Test Bench begins
 
  -- Nominal 100MHz clock which also defines number of cycles in simulation 
  test_clock: process
      variable max_cycles : integer :=400;
      variable cycle_count : integer := 0;
    begin
      -- Define the clock cycles and the clock cycle counter
	   while cycle_count < max_cycles loop
	     clk <= '0';
		  wait for 5 ns;
		  clk <= '1';
		  cycle_count := cycle_count + 1;
		  wait for 5 ns;

        --Now define stimulus relative to a given clock cycle

        case cycle_count is

          when 30 =>  interrupt_event <= '1'; 
          when 34 =>  interrupt_event <= '0'; 

          when 67 =>  interrupt_event <= '1'; 
          when 71 =>  interrupt_event <= '0'; 

          when 184 =>  interrupt_event <= '1'; 
          when 188 =>  interrupt_event <= '0'; 
 
          when others => interrupt_event <= interrupt_event;   -- hold last defined value

        end case;

      end loop;

      wait; -- end of simulation.
  
  end process;

END;

⌨️ 快捷键说明

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