1 |
2 |
rehayes |
////////////////////////////////////////////////////////////////////////////////
|
2 |
|
|
//
|
3 |
|
|
// WISHBONE revB.2 compliant Xgate Coprocessor - Test Bench
|
4 |
|
|
//
|
5 |
|
|
// Author: Bob Hayes
|
6 |
|
|
// rehayes@opencores.org
|
7 |
|
|
//
|
8 |
|
|
// Downloaded from: http://www.opencores.org/projects/xgate.....
|
9 |
|
|
//
|
10 |
|
|
////////////////////////////////////////////////////////////////////////////////
|
11 |
|
|
// Copyright (c) 2009, Robert Hayes
|
12 |
|
|
//
|
13 |
|
|
// This source file is free software: you can redistribute it and/or modify
|
14 |
|
|
// it under the terms of the GNU Lesser General Public License as published
|
15 |
|
|
// by the Free Software Foundation, either version 3 of the License, or
|
16 |
|
|
// (at your option) any later version.
|
17 |
|
|
//
|
18 |
|
|
// Supplemental terms.
|
19 |
|
|
// * Redistributions of source code must retain the above copyright
|
20 |
|
|
// notice, this list of conditions and the following disclaimer.
|
21 |
|
|
// * Neither the name of the <organization> nor the
|
22 |
|
|
// names of its contributors may be used to endorse or promote products
|
23 |
|
|
// derived from this software without specific prior written permission.
|
24 |
|
|
//
|
25 |
|
|
// THIS SOFTWARE IS PROVIDED BY Robert Hayes ''AS IS'' AND ANY
|
26 |
|
|
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
27 |
|
|
// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
28 |
|
|
// DISCLAIMED. IN NO EVENT SHALL Robert Hayes BE LIABLE FOR ANY
|
29 |
|
|
// DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
30 |
|
|
// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
31 |
|
|
// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
32 |
|
|
// ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
33 |
|
|
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
34 |
|
|
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
35 |
|
|
//
|
36 |
|
|
// You should have received a copy of the GNU General Public License
|
37 |
|
|
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
38 |
|
|
////////////////////////////////////////////////////////////////////////////////
|
39 |
|
|
// 45678901234567890123456789012345678901234567890123456789012345678901234567890
|
40 |
|
|
|
41 |
|
|
|
42 |
|
|
`include "timescale.v"
|
43 |
|
|
|
44 |
|
|
module tst_bench_top();
|
45 |
|
|
|
46 |
|
|
parameter MAX_CHANNEL = 127; // Max XGATE Interrupt Channel Number
|
47 |
5 |
rehayes |
parameter STOP_ON_ERROR = 1'b0;
|
48 |
11 |
rehayes |
parameter MAX_VECTOR = 1800;
|
49 |
2 |
rehayes |
|
50 |
|
|
//
|
51 |
|
|
// wires && regs
|
52 |
|
|
//
|
53 |
|
|
reg mstr_test_clk;
|
54 |
|
|
reg [19:0] vector;
|
55 |
|
|
reg [ 7:0] test_num;
|
56 |
|
|
reg [15:0] wb_temp;
|
57 |
|
|
reg rstn;
|
58 |
|
|
reg sync_reset;
|
59 |
|
|
reg por_reset_b;
|
60 |
|
|
reg stop_mode;
|
61 |
|
|
reg wait_mode;
|
62 |
|
|
reg debug_mode;
|
63 |
|
|
reg scantestmode;
|
64 |
5 |
rehayes |
|
65 |
|
|
reg wbm_ack_i;
|
66 |
2 |
rehayes |
|
67 |
|
|
|
68 |
|
|
wire [31:0] adr;
|
69 |
|
|
wire [15:0] dat_i, dat_o, dat0_i, dat1_i, dat2_i, dat3_i;
|
70 |
|
|
wire we;
|
71 |
|
|
wire stb;
|
72 |
|
|
wire cyc;
|
73 |
|
|
wire ack, ack_1, ack_2, ack_3, ack_4;
|
74 |
|
|
wire inta_1, inta_2, inta_3, inta_4;
|
75 |
|
|
wire count_en_1;
|
76 |
|
|
wire count_flag_1;
|
77 |
|
|
|
78 |
|
|
reg [15:0] q, qq;
|
79 |
|
|
|
80 |
|
|
reg [ 7:0] ram_8 [65535:0];
|
81 |
|
|
wire write_mem_strb_l;
|
82 |
|
|
wire write_mem_strb_h;
|
83 |
|
|
reg [127:0] channel_req;
|
84 |
|
|
wire [ 7:0] xgswt; // XGATE Software Triggers
|
85 |
|
|
wire [MAX_CHANNEL:0] xgif; // Max XGATE Interrupt Channel Number
|
86 |
11 |
rehayes |
wire xg_sw_irq; // Xgate Software interrupt
|
87 |
2 |
rehayes |
|
88 |
|
|
|
89 |
|
|
wire [15:0] xgate_address;
|
90 |
|
|
wire [15:0] write_mem_data;
|
91 |
|
|
wire [15:0] read_mem_data;
|
92 |
5 |
rehayes |
|
93 |
|
|
wire [15:0] wbm_dat_o;
|
94 |
|
|
wire [15:0] wbm_dat_i;
|
95 |
|
|
wire [15:0] wbm_adr_o;
|
96 |
|
|
wire [ 1:0] wbm_sel_o;
|
97 |
2 |
rehayes |
|
98 |
|
|
|
99 |
|
|
// Name Address Locations
|
100 |
|
|
parameter XGATE_XGMCTL = 5'h00;
|
101 |
|
|
parameter XGATE_XGCHID = 5'h01;
|
102 |
|
|
parameter XGATE_XGISPHI = 5'h02;
|
103 |
|
|
parameter XGATE_XGISPLO = 5'h03;
|
104 |
|
|
parameter XGATE_XGVBR = 5'h04;
|
105 |
|
|
parameter XGATE_XGIF_7 = 5'h05;
|
106 |
|
|
parameter XGATE_XGIF_6 = 5'h06;
|
107 |
|
|
parameter XGATE_XGIF_5 = 5'h07;
|
108 |
|
|
parameter XGATE_XGIF_4 = 5'h08;
|
109 |
|
|
parameter XGATE_XGIF_3 = 5'h09;
|
110 |
|
|
parameter XGATE_XGIF_2 = 5'h0a;
|
111 |
|
|
parameter XGATE_XGIF_1 = 5'h0b;
|
112 |
|
|
parameter XGATE_XGIF_0 = 5'h0c;
|
113 |
|
|
parameter XGATE_XGSWT = 5'h0d;
|
114 |
|
|
parameter XGATE_XGSEM = 5'h0e;
|
115 |
|
|
parameter XGATE_RES1 = 5'h0f;
|
116 |
|
|
parameter XGATE_XGCCR = 5'h10;
|
117 |
|
|
parameter XGATE_XGPC = 5'h11;
|
118 |
|
|
parameter XGATE_RES1 = 5'h12;
|
119 |
|
|
parameter XGATE_XGR1 = 5'h13;
|
120 |
|
|
parameter XGATE_XGR2 = 5'h14;
|
121 |
|
|
parameter XGATE_XGR3 = 5'h15;
|
122 |
|
|
parameter XGATE_XGR4 = 5'h16;
|
123 |
|
|
parameter XGATE_XGR5 = 5'h17;
|
124 |
|
|
parameter XGATE_XGR6 = 5'h18;
|
125 |
|
|
parameter XGATE_XGR7 = 5'h19;
|
126 |
11 |
rehayes |
|
127 |
|
|
// Define bits in XGATE Control Register
|
128 |
|
|
parameter XGMCTL_XGEM = 16'h8000;
|
129 |
|
|
parameter XGMCTL_XGFRZM = 16'h4000;
|
130 |
|
|
parameter XGMCTL_XGDBGM = 15'h2000;
|
131 |
|
|
parameter XGMCTL_XGSSM = 15'h1000;
|
132 |
|
|
parameter XGMCTL_XGFACTM = 15'h0800;
|
133 |
|
|
parameter XGMCTL_XGBRKIEM = 15'h0400;
|
134 |
|
|
parameter XGMCTL_XGSWEIFM = 15'h0200;
|
135 |
|
|
parameter XGMCTL_XGIEM = 15'h0100;
|
136 |
|
|
parameter XGMCTL_XGE = 16'h0080;
|
137 |
|
|
parameter XGMCTL_XGFRZ = 16'h0040;
|
138 |
|
|
parameter XGMCTL_XGDBG = 15'h0020;
|
139 |
|
|
parameter XGMCTL_XGSS = 15'h0010;
|
140 |
|
|
parameter XGMCTL_XGFACT = 15'h0008;
|
141 |
|
|
parameter XGMCTL_XGBRKIE = 15'h0004;
|
142 |
|
|
parameter XGMCTL_XGSWEIF = 15'h0002;
|
143 |
|
|
parameter XGMCTL_XGIE = 15'h0001;
|
144 |
|
|
|
145 |
2 |
rehayes |
parameter COP_CNTRL = 5'b0_0000;
|
146 |
|
|
|
147 |
|
|
parameter COP_CNTRL_COP_EVENT = 16'h0100; // COP Enable interrupt request
|
148 |
|
|
|
149 |
5 |
rehayes |
parameter CHECK_POINT = 16'h8000;
|
150 |
|
|
parameter CHANNEL_ACK = CHECK_POINT + 2;
|
151 |
|
|
parameter CHANNEL_ERR = CHECK_POINT + 4;
|
152 |
|
|
reg [ 7:0] check_point_reg;
|
153 |
|
|
reg [ 7:0] channel_ack_reg;
|
154 |
|
|
reg [ 7:0] channel_err_reg;
|
155 |
|
|
event check_point_wrt;
|
156 |
|
|
event channel_ack_wrt;
|
157 |
|
|
event channel_err_wrt;
|
158 |
|
|
reg [15:0] error_count;
|
159 |
11 |
rehayes |
|
160 |
|
|
reg mem_wait_state_enable;
|
161 |
|
|
|
162 |
|
|
// Registers used to mirror internal registers
|
163 |
|
|
reg [15:0] data_xgmctl;
|
164 |
|
|
reg [15:0] data_xgchid;
|
165 |
|
|
reg [15:0] data_xgvbr;
|
166 |
|
|
reg [15:0] data_xgswt;
|
167 |
|
|
reg [15:0] data_xgsem;
|
168 |
2 |
rehayes |
|
169 |
|
|
// initial values and testbench setup
|
170 |
|
|
initial
|
171 |
|
|
begin
|
172 |
|
|
mstr_test_clk = 0;
|
173 |
|
|
vector = 0;
|
174 |
|
|
test_num = 0;
|
175 |
|
|
por_reset_b = 0;
|
176 |
|
|
stop_mode = 0;
|
177 |
|
|
wait_mode = 0;
|
178 |
|
|
debug_mode = 0;
|
179 |
|
|
scantestmode = 0;
|
180 |
5 |
rehayes |
check_point_reg = 0;
|
181 |
|
|
channel_ack_reg = 0;
|
182 |
|
|
channel_err_reg = 0;
|
183 |
|
|
error_count = 0;
|
184 |
11 |
rehayes |
wbm_ack_i = 1;
|
185 |
|
|
mem_wait_state_enable = 0;
|
186 |
2 |
rehayes |
// channel_req = 0;
|
187 |
|
|
|
188 |
|
|
`ifdef WAVES
|
189 |
|
|
$shm_open("waves");
|
190 |
|
|
$shm_probe("AS",tst_bench_top,"AS");
|
191 |
|
|
$display("\nINFO: Signal dump enabled ...\n\n");
|
192 |
|
|
`endif
|
193 |
|
|
|
194 |
|
|
`ifdef WAVES_V
|
195 |
|
|
$dumpfile ("xgate_wave_dump.lxt");
|
196 |
|
|
$dumpvars (0, tst_bench_top);
|
197 |
|
|
$dumpon;
|
198 |
|
|
$display("\nINFO: VCD Signal dump enabled ...\n\n");
|
199 |
|
|
`endif
|
200 |
|
|
|
201 |
|
|
end
|
202 |
|
|
|
203 |
|
|
// generate clock
|
204 |
|
|
always #20 mstr_test_clk = ~mstr_test_clk;
|
205 |
|
|
|
206 |
5 |
rehayes |
// Keep a count of how many clocks we've simulated
|
207 |
2 |
rehayes |
always @(posedge mstr_test_clk)
|
208 |
11 |
rehayes |
begin
|
209 |
|
|
vector <= vector + 1;
|
210 |
|
|
if (vector > MAX_VECTOR)
|
211 |
|
|
begin
|
212 |
|
|
error_count = error_count + 1;
|
213 |
|
|
$display("\n ------ !!!!! Simulation Timeout at vector=%d\n -------", vector);
|
214 |
|
|
wrap_up;
|
215 |
|
|
end
|
216 |
|
|
end
|
217 |
2 |
rehayes |
|
218 |
11 |
rehayes |
|
219 |
5 |
rehayes |
// Throw in some wait states from the memory
|
220 |
|
|
always @(posedge mstr_test_clk)
|
221 |
11 |
rehayes |
if (((vector % 5) == 0) && (xgate.risc.load_next_inst || xgate.risc.data_access))
|
222 |
|
|
// if ((vector % 5) == 0)
|
223 |
5 |
rehayes |
wbm_ack_i <= 1'b0;
|
224 |
|
|
else
|
225 |
|
|
wbm_ack_i <= 1'b1;
|
226 |
2 |
rehayes |
|
227 |
11 |
rehayes |
|
228 |
2 |
rehayes |
// Write memory interface to RAM
|
229 |
|
|
always @(posedge mstr_test_clk)
|
230 |
|
|
begin
|
231 |
5 |
rehayes |
if (write_mem_strb_l && !write_mem_strb_h && wbm_ack_i)
|
232 |
|
|
ram_8[xgate_address] <= write_mem_data[7:0];
|
233 |
|
|
if (write_mem_strb_h && !write_mem_strb_l && wbm_ack_i)
|
234 |
|
|
ram_8[xgate_address] <= write_mem_data[7:0];
|
235 |
|
|
if (write_mem_strb_h && write_mem_strb_l && wbm_ack_i)
|
236 |
2 |
rehayes |
begin
|
237 |
5 |
rehayes |
ram_8[xgate_address] <= write_mem_data[15:8];
|
238 |
|
|
ram_8[xgate_address+1] <= write_mem_data[7:0];
|
239 |
2 |
rehayes |
end
|
240 |
|
|
end
|
241 |
|
|
|
242 |
|
|
// Special Memory Mapped Testbench Registers
|
243 |
|
|
always @(posedge mstr_test_clk or negedge rstn)
|
244 |
|
|
begin
|
245 |
|
|
if (!rstn)
|
246 |
|
|
begin
|
247 |
5 |
rehayes |
check_point_reg <= 0;
|
248 |
|
|
channel_ack_reg <= 0;
|
249 |
|
|
channel_err_reg <= 0;
|
250 |
2 |
rehayes |
end
|
251 |
5 |
rehayes |
if (write_mem_strb_l && wbm_ack_i && (xgate_address == CHECK_POINT))
|
252 |
|
|
begin
|
253 |
|
|
check_point_reg <= write_mem_data[7:0];
|
254 |
11 |
rehayes |
#1;
|
255 |
5 |
rehayes |
-> check_point_wrt;
|
256 |
|
|
end
|
257 |
|
|
if (write_mem_strb_l && wbm_ack_i && (xgate_address == CHANNEL_ACK))
|
258 |
|
|
begin
|
259 |
|
|
channel_ack_reg <= write_mem_data[7:0];
|
260 |
11 |
rehayes |
#1;
|
261 |
5 |
rehayes |
-> channel_ack_wrt;
|
262 |
|
|
end
|
263 |
|
|
if (write_mem_strb_l && wbm_ack_i && (xgate_address == CHANNEL_ERR))
|
264 |
|
|
begin
|
265 |
|
|
channel_err_reg <= write_mem_data[7:0];
|
266 |
11 |
rehayes |
#1;
|
267 |
5 |
rehayes |
-> channel_err_wrt;
|
268 |
|
|
end
|
269 |
2 |
rehayes |
end
|
270 |
|
|
|
271 |
5 |
rehayes |
always @check_point_wrt
|
272 |
11 |
rehayes |
$display("\nSoftware Checkpoint #%h -- at vector=%d\n", check_point_reg, vector);
|
273 |
2 |
rehayes |
|
274 |
5 |
rehayes |
always @channel_err_wrt
|
275 |
|
|
begin
|
276 |
|
|
$display("\n ------ !!!!! Software Error #%d -- at vector=%d\n -------", channel_err_reg, vector);
|
277 |
|
|
error_count = error_count + 1;
|
278 |
|
|
if (STOP_ON_ERROR == 1'b1)
|
279 |
|
|
wrap_up;
|
280 |
|
|
end
|
281 |
|
|
|
282 |
2 |
rehayes |
wire [ 6:0] current_active_channel = xgate.risc.xgchid;
|
283 |
5 |
rehayes |
always @channel_ack_wrt
|
284 |
2 |
rehayes |
clear_channel(current_active_channel);
|
285 |
|
|
|
286 |
|
|
|
287 |
|
|
// hookup wishbone master model
|
288 |
|
|
wb_master_model #(.dwidth(16), .awidth(32))
|
289 |
|
|
u0 (
|
290 |
|
|
.clk(mstr_test_clk),
|
291 |
|
|
.rst(rstn),
|
292 |
|
|
.adr(adr),
|
293 |
|
|
.din(dat_i),
|
294 |
|
|
.dout(dat_o),
|
295 |
|
|
.cyc(cyc),
|
296 |
|
|
.stb(stb),
|
297 |
|
|
.we(we),
|
298 |
|
|
.sel(),
|
299 |
|
|
.ack(ack),
|
300 |
|
|
.err(1'b0),
|
301 |
|
|
.rty(1'b0)
|
302 |
|
|
);
|
303 |
|
|
|
304 |
|
|
|
305 |
|
|
// Address decoding for different XGATE module instances
|
306 |
|
|
wire stb0 = stb && ~adr[6] && ~adr[5];
|
307 |
|
|
wire stb1 = stb && ~adr[6] && adr[5];
|
308 |
|
|
wire stb2 = stb && adr[6] && ~adr[5];
|
309 |
|
|
wire stb3 = stb && adr[6] && adr[5];
|
310 |
|
|
|
311 |
|
|
assign dat1_i = 16'h0000;
|
312 |
|
|
assign dat2_i = 16'h0000;
|
313 |
|
|
assign dat3_i = 16'h0000;
|
314 |
|
|
assign ack_2 = 1'b0;
|
315 |
|
|
assign ack_3 = 1'b0;
|
316 |
|
|
assign ack_4 = 1'b0;
|
317 |
|
|
|
318 |
|
|
// Create the Read Data Bus
|
319 |
|
|
assign dat_i = ({16{stb0}} & dat0_i) |
|
320 |
|
|
({16{stb1}} & dat1_i) |
|
321 |
|
|
({16{stb2}} & dat2_i) |
|
322 |
|
|
({16{stb3}} & {8'b0, dat3_i[7:0]});
|
323 |
|
|
|
324 |
|
|
assign ack = ack_1 || ack_2 || ack_3 || ack_4;
|
325 |
|
|
|
326 |
|
|
assign read_mem_data = {ram_8[xgate_address], ram_8[xgate_address+1]};
|
327 |
|
|
|
328 |
5 |
rehayes |
// hookup XGATE core - Parameters take all default values
|
329 |
2 |
rehayes |
// Async Reset, 16 bit Bus, 16 bit Granularity
|
330 |
11 |
rehayes |
xgate_top #(.SINGLE_CYCLE(1'b1),
|
331 |
2 |
rehayes |
.MAX_CHANNEL(MAX_CHANNEL)) // Max XGATE Interrupt Channel Number
|
332 |
|
|
xgate(
|
333 |
5 |
rehayes |
// Wishbone slave interface
|
334 |
|
|
.wbs_clk_i( mstr_test_clk ),
|
335 |
|
|
.wbs_rst_i( 1'b0 ), // sync_reset
|
336 |
|
|
.arst_i( rstn ), // async resetn
|
337 |
|
|
.wbs_adr_i( adr[4:0] ),
|
338 |
|
|
.wbs_dat_i( dat_o ),
|
339 |
|
|
.wbs_dat_o( dat0_i ),
|
340 |
|
|
.wbs_we_i( we ),
|
341 |
|
|
.wbs_stb_i( stb0 ),
|
342 |
|
|
.wbs_cyc_i( cyc ),
|
343 |
2 |
rehayes |
.wbs_sel_i( 2'b11 ),
|
344 |
5 |
rehayes |
.wbs_ack_o( ack_1 ),
|
345 |
2 |
rehayes |
|
346 |
5 |
rehayes |
// Wishbone master Signals
|
347 |
|
|
.wbm_dat_o( write_mem_data ),
|
348 |
|
|
.wbm_we_o( wbm_we_o ),
|
349 |
|
|
.wbm_stb_o( wbm_stb_o ),
|
350 |
|
|
.wbm_cyc_o( wbm_cyc_o ),
|
351 |
|
|
.wbm_sel_o( wbm_sel_o ),
|
352 |
|
|
.wbm_adr_o( xgate_address ),
|
353 |
|
|
.wbm_dat_i( read_mem_data ),
|
354 |
|
|
.wbm_ack_i( wbm_ack_i ),
|
355 |
|
|
|
356 |
2 |
rehayes |
.xgif( xgif ), // XGATE Interrupt Flag
|
357 |
11 |
rehayes |
.xg_sw_irq( xg_sw_irq ),
|
358 |
2 |
rehayes |
.risc_clk( mstr_test_clk ),
|
359 |
5 |
rehayes |
.xgswt( xgswt ),
|
360 |
2 |
rehayes |
.chan_req_i( {channel_req[127:40], xgswt, channel_req[31:0]} ),
|
361 |
|
|
.write_mem_strb_l( write_mem_strb_l ),
|
362 |
|
|
.write_mem_strb_h( write_mem_strb_h ),
|
363 |
|
|
.scantestmode( scantestmode )
|
364 |
|
|
);
|
365 |
|
|
|
366 |
|
|
|
367 |
|
|
|
368 |
|
|
////////////////////////////////////////////////////////////////////////////////
|
369 |
|
|
////////////////////////////////////////////////////////////////////////////////
|
370 |
|
|
////////////////////////////////////////////////////////////////////////////////
|
371 |
|
|
|
372 |
|
|
// Test Program
|
373 |
|
|
initial
|
374 |
|
|
begin
|
375 |
11 |
rehayes |
$readmemh("../../../bench/verilog/inst_test.v", ram_8);
|
376 |
2 |
rehayes |
$display("\nstatus at time: %t Testbench started", $time);
|
377 |
|
|
|
378 |
|
|
// reset system
|
379 |
|
|
rstn = 1'b1; // negate reset
|
380 |
|
|
channel_req = 1; //
|
381 |
|
|
repeat(1) @(posedge mstr_test_clk);
|
382 |
|
|
sync_reset = 1'b1; // Make the sync reset 1 clock cycle long
|
383 |
|
|
#2; // move the async reset away from the clock edge
|
384 |
|
|
rstn = 1'b0; // assert async reset
|
385 |
|
|
#5; // Keep the async reset pulse with less than a clock cycle
|
386 |
|
|
rstn = 1'b1; // negate async reset
|
387 |
|
|
por_reset_b = 1'b1;
|
388 |
|
|
channel_req = 0; //
|
389 |
|
|
repeat(1) @(posedge mstr_test_clk);
|
390 |
|
|
sync_reset = 1'b0;
|
391 |
|
|
channel_req = 0; //
|
392 |
|
|
|
393 |
|
|
$display("\nstatus at time: %t done reset", $time);
|
394 |
|
|
|
395 |
11 |
rehayes |
test_inst_set;
|
396 |
2 |
rehayes |
|
397 |
11 |
rehayes |
test_debug_mode;
|
398 |
2 |
rehayes |
|
399 |
11 |
rehayes |
// test_debug_bit;
|
400 |
2 |
rehayes |
|
401 |
5 |
rehayes |
wrap_up;
|
402 |
2 |
rehayes |
//
|
403 |
|
|
// program core
|
404 |
|
|
//
|
405 |
|
|
|
406 |
|
|
reg_test_16;
|
407 |
|
|
|
408 |
|
|
repeat(10) @(posedge mstr_test_clk);
|
409 |
|
|
|
410 |
5 |
rehayes |
wrap_up;
|
411 |
2 |
rehayes |
end
|
412 |
|
|
|
413 |
11 |
rehayes |
// Test Debug bit operation
|
414 |
|
|
task test_debug_bit;
|
415 |
2 |
rehayes |
begin
|
416 |
11 |
rehayes |
test_num = test_num + 1;
|
417 |
|
|
$display("\nTEST #%d Starts at vector=%d, test_debug_mode", test_num, vector);
|
418 |
|
|
$readmemh("../../../bench/verilog/debug_test.v", ram_8);
|
419 |
|
|
|
420 |
|
|
data_xgmctl = XGMCTL_XGBRKIEM | XGMCTL_XGBRKIE;
|
421 |
|
|
u0.wb_write(0, XGATE_XGMCTL, data_xgmctl); // Enable interrupt on BRK instruction
|
422 |
|
|
|
423 |
|
|
activate_thread_sw(2);
|
424 |
|
|
|
425 |
|
|
repeat(25) @(posedge mstr_test_clk);
|
426 |
|
|
|
427 |
|
|
data_xgmctl = XGMCTL_XGDBGM | XGMCTL_XGDBG;
|
428 |
|
|
u0.wb_write(0, XGATE_XGMCTL, data_xgmctl); // Set Debug Mode Control Bit
|
429 |
|
|
// data_xgmctl = XGMCTL_XGDBGM;
|
430 |
|
|
// u0.wb_write(0, XGATE_XGMCTL, data_xgmctl); // Clear Debug Mode Control Bit
|
431 |
|
|
// Should be back in Run Mode
|
432 |
|
|
wait_irq_set(1);
|
433 |
|
|
u0.wb_write(1, XGATE_XGIF_0, 16'h0004);
|
434 |
|
|
|
435 |
|
|
data_xgmctl = XGMCTL_XGSWEIFM | XGMCTL_XGSWEIF | XGMCTL_XGBRKIEM;
|
436 |
|
|
u0.wb_write(0, XGATE_XGMCTL, data_xgmctl); // Clear Software Interrupt and BRK Interrupt Enable Bit
|
437 |
|
|
repeat(15) @(posedge mstr_test_clk);
|
438 |
|
|
|
439 |
2 |
rehayes |
end
|
440 |
|
|
endtask
|
441 |
|
|
|
442 |
11 |
rehayes |
// Test Debug mode operation
|
443 |
|
|
task test_debug_mode;
|
444 |
2 |
rehayes |
begin
|
445 |
11 |
rehayes |
test_num = test_num + 1;
|
446 |
|
|
$display("\nTEST #%d Starts at vector=%d, test_debug_mode", test_num, vector);
|
447 |
|
|
$readmemh("../../../bench/verilog/debug_test.v", ram_8);
|
448 |
|
|
|
449 |
|
|
data_xgmctl = XGMCTL_XGBRKIEM | XGMCTL_XGBRKIE;
|
450 |
|
|
u0.wb_write(0, XGATE_XGMCTL, data_xgmctl); // Enable interrupt on BRK instruction
|
451 |
|
|
|
452 |
|
|
activate_thread_sw(1);
|
453 |
|
|
|
454 |
|
|
wait_debug_set; // Debug Status bit is set by BRK instruction
|
455 |
|
|
|
456 |
|
|
u0.wb_cmp(0, XGATE_XGPC, 16'h203a); // See Program code (BRK).
|
457 |
|
|
u0.wb_cmp(0, XGATE_XGR3, 16'h0001); // See Program code.R3 = 1
|
458 |
|
|
|
459 |
|
|
data_xgmctl = XGMCTL_XGSSM | XGMCTL_XGSS;
|
460 |
|
|
|
461 |
|
|
u0.wb_write(0, XGATE_XGMCTL, data_xgmctl); // Do a Single Step (Load ADDL instruction)
|
462 |
|
|
repeat(5) @(posedge mstr_test_clk);
|
463 |
|
|
u0.wb_cmp(0, XGATE_XGPC, 16'h203c); // PC + 2.
|
464 |
|
|
|
465 |
|
|
u0.wb_write(0, XGATE_XGMCTL, data_xgmctl); // Do a Single Step (Load NOP instruction)
|
466 |
|
|
repeat(5) @(posedge mstr_test_clk); // Execute ADDL instruction
|
467 |
|
|
u0.wb_cmp(0, XGATE_XGR3, 16'h0002); // See Program code.(R3 <= R3 + 1)
|
468 |
|
|
u0.wb_cmp(0, XGATE_XGCCR, 16'h0000); // See Program code.
|
469 |
|
|
u0.wb_cmp(0, XGATE_XGPC, 16'h203e); // PC + 2.
|
470 |
|
|
repeat(5) @(posedge mstr_test_clk);
|
471 |
|
|
u0.wb_cmp(0, XGATE_XGPC, 16'h203e); // Still no change.
|
472 |
|
|
|
473 |
|
|
u0.wb_write(0, XGATE_XGMCTL, data_xgmctl); // Do a Single Step (Load BRA instruction)
|
474 |
|
|
repeat(9) @(posedge mstr_test_clk); // Execute NOP instruction
|
475 |
|
|
u0.wb_cmp(0, XGATE_XGPC, 16'h2040); // See Program code.
|
476 |
|
|
|
477 |
|
|
|
478 |
|
|
u0.wb_write(0, XGATE_XGMCTL, data_xgmctl); // Do a Single Step
|
479 |
|
|
repeat(5) @(posedge mstr_test_clk); // Execute BRA instruction
|
480 |
|
|
u0.wb_cmp(0, XGATE_XGPC, 16'h2064); // PC = Branch destination.
|
481 |
|
|
// Load ADDL instruction
|
482 |
|
|
|
483 |
|
|
u0.wb_write(0, XGATE_XGMCTL, data_xgmctl); // Do a Single Step (Load LDW R7 instruction)
|
484 |
|
|
repeat(5) @(posedge mstr_test_clk); // Execute ADDL instruction
|
485 |
|
|
u0.wb_cmp(0, XGATE_XGPC, 16'h2066); // PC + 2.
|
486 |
|
|
u0.wb_cmp(0, XGATE_XGR3, 16'h0003); // See Program code.(R3 <= R3 + 1)
|
487 |
|
|
|
488 |
|
|
u0.wb_write(0, XGATE_XGMCTL, data_xgmctl); // Do a Single Step (LDW R7)
|
489 |
|
|
repeat(5) @(posedge mstr_test_clk);
|
490 |
|
|
u0.wb_cmp(0, XGATE_XGPC, 16'h2068); // PC + 2.
|
491 |
|
|
u0.wb_cmp(0, XGATE_XGR7, 16'h00c3); // See Program code
|
492 |
|
|
|
493 |
|
|
repeat(1) @(posedge mstr_test_clk);
|
494 |
|
|
u0.wb_write(0, XGATE_XGMCTL, data_xgmctl); // Do a Single Step (BRA)
|
495 |
|
|
repeat(9) @(posedge mstr_test_clk);
|
496 |
|
|
u0.wb_cmp(0, XGATE_XGPC, 16'h2048); // See Program code.
|
497 |
|
|
|
498 |
|
|
u0.wb_write(0, XGATE_XGMCTL, data_xgmctl); // Do a Single Step (STW R3)
|
499 |
|
|
repeat(5) @(posedge mstr_test_clk);
|
500 |
|
|
u0.wb_cmp(0, XGATE_XGPC, 16'h204a); // PC + 2.
|
501 |
|
|
u0.wb_cmp(0, XGATE_XGR3, 16'h0003); // See Program code.(R3 <= R3 + 1)
|
502 |
|
|
|
503 |
|
|
u0.wb_write(0, XGATE_XGMCTL, data_xgmctl); // Do a Single Step (R3 <= R3 + 1)
|
504 |
|
|
repeat(5) @(posedge mstr_test_clk);
|
505 |
|
|
u0.wb_cmp(0, XGATE_XGPC, 16'h204c); // PC + 2.
|
506 |
|
|
|
507 |
|
|
repeat(5) @(posedge mstr_test_clk);
|
508 |
|
|
|
509 |
|
|
data_xgmctl = XGMCTL_XGDBGM | XGMCTL_XGDBG;
|
510 |
|
|
u0.wb_write(0, XGATE_XGMCTL, data_xgmctl); // Set Debug Mode Control Bit
|
511 |
|
|
data_xgmctl = XGMCTL_XGDBGM;
|
512 |
|
|
u0.wb_write(0, XGATE_XGMCTL, data_xgmctl); // Clear Debug Mode Control Bit
|
513 |
|
|
// Should be back in Run Mode
|
514 |
|
|
wait_irq_set(1);
|
515 |
|
|
u0.wb_write(1, XGATE_XGIF_0, 16'h0002);
|
516 |
|
|
|
517 |
|
|
data_xgmctl = XGMCTL_XGSWEIFM | XGMCTL_XGSWEIF | XGMCTL_XGBRKIEM;
|
518 |
|
|
u0.wb_write(0, XGATE_XGMCTL, data_xgmctl); // Clear Software Interrupt and BRK Interrupt Enable Bit
|
519 |
|
|
repeat(15) @(posedge mstr_test_clk);
|
520 |
|
|
|
521 |
2 |
rehayes |
end
|
522 |
|
|
endtask
|
523 |
|
|
|
524 |
11 |
rehayes |
// Test instruction set
|
525 |
|
|
task test_inst_set;
|
526 |
|
|
begin
|
527 |
|
|
test_num = test_num + 1;
|
528 |
|
|
$display("\nTEST #%d Starts at vector=%d, inst_test", test_num, vector);
|
529 |
|
|
|
530 |
|
|
activate_thread_sw(1);
|
531 |
|
|
wait_irq_set(1);
|
532 |
|
|
u0.wb_write(1, XGATE_XGIF_0, 16'h0002);
|
533 |
|
|
|
534 |
|
|
activate_thread_sw(2);
|
535 |
|
|
wait_irq_set(2);
|
536 |
|
|
u0.wb_write(1, XGATE_XGIF_0, 16'h0004);
|
537 |
|
|
|
538 |
|
|
activate_thread_sw(3);
|
539 |
|
|
wait_irq_set(3);
|
540 |
|
|
u0.wb_write(1, XGATE_XGIF_0, 16'h0008);
|
541 |
|
|
|
542 |
|
|
activate_thread_sw(4);
|
543 |
|
|
wait_irq_set(4);
|
544 |
|
|
u0.wb_write(1, XGATE_XGIF_0, 16'h0010);
|
545 |
|
|
|
546 |
|
|
activate_thread_sw(5);
|
547 |
|
|
wait_irq_set(5);
|
548 |
|
|
u0.wb_write(1, XGATE_XGIF_0, 16'h0020);
|
549 |
|
|
|
550 |
|
|
activate_thread_sw(6);
|
551 |
|
|
wait_irq_set(6);
|
552 |
|
|
u0.wb_write(1, XGATE_XGIF_0, 16'h0040);
|
553 |
|
|
|
554 |
|
|
activate_thread_sw(7);
|
555 |
|
|
wait_irq_set(7);
|
556 |
|
|
u0.wb_write(1, XGATE_XGIF_0, 16'h0080);
|
557 |
|
|
|
558 |
|
|
activate_thread_sw(8);
|
559 |
|
|
wait_irq_set(8);
|
560 |
|
|
u0.wb_write(1, XGATE_XGIF_0, 16'h0100);
|
561 |
|
|
|
562 |
|
|
activate_thread_sw(9);
|
563 |
|
|
wait_irq_set(9);
|
564 |
|
|
u0.wb_write(1, XGATE_XGIF_0, 16'h0200);
|
565 |
|
|
|
566 |
|
|
u0.wb_write(1, XGATE_XGSEM, 16'h5050);
|
567 |
|
|
u0.wb_cmp(0, XGATE_XGSEM, 16'h0050); //
|
568 |
|
|
activate_thread_sw(10);
|
569 |
|
|
wait_irq_set(10);
|
570 |
|
|
u0.wb_write(1, XGATE_XGIF_0, 16'h0400);
|
571 |
|
|
|
572 |
|
|
u0.wb_write(1, XGATE_XGSEM, 16'hff00); // clear the old settings
|
573 |
|
|
u0.wb_cmp(0, XGATE_XGSEM, 16'h0000); //
|
574 |
|
|
u0.wb_write(1, XGATE_XGSEM, 16'ha0a0); // Verify that bits were unlocked by RISC
|
575 |
|
|
u0.wb_cmp(0, XGATE_XGSEM, 16'h00a0); // Verify bits were set
|
576 |
|
|
u0.wb_write(1, XGATE_XGSEM, 16'hff08); // Try to set the bit that was left locked by the RISC
|
577 |
|
|
u0.wb_cmp(0, XGATE_XGSEM, 16'h0000); // Verify no bits were set
|
578 |
|
|
|
579 |
|
|
repeat(20) @(posedge mstr_test_clk);
|
580 |
|
|
|
581 |
|
|
dump_ram(0);
|
582 |
|
|
end
|
583 |
|
|
endtask
|
584 |
|
|
|
585 |
2 |
rehayes |
// check register bits - reset, read/write
|
586 |
|
|
task reg_test_16;
|
587 |
|
|
begin
|
588 |
|
|
test_num = test_num + 1;
|
589 |
|
|
$display("TEST #%d Starts at vector=%d, reg_test_16", test_num, vector);
|
590 |
|
|
u0.wb_cmp(0, XGATE_XGMCTL, 16'h0000); // verify reset
|
591 |
|
|
u0.wb_cmp(0, XGATE_XGCHID, 16'h0000); // verify reset
|
592 |
|
|
u0.wb_cmp(0, XGATE_XGISPHI, 16'h0000); // verify reset
|
593 |
|
|
u0.wb_cmp(0, XGATE_XGISPLO, 16'h0000); // verify reset
|
594 |
|
|
u0.wb_cmp(0, XGATE_XGVBR, 16'h0000); // verify reset
|
595 |
|
|
u0.wb_cmp(0, XGATE_XGIF_7, 16'h0000); // verify reset
|
596 |
|
|
u0.wb_cmp(0, XGATE_XGIF_6, 16'h0000); // verify reset
|
597 |
|
|
u0.wb_cmp(0, XGATE_XGIF_5, 16'h0000); // verify reset
|
598 |
|
|
u0.wb_cmp(0, XGATE_XGIF_4, 16'h0000); // verify reset
|
599 |
|
|
u0.wb_cmp(0, XGATE_XGIF_3, 16'h0000); // verify reset
|
600 |
|
|
u0.wb_cmp(0, XGATE_XGIF_2, 16'h0000); // verify reset
|
601 |
|
|
u0.wb_cmp(0, XGATE_XGIF_1, 16'h0000); // verify reset
|
602 |
|
|
u0.wb_cmp(0, XGATE_XGIF_0, 16'h0000); // verify reset
|
603 |
|
|
u0.wb_cmp(0, XGATE_XGSWT, 16'h0000); // verify reset
|
604 |
|
|
u0.wb_cmp(0, XGATE_XGSEM, 16'h0000); // verify reset
|
605 |
|
|
u0.wb_cmp(0, XGATE_XGCCR, 16'h0000); // verify reset
|
606 |
|
|
u0.wb_cmp(0, XGATE_XGPC, 16'h0000); // verify reset
|
607 |
|
|
u0.wb_cmp(0, XGATE_XGR1, 16'h0000); // verify reset
|
608 |
|
|
u0.wb_cmp(0, XGATE_XGR2, 16'h0000); // verify reset
|
609 |
|
|
u0.wb_cmp(0, XGATE_XGR3, 16'h0000); // verify reset
|
610 |
|
|
u0.wb_cmp(0, XGATE_XGR4, 16'h0000); // verify reset
|
611 |
|
|
u0.wb_cmp(0, XGATE_XGR5, 16'h0000); // verify reset
|
612 |
|
|
u0.wb_cmp(0, XGATE_XGR6, 16'h0000); // verify reset
|
613 |
|
|
u0.wb_cmp(0, XGATE_XGR7, 16'h0000); // verify reset
|
614 |
|
|
|
615 |
|
|
u0.wb_write(1, XGATE_XGR1, 16'h5555);
|
616 |
|
|
u0.wb_cmp( 0, XGATE_XGR1, 16'h5555);
|
617 |
|
|
u0.wb_write(1, XGATE_XGR2, 16'haaaa);
|
618 |
|
|
u0.wb_cmp( 0, XGATE_XGR2, 16'haaaa);
|
619 |
|
|
u0.wb_write(1, XGATE_XGR3, 16'h9999);
|
620 |
|
|
u0.wb_cmp( 0, XGATE_XGR3, 16'h9999);
|
621 |
|
|
u0.wb_write(1, XGATE_XGR4, 16'hcccc);
|
622 |
|
|
u0.wb_cmp( 0, XGATE_XGR4, 16'hcccc);
|
623 |
|
|
u0.wb_write(1, XGATE_XGR5, 16'h3333);
|
624 |
|
|
u0.wb_cmp( 0, XGATE_XGR5, 16'h3333);
|
625 |
|
|
u0.wb_write(1, XGATE_XGR6, 16'h6666);
|
626 |
|
|
u0.wb_cmp( 0, XGATE_XGR6, 16'h6666);
|
627 |
|
|
u0.wb_write(1, XGATE_XGR7, 16'ha5a5);
|
628 |
|
|
u0.wb_cmp( 0, XGATE_XGR7, 16'ha5a5);
|
629 |
|
|
|
630 |
|
|
u0.wb_write(1, XGATE_XGPC, 16'h5a5a);
|
631 |
|
|
u0.wb_cmp( 0, XGATE_XGPC, 16'h5a5a);
|
632 |
|
|
|
633 |
|
|
u0.wb_write(1, XGATE_XGCCR, 16'hfffa);
|
634 |
|
|
u0.wb_cmp( 0, XGATE_XGCCR, 16'h000a);
|
635 |
|
|
u0.wb_write(1, XGATE_XGCCR, 16'hfff5);
|
636 |
|
|
u0.wb_cmp( 0, XGATE_XGCCR, 16'h0005);
|
637 |
|
|
|
638 |
|
|
end
|
639 |
|
|
endtask
|
640 |
|
|
|
641 |
|
|
|
642 |
11 |
rehayes |
// Poll for XGATE Interrupt set
|
643 |
|
|
task wait_irq_set;
|
644 |
|
|
input [ 6:0] chan_val;
|
645 |
|
|
begin
|
646 |
|
|
while(!xgif[chan_val])
|
647 |
|
|
@(posedge mstr_test_clk); // poll it until it is set
|
648 |
|
|
$display("XGATE Interrupt Request #%d set detected at vector =%d", chan_val, vector);
|
649 |
|
|
end
|
650 |
|
|
endtask
|
651 |
2 |
rehayes |
|
652 |
11 |
rehayes |
// Poll for debug bit set
|
653 |
|
|
task wait_debug_set;
|
654 |
|
|
begin
|
655 |
|
|
u0.wb_read(1, XGATE_XGMCTL, q);
|
656 |
|
|
while(~|(q & XGMCTL_XGDBG))
|
657 |
|
|
u0.wb_read(1, XGATE_XGMCTL, q); // poll it until it is set
|
658 |
|
|
$display("DEBUG Flag set detected at vector =%d", vector);
|
659 |
|
|
end
|
660 |
|
|
endtask
|
661 |
2 |
rehayes |
|
662 |
11 |
rehayes |
|
663 |
2 |
rehayes |
task system_reset; // reset system
|
664 |
|
|
begin
|
665 |
|
|
repeat(1) @(posedge mstr_test_clk);
|
666 |
|
|
sync_reset = 1'b1; // Make the sync reset 1 clock cycle long
|
667 |
|
|
#2; // move the async reset away from the clock edge
|
668 |
|
|
rstn = 1'b0; // assert async reset
|
669 |
|
|
#5; // Keep the async reset pulse with less than a clock cycle
|
670 |
|
|
rstn = 1'b1; // negate async reset
|
671 |
|
|
repeat(1) @(posedge mstr_test_clk);
|
672 |
|
|
sync_reset = 1'b0;
|
673 |
|
|
|
674 |
|
|
$display("\nstatus: %t System Reset Task Done", $time);
|
675 |
|
|
test_num = test_num + 1;
|
676 |
|
|
|
677 |
|
|
repeat(2) @(posedge mstr_test_clk);
|
678 |
|
|
end
|
679 |
|
|
endtask
|
680 |
|
|
|
681 |
|
|
|
682 |
|
|
task activate_channel;
|
683 |
|
|
input [ 6:0] chan_val;
|
684 |
|
|
begin
|
685 |
|
|
$display("Activating Channel %d", chan_val);
|
686 |
|
|
|
687 |
|
|
channel_req[chan_val] = 1'b1; //
|
688 |
|
|
repeat(1) @(posedge mstr_test_clk);
|
689 |
|
|
end
|
690 |
|
|
endtask
|
691 |
|
|
|
692 |
|
|
|
693 |
|
|
task clear_channel;
|
694 |
|
|
input [ 6:0] chan_val;
|
695 |
|
|
begin
|
696 |
|
|
$display("Clearing Channel interrupt input #%d", chan_val);
|
697 |
|
|
|
698 |
|
|
channel_req[chan_val] = 1'b0; //
|
699 |
|
|
repeat(1) @(posedge mstr_test_clk);
|
700 |
|
|
end
|
701 |
|
|
endtask
|
702 |
|
|
|
703 |
|
|
|
704 |
|
|
task clear_irq_flag;
|
705 |
|
|
input [ 6:0] chan_val;
|
706 |
|
|
begin
|
707 |
|
|
$display("Clearing Channel interrupt flag #%d", chan_val);
|
708 |
|
|
if (0 < chan_val < 16)
|
709 |
|
|
u0.wb_write(1, XGATE_XGIF_0, 16'hffff);
|
710 |
|
|
if (15 < chan_val < 32)
|
711 |
|
|
u0.wb_write(1, XGATE_XGIF_1, 16'hffff);
|
712 |
|
|
if (31 < chan_val < 48)
|
713 |
|
|
u0.wb_write(1, XGATE_XGIF_2, 16'hffff);
|
714 |
|
|
if (47 < chan_val < 64)
|
715 |
|
|
u0.wb_write(1, XGATE_XGIF_3, 16'hffff);
|
716 |
|
|
if (63 < chan_val < 80)
|
717 |
|
|
u0.wb_write(1, XGATE_XGIF_4, 16'hffff);
|
718 |
|
|
if (79 < chan_val < 96)
|
719 |
|
|
u0.wb_write(1, XGATE_XGIF_5, 16'hffff);
|
720 |
|
|
if (95 < chan_val < 112)
|
721 |
|
|
u0.wb_write(1, XGATE_XGIF_6, 16'hffff);
|
722 |
|
|
if (111 < chan_val < 128)
|
723 |
|
|
u0.wb_write(1, XGATE_XGIF_7, 16'hffff);
|
724 |
|
|
|
725 |
|
|
channel_req[chan_val] = 1'b0; //
|
726 |
|
|
repeat(1) @(posedge mstr_test_clk);
|
727 |
|
|
end
|
728 |
|
|
endtask
|
729 |
|
|
|
730 |
|
|
|
731 |
|
|
task activate_thread_sw;
|
732 |
|
|
input [ 6:0] chan_val;
|
733 |
|
|
begin
|
734 |
|
|
$display("Activating Sofrware Thread - Channel #%d", chan_val);
|
735 |
|
|
|
736 |
11 |
rehayes |
data_xgmctl = XGMCTL_XGEM | XGMCTL_XGE;
|
737 |
|
|
u0.wb_write(0, XGATE_XGMCTL, data_xgmctl); // Enable XGATE
|
738 |
2 |
rehayes |
|
739 |
|
|
channel_req[chan_val] = 1'b1; //
|
740 |
|
|
repeat(1) @(posedge mstr_test_clk);
|
741 |
|
|
end
|
742 |
|
|
endtask
|
743 |
|
|
|
744 |
|
|
task dump_ram;
|
745 |
|
|
input [15:0] start_address;
|
746 |
|
|
reg [15:0] dump_address;
|
747 |
|
|
integer i, j;
|
748 |
|
|
begin
|
749 |
|
|
$display("Dumping RAM - Starting Address #%h", start_address);
|
750 |
|
|
|
751 |
|
|
dump_address = start_address;
|
752 |
|
|
while (dump_address <= start_address + 16'h0080)
|
753 |
|
|
begin
|
754 |
|
|
$write("Address = %h", dump_address);
|
755 |
|
|
for (i = 0; i < 16; i = i + 1)
|
756 |
|
|
begin
|
757 |
|
|
$write(" %h", ram_8[dump_address]);
|
758 |
|
|
dump_address = dump_address + 1;
|
759 |
|
|
end
|
760 |
|
|
$write("\n");
|
761 |
|
|
end
|
762 |
|
|
|
763 |
|
|
end
|
764 |
|
|
endtask
|
765 |
|
|
|
766 |
5 |
rehayes |
task wrap_up;
|
767 |
|
|
begin
|
768 |
|
|
$display("\nSimulation Finished!! - vector =%d", vector);
|
769 |
|
|
if (error_count == 0)
|
770 |
|
|
$display("Simulation Passed");
|
771 |
|
|
else
|
772 |
|
|
$display("Simulation Failed");
|
773 |
|
|
|
774 |
|
|
$finish;
|
775 |
|
|
end
|
776 |
|
|
endtask
|
777 |
|
|
|
778 |
2 |
rehayes |
function [15:0] four_2_16;
|
779 |
|
|
input [3:0] vector;
|
780 |
|
|
begin
|
781 |
|
|
case (vector)
|
782 |
|
|
4'h0 : four_2_16 = 16'b0000_0000_0000_0001;
|
783 |
|
|
4'h1 : four_2_16 = 16'b0000_0000_0000_0010;
|
784 |
|
|
4'h2 : four_2_16 = 16'b0000_0000_0000_0100;
|
785 |
|
|
4'h3 : four_2_16 = 16'b0000_0000_0000_1000;
|
786 |
|
|
4'h4 : four_2_16 = 16'b0000_0000_0001_0000;
|
787 |
|
|
4'h5 : four_2_16 = 16'b0000_0000_0010_0000;
|
788 |
|
|
4'h6 : four_2_16 = 16'b0000_0000_0100_0000;
|
789 |
|
|
4'h7 : four_2_16 = 16'b0000_0000_1000_0000;
|
790 |
|
|
4'h8 : four_2_16 = 16'b0000_0001_0000_0000;
|
791 |
|
|
4'h9 : four_2_16 = 16'b0000_0010_0000_0000;
|
792 |
|
|
4'ha : four_2_16 = 16'b0000_0100_0000_0000;
|
793 |
|
|
4'hb : four_2_16 = 16'b0000_1000_0000_0000;
|
794 |
|
|
4'hc : four_2_16 = 16'b0001_0000_0000_0000;
|
795 |
|
|
4'hd : four_2_16 = 16'b0010_0000_0000_0000;
|
796 |
|
|
4'he : four_2_16 = 16'b0100_0000_0000_0000;
|
797 |
|
|
4'hf : four_2_16 = 16'b1000_0000_0000_0000;
|
798 |
|
|
endcase
|
799 |
|
|
end
|
800 |
|
|
endfunction
|
801 |
|
|
|
802 |
|
|
endmodule // tst_bench_top
|
803 |
|
|
|