1 --------------------------------------------------------------------------------
5 -- Create Date: 20:38:31 03/11/2017
7 -- Module Name: E:/University/_Second Year/Computer Architectures/assesment/MyMicroProccessor/Lab_2/DataPaths/DataPath_D_TB.vhd
8 -- Project Name: DataPaths
13 -- VHDL Test Bench Created by ISE for module: DataPath_D
18 -- Revision 0.01 - File Created
19 -- Additional Comments:
22 -- This testbench has been automatically generated using types std_logic and
23 -- std_logic_vector for the ports of the unit under test. Xilinx recommends
24 -- that these types always be used for the top-level I/O of a design in order
25 -- to guarantee that the testbench will bind correctly to the post-implementation
27 --------------------------------------------------------------------------------
29 USE ieee.std_logic_1164.
ALL;
31 USE work.easyprint.
ALL;
33 -- Uncomment the following library declaration if using
34 -- arithmetic functions with Signed or Unsigned values
35 --USE ieee.numeric_std.ALL;
37 ENTITY DataPath_D_TB
IS
40 ARCHITECTURE behavior
OF DataPath_D_TB
IS
43 constant data_size
: NATURAL
:= 16;
44 constant num_registers
: NATURAL
:= 32;
47 -- Component Declaration for the Unit Under Test (UUT)
51 num_registers
: natural
58 R_A
: in STD_LOGIC_VECTOR (log2
(num_registers
)-1 downto 0);
59 R_B
: in STD_LOGIC_VECTOR (log2
(num_registers
)-1 downto 0);
61 W_A
: in STD_LOGIC_VECTOR (log2
(num_registers
)-1 downto 0);
62 IMM
: in STD_LOGIC_VECTOR (data_size
-1 downto 0);
63 M_A
: in STD_LOGIC_VECTOR (data_size
-1 downto 0);
64 M_in
: in STD_LOGIC_VECTOR (data_size
-1 downto 0);
65 SEL
: in STD_LOGIC_VECTOR (7 downto 0);
66 AL
: in STD_LOGIC_VECTOR (3 downto 0);
67 SH
: in STD_LOGIC_VECTOR (log2
(data_size
)-1 downto 0);
69 Flags
: out STD_LOGIC_VECTOR (7 downto 0);
70 M_DA
: out STD_LOGIC_VECTOR (data_size
-1 downto 0);
71 M_out
: out STD_LOGIC_VECTOR (data_size
-1 downto 0)
77 signal clk
: std_logic := '0';
78 signal rst
: std_logic := '1';
79 signal en
: std_logic := '0';
81 signal R_A
: std_logic_vector(log2
(num_registers
)-1 downto 0) := (others => '0');
82 signal R_B
: std_logic_vector(log2
(num_registers
)-1 downto 0) := (others => '0');
83 signal W_EN
: std_logic := '0';
84 signal W_A
: std_logic_vector(log2
(num_registers
)-1 downto 0) := (others => '0');
85 signal IMM
: std_logic_vector(data_size
-1 downto 0) := (others => '0');
86 signal M_A
: std_logic_vector(data_size
-1 downto 0) := (others => '0');
87 signal M_in
: std_logic_vector(data_size
-1 downto 0) := (others => '0');
88 signal SEL
: std_logic_vector(7 downto 0) := (others => '0');
89 signal AL
: std_logic_vector(3 downto 0) := (others => '0');
90 signal SH
: std_logic_vector(log2
(data_size
)-1 downto 0) := (others => '0');
93 signal Flags
: std_logic_vector(7 downto 0);
94 signal M_DA
: std_logic_vector(data_size
-1 downto 0);
95 signal M_out
: std_logic_vector(data_size
-1 downto 0);
97 -- Clock period definitions
98 constant clk_period
: time := 10 ns
;
100 -- Test data definitions
101 type TEST_VECTOR
is RECORD
102 R_A
: STD_LOGIC_VECTOR(log2
(num_registers
)-1 downto 0);
103 R_B
: std_logic_vector(log2
(num_registers
)-1 downto 0);
106 W_A
: std_logic_vector(log2
(num_registers
)-1 downto 0);
108 IMM
: std_logic_vector(data_size
-1 downto 0);
109 M_A
: std_logic_vector(data_size
-1 downto 0);
110 M_in
: std_logic_vector(data_size
-1 downto 0);
111 SEL
: std_logic_vector(7 downto 0);
112 AL
: std_logic_vector(3 downto 0);
113 SH
: std_logic_vector(log2
(data_size
)-1 downto 0) ;
116 type TEST_VECTOR_ARRAY
is ARRAY(NATURAL
RANGE <>) of TEST_VECTOR
;
119 constant test_vectors
: TEST_VECTOR_ARRAY
:= (
120 --R_A, R_B, W_EN, W_A, IMM, M_A, M_in, SEL, AL, SH
121 ( "
00000"
, "
-----", '0', "-----", "----------------", "----------------", "----------------", "0-------", "----", "----" ),
122 ( "
00000"
, "
-----", '0', "-----", "----------------", "----------------", "----------------", "0---01--", "1000", "----" ),
123 ( "
-----", "-----", '0', "-----", X"0005", "----------------", "----------------", "----0110", "1010", "----" ),
124 ( "
-----", "-----", '1', "00001", "----------------", "----------------", "----------------", "--1-----", "----", "----" ),
125 ( "
-----", "-----", '1', "00010", "----------------", "----------------", "----------------", "-11-11--", "1100", "0011" ),
126 ( "
-----", "-----", '0', "-----", "----------------", "----------------", "----------------", "--1-11--", "0000", "----" ),
127 ( "
-----", "-----", '0', "-----", "----------------", "----------------", "----------------", "---0----", "----", "----" ),
128 ( "
-----", "-----", '0', "-----", "----------------", X"1F1F", X"CCCC", "---1----", "----", "----" ),
129 ( "
-----", "-----", '1', "00101", "----------------", "----------------", "----------------", "--0-----", "----", "----" )
135 -- Instantiate the Unit Under Test (UUT)
138 data_size
=> data_size
,
139 num_registers
=> num_registers
160 -- Clock process definitions
164 wait for clk_period
/2;
166 wait for clk_period
/2;
174 -- hold reset state for 100 ns.
179 wait for 2*clk_period
;
181 -- run the test for every set of data
182 for i
in test_vectors
'range loop
184 --wait for clk_period/2;
185 wait until rising_edge
(clk
);
187 -- assign test inputs
188 R_A
<= test_vectors
(i
).R_A
;
189 R_B
<= test_vectors
(i
).R_B
;
191 W_EN
<= test_vectors
(i
).W_EN
;
192 W_A
<= test_vectors
(i
).W_A
;
194 IMM
<= test_vectors
(i
).IMM
;
195 M_A
<= test_vectors
(i
).M_A
;
196 M_in
<= test_vectors
(i
).M_in
;
198 SEL
<= test_vectors
(i
).SEL
;
199 AL
<= test_vectors
(i
).AL
;
200 SH
<= test_vectors
(i
).SH
;
202 --wait for clk_period/2;
203 wait until falling_edge
(clk
);