Advertisement
NoThisIsPanman

WrapperTestBench

Jan 13th, 2017
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VHDL 3.57 KB | None | 0 0
  1. library IEEE;
  2. use IEEE.STD_LOGIC_1164.ALL;
  3.  
  4. entity WrapperTestBench is
  5. end WrapperTestBench;
  6.  
  7. architecture Behavioral of WrapperTestBench is
  8.    -- Conponent Declaration
  9.    Component Wrapper
  10.    Port (   FROM_STACK, FROM_IMMED : in    STD_LOGIC_VECTOR(9 downto 0);
  11.                            MUX_SEL : in    STD_LOGIC_VECTOR(1 downto 0);
  12.            PC_LD, PC_INC, RST, clk : in    STD_LOGIC;
  13.                   PC_COUNT_MONITOR : out   STD_LOGIC_VECTOR(9 downto 0);    -- Used for debugging
  14.                                 IR : out   STD_LOGIC_VECTOR(17 downto 0));
  15.    end Component;
  16.    
  17.    -- Inputs
  18.    signal FROM_STACK_tb :   STD_LOGIC_VECTOR(9 downto 0) := "0011001100"; --x0CC
  19.    signal FROM_IMMED_tb :   STD_LOGIC_VECTOR(9 downto 0) := "0110101010"; --x1AA
  20.    signal MUX_SEL_tb    :   STD_LOGIC_VECTOR(1 downto 0) := (others => '0');
  21.    signal PC_LD_tb      :   STD_LOGIC := '0';
  22.    signal PC_INC_tb     :   STD_LOGIC := '0';
  23.    signal RST_tb        :   STD_LOGIC := '0';
  24.    signal clk_tb        :   STD_LOGIC := '0';
  25.    
  26.    -- Outputs
  27.    signal PC_COUNT_MONITOR_tb   :   STD_LOGIC_VECTOR(9 downto 0);
  28.    signal               IR_tb   :   STD_LOGIC_VECTOR(17 downto 0);
  29.  
  30.    -- Clock period definitions
  31.    constant CLK_period  : time := 10 ns;
  32.    
  33. begin
  34.    
  35.     -- Instantiate SUT
  36.     SUT: Wrapper port map(
  37.             FROM_STACK  =>  FROM_STACK_tb,
  38.             FROM_IMMED  =>  FROM_IMMED_tb,
  39.             MUX_SEL     =>  MUX_SEL_tb,
  40.             PC_LD       =>  PC_LD_tb,
  41.             PC_INC      =>  PC_INC_tb,
  42.             RST         =>  RST_tb,
  43.             clk         =>  clk_tb,
  44.             PC_COUNT_MONITOR    =>  PC_COUNT_MONITOR_tb,
  45.             IR          =>  IR_tb);            
  46.            
  47.     -- Clock process definition
  48.     CLK_process: process
  49.     begin
  50.         clk_tb <= '0';      -- Using clk_tb NOT clk!!!
  51.         wait for CLK_period / 2;
  52.         clk_tb <= '1';
  53.         wait for CLK_period / 2;
  54.     end process;
  55.    
  56.     -- Simulate process
  57.     stim_proc: process
  58.     begin
  59. --      Simulation 1:
  60. --          test PC functions are sync
  61.  
  62.         MUX_SEL_tb <= "00"; -- select input one from mux
  63.         PC_LD_tb <= '1'; -- load in FROM_IMMED
  64.         PC_INC_tb <= '1';
  65.         wait for 20 ns;
  66.         PC_LD_tb <= '0'; -- stop loading
  67.         wait for 10 ns;
  68.         RST_tb <= '1'; -- turn on reset
  69.         wait for 5 ns;
  70.         RST_tb <= '0'; -- turn off reset. the PC should NOT have reset
  71.         wait for 25 ns;
  72.         RST_tb <= '1'; -- reset. the PC should actually reset now
  73.         wait for 10 ns;
  74.        
  75. --      Simulation 2:
  76. --          test MUX selectors
  77.        
  78.         RST_tb <= '0'; -- each of the mux signals is selected to check PC output
  79.         PC_LD_tb <= '1';
  80.         MUX_SEL_tb <= "00";
  81.         wait for 40 ns;
  82.         MUX_SEL_tb <= "01";
  83.         wait for 40 ns;
  84.         MUX_SEL_tb <= "10";
  85.         wait for 40 ns;    
  86.        
  87.        
  88. --      Simulation 3
  89. --          test incrimenting  
  90.  
  91.         PC_LD_tb <= '0';
  92.         RST_tb <= '1'; -- reset to zero
  93.         PC_INC_tb <= '0';
  94.         wait for 40 ns; -- the PC will increment for 100 ns
  95.         RST_tb <= '0';
  96.         PC_INC_tb <= '1';
  97.         wait for 100 ns;
  98.        
  99. --      Simulation 4
  100. --          test IR outputs
  101.  
  102.         MUX_SEL_tb <= "00";
  103.         FROM_IMMED_tb <= "0000010000"; -- should be line 10
  104.         PC_LD_tb <= '1'; -- load in 10
  105.         PC_INC_tb <= '0';
  106.         wait for 20 ns;
  107.         PC_LD_tb <= '0'; -- start incrimenting to see the commands in IR
  108.         PC_INC_tb <= '1';
  109.        
  110.     end process;
  111.    
  112. end Behavioral;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement