OpenCores
URL https://opencores.org/ocsvn/opencpu32/opencpu32/trunk

Subversion Repositories opencpu32

[/] [opencpu32/] [trunk/] [hdl/] [opencpu32/] [testMultiplexer4_1.vhd] - Diff between revs 19 and 42

Only display areas with differences | Details | Blame | View Log

Rev 19 Rev 42
--! @file
--! @file
--! @brief Testbench for Multiplexer4_1
--! @brief Testbench for Multiplexer4_1
 
 
--! Use standard library and import the packages (std_logic_1164,std_logic_unsigned,std_logic_arith)
--! Use standard library and import the packages (std_logic_1164,std_logic_unsigned,std_logic_arith)
LIBRARY ieee;
LIBRARY ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;
use ieee.std_logic_unsigned.all;
use ieee.std_logic_arith.all;
use ieee.std_logic_arith.all;
 
 
--! Use CPU Definitions package
--! Use CPU Definitions package
use work.pkgOpenCPU32.all;
use work.pkgOpenCPU32.all;
 
 
ENTITY testMultiplexer4_1 IS
ENTITY testMultiplexer4_1 IS
END testMultiplexer4_1;
END testMultiplexer4_1;
 
 
--! @brief Multiplexer4_1 Testbench file
--! @brief Multiplexer4_1 Testbench file
--! @details Test multiplexer operations changing the selection signal
--! @details Test multiplexer operations changing the selection signal
--! for more information: http://en.wikipedia.org/wiki/Multiplexer
--! for more information: http://en.wikipedia.org/wiki/Multiplexer
ARCHITECTURE behavior OF testMultiplexer4_1 IS
ARCHITECTURE behavior OF testMultiplexer4_1 IS
 
 
    --! Component declaration to instantiate the Multiplexer circuit
    --! Component declaration to instantiate the Multiplexer circuit
    COMPONENT Multiplexer4_1
    COMPONENT Multiplexer4_1
    generic (n : integer := nBits - 1);                                 --! Generic value (Used to easily change the size of the Alu on the package)
    generic (n : integer := nBits - 1);                                 --! Generic value (Used to easily change the size of the Alu on the package)
         Port ( A   : in  STD_LOGIC_VECTOR (n downto 0); --! First Input
         Port ( A   : in  STD_LOGIC_VECTOR (n downto 0); --! First Input
           B   : in  STD_LOGIC_VECTOR (n downto 0);      --! Second Input
           B   : in  STD_LOGIC_VECTOR (n downto 0);      --! Second Input
                          C   : in  STD_LOGIC_VECTOR (n downto 0);       --! Third Input
                          C   : in  STD_LOGIC_VECTOR (n downto 0);       --! Third Input
                          D   : in  STD_LOGIC_VECTOR (n downto 0);       --! Forth Input
                          D   : in  STD_LOGIC_VECTOR (n downto 0);       --! Forth Input
                          E   : in  STD_LOGIC_VECTOR (n downto 0);       --! Fifth Input
                          E   : in  STD_LOGIC_VECTOR (n downto 0);       --! Fifth Input
           sel : in  STD_LOGIC_VECTOR (2 downto 0);      --! Select inputs (1, 2, 3, 4, 5)
           sel : in  dpMuxInputs;                                                       --! Select inputs (1, 2, 3, 4, 5)
           S   : out  STD_LOGIC_VECTOR (n downto 0));    --! Mux Output
           S   : out  STD_LOGIC_VECTOR (n downto 0));    --! Mux Output
    END COMPONENT;
    END COMPONENT;
 
 
 
 
   --Inputs
   --Inputs
   signal A : std_logic_vector((nBits - 1) downto 0) := (others => '0');  --! Wire to connect Test signal to component
   signal A : std_logic_vector((nBits - 1) downto 0) := (others => '0');  --! Wire to connect Test signal to component
   signal B : std_logic_vector((nBits - 1) downto 0) := (others => '0');  --! Wire to connect Test signal to component
   signal B : std_logic_vector((nBits - 1) downto 0) := (others => '0');  --! Wire to connect Test signal to component
        signal C : std_logic_vector((nBits - 1) downto 0) := (others => '0');     --! Wire to connect Test signal to component
        signal C : std_logic_vector((nBits - 1) downto 0) := (others => '0');     --! Wire to connect Test signal to component
        signal D : std_logic_vector((nBits - 1) downto 0) := (others => '0');     --! Wire to connect Test signal to component
        signal D : std_logic_vector((nBits - 1) downto 0) := (others => '0');     --! Wire to connect Test signal to component
        signal E : std_logic_vector((nBits - 1) downto 0) := (others => '0');     --! Wire to connect Test signal to component
        signal E : std_logic_vector((nBits - 1) downto 0) := (others => '0');     --! Wire to connect Test signal to component
   signal sel : STD_LOGIC_VECTOR (2 downto 0) := "000";                                                  --! Wire to connect Test signal to component
   signal sel : dpMuxInputs := fromMemory;                                                                                      --! Wire to connect Test signal to component
 
 
        --Outputs
        --Outputs
   signal S : std_logic_vector((nBits - 1) downto 0);                                                    --! Wire to connect Test signal to component
   signal S : std_logic_vector((nBits - 1) downto 0);                                                    --! Wire to connect Test signal to component
 
 
