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

Subversion Repositories opencpu32

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

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 19 leonardoar
    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
                          E   : in  STD_LOGIC_VECTOR (n downto 0);       --! Fifth Input
29 42 leonardoar
           sel : in  dpMuxInputs;                                                       --! Select inputs (1, 2, 3, 4, 5)
30 18 leonardoar
           S   : out  STD_LOGIC_VECTOR (n downto 0));    --! Mux Output
31
    END COMPONENT;
32
 
33
 
34
   --Inputs
35
   signal A : std_logic_vector((nBits - 1) downto 0) := (others => '0');  --! Wire to connect Test signal to component
36
   signal B : std_logic_vector((nBits - 1) downto 0) := (others => '0');  --! Wire to connect Test signal to component
37
        signal C : std_logic_vector((nBits - 1) downto 0) := (others => '0');     --! Wire to connect Test signal to component
38 19 leonardoar
        signal D : std_logic_vector((nBits - 1) downto 0) := (others => '0');     --! Wire to connect Test signal to component
39
        signal E : std_logic_vector((nBits - 1) downto 0) := (others => '0');     --! Wire to connect Test signal to component
40 42 leonardoar
   signal sel : dpMuxInputs := fromMemory;                                                                                      --! Wire to connect Test signal to component
41 18 leonardoar
 
42
        --Outputs
43
   signal S : std_logic_vector((nBits - 1) downto 0);                                                    --! Wire to connect Test signal to component
44
 
45
BEGIN
46
 
47
        --!Instantiate the Unit Under Test (Multiplexer4_1) (Doxygen bug if it's not commented!)
48
   uut: Multiplexer4_1 PORT MAP (
49
          A => A,
50
          B => B,
51
                         C => C,
52 19 leonardoar
                         D => D,
53
                         E => E,
54 18 leonardoar
          sel => sel,
55
          S => S
56
        );
57
 
58
   --! Process that will change sel signal and verify the Mux outputs
59
   stim_proc: process
60
   begin
61
      -- Sel 0 ---------------------------------------------------------------------------
62 10 leonardoar
                wait for 1 ps;
63
                REPORT "Select first channel" SEVERITY NOTE;
64 42 leonardoar
                sel <= fromMemory;
65 10 leonardoar
                A <= conv_std_logic_vector(0, nBits);
66
                B <= conv_std_logic_vector(1000, nBits);
67 18 leonardoar
                C <= conv_std_logic_vector(2000, nBits);
68 19 leonardoar
                D <= conv_std_logic_vector(3000, nBits);
69
                E <= conv_std_logic_vector(4000, nBits);
70 18 leonardoar
                wait for 1 ns;  -- Wait to stabilize the response
71
                assert S = (A) report "Could not select first channel" severity FAILURE;
72
 
73
                -- Sel 1 ---------------------------------------------------------------------------
74 10 leonardoar
                wait for 1 ns;
75
                REPORT "Select second channel" SEVERITY NOTE;
76 42 leonardoar
                sel <= fromImediate;
77 10 leonardoar
                A <= conv_std_logic_vector(0, nBits);
78
                B <= conv_std_logic_vector(1000, nBits);
79 18 leonardoar
                C <= conv_std_logic_vector(2000, nBits);
80 19 leonardoar
                D <= conv_std_logic_vector(3000, nBits);
81
                E <= conv_std_logic_vector(4000, nBits);
82 18 leonardoar
                wait for 1 ns;  -- Wait to stabilize the response
83
                assert S = (B) report "Could not select second channel" severity FAILURE;
84
 
85
                -- Sel 2 ---------------------------------------------------------------------------
86
                wait for 1 ns;
87 19 leonardoar
                REPORT "Select third channel" SEVERITY NOTE;
88 42 leonardoar
                sel <= fromRegFileA;
89 18 leonardoar
                A <= conv_std_logic_vector(0, nBits);
90
                B <= conv_std_logic_vector(1000, nBits);
91
                C <= conv_std_logic_vector(2000, nBits);
92 19 leonardoar
                D <= conv_std_logic_vector(3000, nBits);
93
                E <= conv_std_logic_vector(4000, nBits);
94 18 leonardoar
                wait for 1 ns;  -- Wait to stabilize the response
95 19 leonardoar
                assert S = (C) report "Could not select third channel" severity FAILURE;
96 18 leonardoar
 
97
                -- Sel 3 ---------------------------------------------------------------------------
98
                wait for 1 ns;
99 19 leonardoar
                REPORT "Select forth channel" SEVERITY NOTE;
100 42 leonardoar
                sel <= fromRegFileB;
101 18 leonardoar
                A <= conv_std_logic_vector(0, nBits);
102
                B <= conv_std_logic_vector(1000, nBits);
103
                C <= conv_std_logic_vector(2000, nBits);
104 19 leonardoar
                D <= conv_std_logic_vector(3000, nBits);
105
                E <= conv_std_logic_vector(4000, nBits);
106 18 leonardoar
                wait for 1 ns;  -- Wait to stabilize the response
107 19 leonardoar
                assert S = (D) report "Could not select forth channel" severity FAILURE;
108
 
109
                -- Sel 4 ---------------------------------------------------------------------------
110
                wait for 1 ns;
111
                REPORT "Select fifth channel" SEVERITY NOTE;
112 42 leonardoar
                sel <= fromAlu;
113 19 leonardoar
                A <= conv_std_logic_vector(0, nBits);
114
                B <= conv_std_logic_vector(1000, nBits);
115
                C <= conv_std_logic_vector(2000, nBits);
116
                D <= conv_std_logic_vector(3000, nBits);
117
                E <= conv_std_logic_vector(4000, nBits);
118
                wait for 1 ns;  -- Wait to stabilize the response
119
                assert S = (E) report "Could not select fifth channel" severity FAILURE;
120 18 leonardoar
 
121
                -- Finish simulation
122
                assert false report "NONE. End of simulation." severity failure;
123
   end process;
124
 
125
END;

powered by: WebSVN 2.1.0

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