-
Notifications
You must be signed in to change notification settings - Fork 1
/
IFSTAGE_TB.vhd
218 lines (185 loc) · 6.11 KB
/
IFSTAGE_TB.vhd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
--------------------------------------------------------------------------------
-- Company:
-- Engineer:
--
-- Create Date: 15:21:40 04/19/2020
-- Design Name:
-- Module Name: C:/Users/Matzik/Xilinx/ergasia1/IFSTAGE_TB.vhd
-- Project Name: ergasia1
-- Target Device:
-- Tool versions:
-- Description:
--
-- VHDL Test Bench Created by ISE for module: IFSTAGE
--
-- Dependencies:
--
-- Revision:
-- Revision 0.01 - File Created
-- Additional Comments:
--
-- Notes:
-- This testbench has been automatically generated using types std_logic and
-- std_logic_vector for the ports of the unit under test. Xilinx recommends
-- that these types always be used for the top-level I/O of a design in order
-- to guarantee that the testbench will bind correctly to the post-implementation
-- simulation model.
--------------------------------------------------------------------------------
LIBRARY ieee;
USE ieee.std_logic_1164.ALL;
-- Uncomment the following library declaration if using
-- arithmetic functions with Signed or Unsigned values
--USE ieee.numeric_std.ALL;
ENTITY IFSTAGE_TB IS
END IFSTAGE_TB;
ARCHITECTURE behavior OF IFSTAGE_TB IS
-- Component Declaration for the Unit Under Test (UUT)
COMPONENT IFSTAGE
PORT(
PC_Immed : IN std_logic_vector(31 downto 0);
PC_sel : IN std_logic;
PC_LdEn : IN std_logic;
Reset : IN std_logic;
Clk : IN std_logic;
PC : OUT std_logic_vector(31 downto 0)
);
END COMPONENT;
COMPONENT RAM
Port ( inst_addr : in STD_LOGIC_VECTOR (10 downto 0);
inst_dout : out STD_LOGIC_VECTOR (31 downto 0);
data_addr : in STD_LOGIC_VECTOR (10 downto 0);
data_we : in STD_LOGIC;
clk : in STD_LOGIC;
data_din : in STD_LOGIC_VECTOR (31 downto 0);
data_dout : out STD_LOGIC_VECTOR (31 downto 0));
END COMPONENT;
COMPONENT MEMSTAGE
PORT(
clk : IN std_logic;
ByteOp : IN std_logic;
MEM_WrEn : IN std_logic;
ALU_MEM_Addr : IN std_logic_vector(31 downto 0);
MEM_DataIn : IN std_logic_vector(31 downto 0);
MEM_DataOut : OUT std_logic_vector(31 downto 0);
MM_Addr : OUT std_logic_vector(31 downto 0);
MM_WrEn : OUT std_logic;
MM_WrData : OUT std_logic_vector(31 downto 0);
MM_RdData : IN std_logic_vector(31 downto 0)
);
END COMPONENT;
--Inputs
signal PC_Immed : std_logic_vector(31 downto 0) := (others => '0');
signal PC_sel : std_logic := '0';
signal PC_LdEn : std_logic := '0';
signal Reset : std_logic := '0';
signal Clk : std_logic := '0';
--Ram Inputs
signal inst_addr : std_logic_vector(10 downto 0) := (others => '0');
signal data_we : std_logic := '0';
signal data_addr : std_logic_vector(10 downto 0) := (others => '0');
signal data_din : std_logic_vector(31 downto 0) := (others => '0');
--Ram Outputs
signal inst_dout : std_logic_vector(31 downto 0);
signal data_dout : std_logic_vector(31 downto 0);
-- MemStage Inputs
signal ByteOp : std_logic := '0';
signal MEM_WrEn : std_logic := '0';
signal ALU_MEM_Addr : std_logic_vector(31 downto 0) := (others => '0');
signal MEM_DataIn : std_logic_vector(31 downto 0) := (others => '0');
signal MM_RdData : std_logic_vector(31 downto 0) := (others => '0');
--MemStage Outputs
signal MEM_DataOut : std_logic_vector(31 downto 0);
signal MM_Addr : std_logic_vector(31 downto 0);
signal MM_WrEn : std_logic;
signal MM_WrData : std_logic_vector(31 downto 0);
--Outputs
signal PC : std_logic_vector(31 downto 0);
-- Clock period definitions
constant Clk_period : time := 10 ns;
BEGIN
-- Instantiate the Unit Under Test (UUT)
ifstageon: IFSTAGE PORT MAP (
PC_Immed => PC_Immed,
PC_sel => PC_sel,
PC_LdEn => PC_LdEn,
Reset => Reset,
Clk => Clk,
PC => PC
);
ramon: RAM PORT MAP (
clk => clk,
inst_addr => PC(12 downto 2),
inst_dout => inst_dout,
data_we => data_we,
data_addr => ALU_MEM_Addr(10 downto 0),
data_din => data_din,
data_dout => data_dout
);
memStageon: MEMSTAGE PORT MAP (
clk => clk,
ByteOp => ByteOp,
MEM_WrEn => MEM_WrEn,
ALU_MEM_Addr => ALU_MEM_Addr,
MEM_DataIn => MEM_DataIn,
MEM_DataOut => MEM_DataOut,
MM_Addr => MM_Addr,
MM_WrEn => MM_WrEn,
MM_WrData => MM_WrData,
MM_RdData => MM_RdData
);
-- Clock process definitions
Clk_process :process
begin
Clk <= '0';
wait for Clk_period/2;
Clk <= '1';
wait for Clk_period/2;
end process;
-- Stimulus process
stim_proc: process
begin
--reset state
PC_LdEn <= '1';
PC_Immed <= "00000000000000000000000000010010";
PC_sel <= '0' ;
Reset<= '1' ;
wait for Clk_period;
--non branch
PC_LdEn <= '1';
PC_Immed <= "00000000000000000000000000010010";
PC_sel <= '0' ;
Reset<= '0' ;
wait for Clk_period;
--branch
PC_LdEn <= '1';
PC_Immed <= "00000000000000000000000000000001";
ALU_MEM_Addr <= x"00000001";
PC_sel <= '1' ;
Reset<= '0' ;
wait for Clk_period;
PC_LdEn <= '0';
PC_Immed <= "00000000000000000000000000011111";
PC_sel <= '1' ;
Reset<= '0' ;
wait for Clk_period;
--non branch
PC_LdEn <= '1';
PC_Immed <= "00000000000000000000000000010111"; --immed shouldn't be considered
PC_sel <= '0' ;
Reset<= '0' ;
wait for Clk_period;
--branch
PC_LdEn <= '1';
PC_Immed <= "00000000000000000000000000011000"; --immed shouldn't be considered
PC_sel <= '1' ;
Reset<= '0' ;
wait for Clk_period;
PC_LdEn <= '1';
PC_Immed <= "00000000000000000000000000010111"; --immed shouldn't be considered
PC_sel <= '1' ;
Reset<= '0' ;
wait for Clk_period;
-- insert stimulus here
wait;
end process;
END;