BEGIN
BEGIN
 
 
        --!Instantiate the Unit Under Test (Multiplexer4_1) (Doxygen bug if it's not commented!)
        --!Instantiate the Unit Under Test (Multiplexer4_1) (Doxygen bug if it's not commented!)
   uut: Multiplexer4_1 PORT MAP (
   uut: Multiplexer4_1 PORT MAP (
          A => A,
          A => A,
          B => B,
          B => B,
                         C => C,
                         C => C,
                         D => D,
                         D => D,
                         E => E,
                         E => E,
          sel => sel,
          sel => sel,
          S => S
          S => S
        );
        );
 
 
   --! Process that will change sel signal and verify the Mux outputs
   --! Process that will change sel signal and verify the Mux outputs
   stim_proc: process
   stim_proc: process
   begin
   begin
      -- Sel 0 ---------------------------------------------------------------------------
      -- Sel 0 ---------------------------------------------------------------------------
                wait for 1 ps;
                wait for 1 ps;
                REPORT "Select first channel" SEVERITY NOTE;
                REPORT "Select first channel" SEVERITY NOTE;
                sel <= "000";
                sel <= fromMemory;
                A <= conv_std_logic_vector(0, nBits);
                A <= conv_std_logic_vector(0, nBits);
                B <= conv_std_logic_vector(1000, nBits);
                B <= conv_std_logic_vector(1000, nBits);
                C <= conv_std_logic_vector(2000, nBits);
                C <= conv_std_logic_vector(2000, nBits);
                D <= conv_std_logic_vector(3000, nBits);
                D <= conv_std_logic_vector(3000, nBits);
                E <= conv_std_logic_vector(4000, nBits);
                E <= conv_std_logic_vector(4000, nBits);
                wait for 1 ns;  -- Wait to stabilize the response
                wait for 1 ns;  -- Wait to stabilize the response
                assert S = (A) report "Could not select first channel" severity FAILURE;
                assert S = (A) report "Could not select first channel" severity FAILURE;
 
 
                -- Sel 1 ---------------------------------------------------------------------------
                -- Sel 1 ---------------------------------------------------------------------------
                wait for 1 ns;
                wait for 1 ns;
                REPORT "Select second channel" SEVERITY NOTE;
                REPORT "Select second channel" SEVERITY NOTE;
                sel <= "001";
                sel <= fromImediate;
                A <= conv_std_logic_vector(0, nBits);
                A <= conv_std_logic_vector(0, nBits);
                B <= conv_std_logic_vector(1000, nBits);
                B <= conv_std_logic_vector(1000, nBits);
                C <= conv_std_logic_vector(2000, nBits);
                C <= conv_std_logic_vector(2000, nBits);
                D <= conv_std_logic_vector(3000, nBits);
                D <= conv_std_logic_vector(3000, nBits);
                E <= conv_std_logic_vector(4000, nBits);
                E <= conv_std_logic_vector(4000, nBits);
                wait for 1 ns;  -- Wait to stabilize the response
                wait for 1 ns;  -- Wait to stabilize the response
                assert S = (B) report "Could not select second channel" severity FAILURE;
                assert S = (B) report "Could not select second channel" severity FAILURE;
 
 
                -- Sel 2 ---------------------------------------------------------------------------
                -- Sel 2 ---------------------------------------------------------------------------
                wait for 1 ns;
                wait for 1 ns;
                REPORT "Select third channel" SEVERITY NOTE;
                REPORT "Select third channel" SEVERITY NOTE;
                sel <= "010";
                sel <= fromRegFileA;
                A <= conv_std_logic_vector(0, nBits);
                A <= conv_std_logic_vector(0, nBits);
                B <= conv_std_logic_vector(1000, nBits);
                B <= conv_std_logic_vector(1000, nBits);
                C <= conv_std_logic_vector(2000, nBits);
                C <= conv_std_logic_vector(2000, nBits);
                D <= conv_std_logic_vector(3000, nBits);
                D <= conv_std_logic_vector(3000, nBits);
                E <= conv_std_logic_vector(4000, nBits);
                E <= conv_std_logic_vector(4000, nBits);
                wait for 1 ns;  -- Wait to stabilize the response
                wait for 1 ns;  -- Wait to stabilize the response
                assert S = (C) report "Could not select third channel" severity FAILURE;
                assert S = (C) report "Could not select third channel" severity FAILURE;
 
 
                -- Sel 3 ---------------------------------------------------------------------------
                -- Sel 3 ---------------------------------------------------------------------------
                wait for 1 ns;
                wait for 1 ns;
                REPORT "Select forth channel" SEVERITY NOTE;
                REPORT "Select forth channel" SEVERITY NOTE;
                sel <= "011";
                sel <= fromRegFileB;
                A <= conv_std_logic_vector(0, nBits);
                A <= conv_std_logic_vector(0, nBits);
                B <= conv_std_logic_vector(1000, nBits);
                B <= conv_std_logic_vector(1000, nBits);
                C <= conv_std_logic_vector(2000, nBits);
                C <= conv_std_logic_vector(2000, nBits);
                D <= conv_std_logic_vector(3000, nBits);
                D <= conv_std_logic_vector(3000, nBits);
                E <= conv_std_logic_vector(4000, nBits);
                E <= conv_std_logic_vector(4000, nBits);
                wait for 1 ns;  -- Wait to stabilize the response
                wait for 1 ns;  -- Wait to stabilize the response
                assert S = (D) report "Could not select forth channel" severity FAILURE;
                assert S = (D) report "Could not select forth channel" severity FAILURE;
 
 
                -- Sel 4 ---------------------------------------------------------------------------
                -- Sel 4 ---------------------------------------------------------------------------
                wait for 1 ns;
                wait for 1 ns;
                REPORT "Select fifth channel" SEVERITY NOTE;
                REPORT "Select fifth channel" SEVERITY NOTE;
                sel <= "100";
                sel <= fromAlu;
                A <= conv_std_logic_vector(0, nBits);
                A <= conv_std_logic_vector(0, nBits);
                B <= conv_std_logic_vector(1000, nBits);
                B <= conv_std_logic_vector(1000, nBits);
                C <= conv_std_logic_vector(2000, nBits);
                C <= conv_std_logic_vector(2000, nBits);
                D <= conv_std_logic_vector(3000, nBits);
                D <= conv_std_logic_vector(3000, nBits);
                E <= conv_std_logic_vector(4000, nBits);
                E <= conv_std_logic_vector(4000, nBits);
                wait for 1 ns;  -- Wait to stabilize the response
                wait for 1 ns;  -- Wait to stabilize the response
                assert S = (E) report "Could not select fifth channel" severity FAILURE;
                assert S = (E) report "Could not select fifth channel" severity FAILURE;
 
 
                -- Finish simulation
                -- Finish simulation
                assert false report "NONE. End of simulation." severity failure;
                assert false report "NONE. End of simulation." severity failure;
   end process;
   end process;
 
 
END;
END;
 
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.