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

Subversion Repositories opencpu32

[/] [opencpu32/] [trunk/] [hdl/] [opencpu32/] [testMultiplexer4_1.vhd] - Blame information for rev 18

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 10 leonardoar
--! @file
2 18 leonardoar
--! @brief Testbench for Multiplexer4_1
3
 
4
--! Use standard library and import the packages (std_logic_1164,std_logic_unsigned,std_logic_arith)
5
LIBRARY ieee;
6 10 leonardoar
use ieee.std_logic_1164.all;
7
use ieee.std_logic_unsigned.all;
8 18 leonardoar
use ieee.std_logic_arith.all;
9
 
10
--! Use CPU Definitions package
11
use work.pkgOpenCPU32.all;
12
 
13
ENTITY testMultiplexer4_1 IS
14
END testMultiplexer4_1;
15
 
16
--! @brief Multiplexer4_1 Testbench file
17
--! @details Test multiplexer operations changing the selection signal
18
--! for more information: http://en.wikipedia.org/wiki/Multiplexer
19
ARCHITECTURE behavior OF testMultiplexer4_1 IS
20
 
21
    --! Component declaration to instantiate the Multiplexer circuit
22
    COMPONENT Multiplexer4_1
23
    generic (n : integer := nBits - 1);                                 --! Generic value (Used to easily change the size of the Alu on the package)
24
         Port ( A   : in  STD_LOGIC_VECTOR (n downto 0); --! First Input
25
           B   : in  STD_LOGIC_VECTOR (n downto 0);      --! Second Input
26
                          C   : in  STD_LOGIC_VECTOR (n downto 0);       --! Third Input
27
                          D   : in  STD_LOGIC_VECTOR (n downto 0);       --! Forth Input
28
           sel : in  STD_LOGIC_VECTOR (1 downto 0);      --! Select inputs (1, 2, 3, 4)
29
           S   : out  STD_LOGIC_VECTOR (n downto 0));    --! Mux Output
30
    END COMPONENT;
31
 
32
 
33
   --Inputs
34
   signal A : std_logic_vector((nBits - 1) downto 0) := (others => '0');  --! Wire to connect Test signal to component
35
   signal B : std_logic_vector((nBits - 1) downto 0) := (others => '0');  --! Wire to connect Test signal to component
36
        signal C : std_logic_vector((nBits - 1) downto 0) := (others => '0');     --! Wire to connect Test signal to component
37
        signal D : std_logic_vector((nBits - 1) downto 0) := (others => '0');     --! Wire to connect Test signal to component
38
   signal sel : STD_LOGIC_VECTOR (1 downto 0) := "00";                                                   --! Wire to connect Test signal to component
39
 
40
        --Outputs
41
   signal S : std_logic_vector((nBits - 1) downto 0);                                                    --! Wire to connect Test signal to component
42
 
43
BEGIN
44
 
45
        --!Instantiate the Unit Under Test (Multiplexer4_1) (Doxygen bug if it's not commented!)
46
   uut: Multiplexer4_1 PORT MAP (
47
          A => A,
48
          B => B,
49
                         C => C,
50
                         D => D,
51
          sel => sel,
52
          S => S
53
        );
54
 
55
   --! Process that will change sel signal and verify the Mux outputs
56
   stim_proc: process
57
   begin
58
      -- Sel 0 ---------------------------------------------------------------------------
59 10 leonardoar
                wait for 1 ps;
60
                REPORT "Select first channel" SEVERITY NOTE;
61 18 leonardoar
                sel <= "00";
62 10 leonardoar
                A <= conv_std_logic_vector(0, nBits);
63
                B <= conv_std_logic_vector(1000, nBits);
64 18 leonardoar
                C <= conv_std_logic_vector(2000, nBits);
65
                D <= conv_std_logic_vector(3000, nBits);
66
                wait for 1 ns;  -- Wait to stabilize the response
67
                assert S = (A) report "Could not select first channel" severity FAILURE;
68
 
69
                -- Sel 1 ---------------------------------------------------------------------------
70 10 leonardoar
                wait for 1 ns;
71
                REPORT "Select second channel" SEVERITY NOTE;
72 18 leonardoar
                sel <= "01";
73 10 leonardoar
                A <= conv_std_logic_vector(0, nBits);
74
                B <= conv_std_logic_vector(1000, nBits);
75 18 leonardoar
                C <= conv_std_logic_vector(2000, nBits);
76
                D <= conv_std_logic_vector(3000, nBits);
77
                wait for 1 ns;  -- Wait to stabilize the response
78
                assert S = (B) report "Could not select second channel" severity FAILURE;
79
 
80
                -- Sel 2 ---------------------------------------------------------------------------
81
                wait for 1 ns;
82
                REPORT "Select second channel" SEVERITY NOTE;
83
                sel <= "10";
84
                A <= conv_std_logic_vector(0, nBits);
85
                B <= conv_std_logic_vector(1000, nBits);
86
                C <= conv_std_logic_vector(2000, nBits);
87
                D <= conv_std_logic_vector(3000, nBits);
88
                wait for 1 ns;  -- Wait to stabilize the response
89
                assert S = (C) report "Could not select second channel" severity FAILURE;
90
 
91
                -- Sel 3 ---------------------------------------------------------------------------
92
                wait for 1 ns;
93
                REPORT "Select second channel" SEVERITY NOTE;
94
                sel <= "11";
95
                A <= conv_std_logic_vector(0, nBits);
96
                B <= conv_std_logic_vector(1000, nBits);
97
                C <= conv_std_logic_vector(2000, nBits);
98
                D <= conv_std_logic_vector(3000, nBits);
99
                wait for 1 ns;  -- Wait to stabilize the response
100
                assert S = (D) report "Could not select second channel" severity FAILURE;
101
 
102
                -- Finish simulation
103
                assert false report "NONE. End of simulation." severity failure;
104
   end process;
105
 
106
END;

powered by: WebSVN 2.1.0

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