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

Subversion Repositories dbg_interface

[/] [dbg_interface/] [tags/] [rel_19/] [bench/] [verilog/] [dbg_tb.v] - Blame information for rev 115

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

Line No. Rev Author Line
1 2 mohor
//////////////////////////////////////////////////////////////////////
2
////                                                              ////
3
////  dbg_tb.v                                                    ////
4
////                                                              ////
5
////                                                              ////
6
////  This file is part of the SoC/OpenRISC Development Interface ////
7 36 mohor
////  http://www.opencores.org/projects/DebugInterface/           ////
8 2 mohor
////                                                              ////
9
////  Author(s):                                                  ////
10 80 mohor
////       Igor Mohor (igorm@opencores.org)                       ////
11 2 mohor
////                                                              ////
12
////                                                              ////
13
////  All additional information is avaliable in the README.txt   ////
14
////  file.                                                       ////
15
////                                                              ////
16
//////////////////////////////////////////////////////////////////////
17
////                                                              ////
18 101 mohor
//// Copyright (C) 2000 - 2004 Authors                            ////
19 2 mohor
////                                                              ////
20
//// This source file may be used and distributed without         ////
21
//// restriction provided that this copyright statement is not    ////
22
//// removed from the file and that any derivative work contains  ////
23
//// the original copyright notice and the associated disclaimer. ////
24
////                                                              ////
25
//// This source file is free software; you can redistribute it   ////
26
//// and/or modify it under the terms of the GNU Lesser General   ////
27
//// Public License as published by the Free Software Foundation; ////
28
//// either version 2.1 of the License, or (at your option) any   ////
29
//// later version.                                               ////
30
////                                                              ////
31
//// This source is distributed in the hope that it will be       ////
32
//// useful, but WITHOUT ANY WARRANTY; without even the implied   ////
33
//// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR      ////
34
//// PURPOSE.  See the GNU Lesser General Public License for more ////
35
//// details.                                                     ////
36
////                                                              ////
37
//// You should have received a copy of the GNU Lesser General    ////
38
//// Public License along with this source; if not, download it   ////
39
//// from http://www.opencores.org/lgpl.shtml                     ////
40
////                                                              ////
41
//////////////////////////////////////////////////////////////////////
42
//
43
// CVS Revision History
44
//
45
// $Log: not supported by cvs2svn $
46 115 mohor
// Revision 1.31  2004/01/20 09:07:44  mohor
47
// CRC generation iand verification in bench changed.
48
//
49 114 mohor
// Revision 1.30  2004/01/20 08:03:35  mohor
50
// IDCODE test improved.
51
//
52 113 mohor
// Revision 1.29  2004/01/19 13:13:18  mohor
53
// Define tap_defines.v added to test bench.
54
//
55 111 mohor
// Revision 1.28  2004/01/19 12:38:10  mohor
56
// Waiting for "ready" improved.
57
//
58 110 mohor
// Revision 1.27  2004/01/17 18:01:31  mohor
59
// New version.
60
//
61 102 mohor
// Revision 1.26  2004/01/17 17:01:25  mohor
62
// Almost finished.
63
//
64 101 mohor
// Revision 1.25  2004/01/16 14:51:24  mohor
65
// cpu registers added.
66
//
67 99 mohor
// Revision 1.24  2004/01/15 10:47:13  mohor
68
// Working.
69
//
70 96 mohor
// Revision 1.23  2004/01/14 22:59:01  mohor
71
// Temp version.
72
//
73 95 mohor
// Revision 1.22  2004/01/13 11:28:30  mohor
74
// tmp version.
75
//
76 93 mohor
// Revision 1.21  2004/01/10 07:50:41  mohor
77
// temp version.
78
//
79 92 mohor
// Revision 1.20  2004/01/09 12:49:23  mohor
80
// tmp version.
81
//
82 91 mohor
// Revision 1.19  2004/01/08 17:53:12  mohor
83
// tmp version.
84
//
85 90 mohor
// Revision 1.18  2004/01/07 11:59:48  mohor
86
// temp4 version.
87
//
88 89 mohor
// Revision 1.17  2004/01/06 17:14:59  mohor
89
// temp3 version.
90
//
91 88 mohor
// Revision 1.16  2004/01/05 12:16:50  mohor
92
// tmp2 version.
93
//
94 87 mohor
// Revision 1.15  2003/12/23 14:26:01  mohor
95
// New version of the debug interface. Not finished, yet.
96
//
97 80 mohor
// Revision 1.14  2003/10/23 16:16:30  mohor
98
// CRC logic changed.
99
//
100 73 mohor
// Revision 1.13  2003/08/28 13:54:33  simons
101
// Three more chains added for cpu debug access.
102
//
103 63 simons
// Revision 1.12  2002/05/07 14:44:52  mohor
104
// mon_cntl_o signals that controls monitor mux added.
105
//
106 47 mohor
// Revision 1.11  2002/03/12 14:32:26  mohor
107
// Few outputs for boundary scan chain added.
108
//
109 38 mohor
// Revision 1.10  2002/03/08 15:27:08  mohor
110
// Structure changed. Hooks for jtag chain added.
111
//
112 36 mohor
// Revision 1.9  2001/10/19 11:39:20  mohor
113
// dbg_timescale.v changed to timescale.v This is done for the simulation of
114
// few different cores in a single project.
115
//
116 17 mohor
// Revision 1.8  2001/10/17 10:39:17  mohor
117
// bs_chain_o added.
118
//
119 15 mohor
// Revision 1.7  2001/10/16 10:10:18  mohor
120
// Signal names changed to lowercase.
121
//
122 13 mohor
// Revision 1.6  2001/10/15 09:52:50  mohor
123
// Wishbone interface added, few fixes for better performance,
124
// hooks for boundary scan testing added.
125
//
126 12 mohor
// Revision 1.5  2001/09/24 14:06:12  mohor
127
// Changes connected to the OpenRISC access (SPR read, SPR write).
128
//
129 11 mohor
// Revision 1.4  2001/09/20 10:10:29  mohor
130
// Working version. Few bugs fixed, comments added.
131
//
132 9 mohor
// Revision 1.3  2001/09/19 11:54:03  mohor
133
// Minor changes for simulation.
134
//
135 6 mohor
// Revision 1.2  2001/09/18 14:12:43  mohor
136
// Trace fixed. Some registers changed, trace simplified.
137
//
138 5 mohor
// Revision 1.1.1.1  2001/09/13 13:49:19  mohor
139
// Initial official release.
140
//
141 2 mohor
// Revision 1.3  2001/06/01 22:23:40  mohor
142
// This is a backup. It is not a fully working version. Not for use, yet.
143
//
144
// Revision 1.2  2001/05/18 13:10:05  mohor
145
// Headers changed. All additional information is now avaliable in the README.txt file.
146
//
147
// Revision 1.1.1.1  2001/05/18 06:35:15  mohor
148
// Initial release
149
//
150
//
151
 
152
 
153 17 mohor
`include "timescale.v"
154 111 mohor
`include "tap_defines.v"
155 2 mohor
`include "dbg_defines.v"
156 80 mohor
`include "dbg_wb_defines.v"
157 99 mohor
`include "dbg_cpu_defines.v"
158 2 mohor
 
159
// Test bench
160
module dbg_tb;
161
 
162 80 mohor
parameter TCLK = 50;   // Clock half period (Clok period = 100 ns => 10 MHz)
163 2 mohor
 
164 80 mohor
reg   tms_pad_i;
165
reg   tck_pad_i;
166
reg   trst_pad_i;
167
reg   tdi_pad_i;
168
wire  tdo_pad_o;
169
wire  tdo_padoe_o;
170 2 mohor
 
171 80 mohor
wire  shift_dr_o;
172
wire  pause_dr_o;
173
wire  update_dr_o;
174 102 mohor
wire  capture_dr_o;
175 2 mohor
 
176 80 mohor
wire  extest_select_o;
177
wire  sample_preload_select_o;
178
wire  mbist_select_o;
179
wire  debug_select_o;
180 2 mohor
 
181 80 mohor
// WISHBONE common signals
182
reg   wb_rst_i;
183
reg   wb_clk_i;
184
 
185
// WISHBONE master interface
186
wire [31:0] wb_adr_o;
187
wire [31:0] wb_dat_o;
188
wire [31:0] wb_dat_i;
189
wire        wb_cyc_o;
190
wire        wb_stb_o;
191
wire  [3:0] wb_sel_o;
192
wire        wb_we_o;
193
wire        wb_ack_i;
194
wire        wb_cab_o;
195
wire        wb_err_i;
196
wire  [2:0] wb_cti_o;
197
wire  [1:0] wb_bte_o;
198 2 mohor
 
199 101 mohor
// CPU signals
200
wire        cpu_clk_i;
201
wire [31:0] cpu_addr_o;
202
wire [31:0] cpu_data_i;
203
wire [31:0] cpu_data_o;
204
wire        cpu_bp_i;
205
wire        cpu_stall_o;
206
wire        cpu_stall_all_o;
207
wire        cpu_stb_o;
208
wire  [`CPU_NUM -1:0]  cpu_sel_o;
209
wire        cpu_we_o;
210
wire        cpu_ack_i;
211
wire        cpu_rst_o;
212
 
213 87 mohor
// Text used for easier debugging
214 99 mohor
reg [199:0] test_text;
215 88 mohor
reg   [2:0] last_wb_cmd;
216 99 mohor
reg [199:0] last_wb_cmd_text;
217 88 mohor
reg  [31:0] wb_data;
218 2 mohor
 
219
 
220 12 mohor
 
221 80 mohor
wire  tdo_o;
222 12 mohor
 
223 80 mohor
wire  debug_tdi_i;
224
wire  bs_chain_tdi_i;
225
wire  mbist_tdi_i;
226 73 mohor
 
227 80 mohor
reg   test_enabled;
228 73 mohor
 
229 80 mohor
reg [31:0] result;
230 113 mohor
reg [31:0] in_data_le, in_data_be;
231
reg [31:0] id;
232 88 mohor
 
233 110 mohor
wire crc_match_in;
234 114 mohor
reg [31:0] crc_in;
235
reg [31:0] crc_out;
236 99 mohor
 
237
 
238 80 mohor
wire tdo;
239 73 mohor
 
240 80 mohor
assign tdo = tdo_padoe_o? tdo_pad_o : 1'hz;
241 73 mohor
 
242 80 mohor
// Connecting TAP module
243
tap_top i_tap_top (
244 101 mohor
                    .tms_pad_i        (tms_pad_i),
245
                    .tck_pad_i        (tck_pad_i),
246
                    .trst_pad_i       (!trst_pad_i),
247
                    .tdi_pad_i        (tdi_pad_i),
248
                    .tdo_pad_o        (tdo_pad_o),
249
                    .tdo_padoe_o      (tdo_padoe_o),
250 38 mohor
 
251 80 mohor
                    // TAP states
252 101 mohor
                    .shift_dr_o       (shift_dr_o),
253
                    .pause_dr_o       (pause_dr_o),
254
                    .update_dr_o      (update_dr_o),
255 102 mohor
                    .capture_dr_o     (capture_dr_o),
256 38 mohor
 
257 80 mohor
                    // Select signals for boundary scan or mbist
258 101 mohor
                    .extest_select_o  (extest_select_o),
259 80 mohor
                    .sample_preload_select_o(sample_preload_select_o),
260 101 mohor
                    .mbist_select_o   (mbist_select_o),
261
                    .debug_select_o   (debug_select_o),
262 2 mohor
 
263 80 mohor
                    // TDO signal that is connected to TDI of sub-modules.
264 101 mohor
                    .tdo_o            (tdo_o),
265 38 mohor
 
266 80 mohor
                    // TDI signals from sub-modules
267 101 mohor
                    .debug_tdi_i      (debug_tdi_i),        // from debug module
268
                    .bs_chain_tdi_i   (bs_chain_tdi_i),  // from Boundary Scan Chain
269
                    .mbist_tdi_i      (mbist_tdi_i)         // from Mbist Chain
270 73 mohor
 
271 38 mohor
               );
272 2 mohor
 
273
 
274 99 mohor
// Connecting debug top module
275 80 mohor
dbg_top i_dbg_top  (
276 101 mohor
                    .tck_i            (tck_pad_i),
277
                    .tdi_i            (tdo_o),
278
                    .tdo_o            (debug_tdi_i),
279 80 mohor
 
280
                    // TAP states
281 101 mohor
                    .shift_dr_i       (shift_dr_o),
282
                    .pause_dr_i       (pause_dr_o),
283
                    .update_dr_i      (update_dr_o),
284 80 mohor
 
285
                    // Instructions
286 101 mohor
                    .debug_select_i   (debug_select_o),
287 12 mohor
 
288 80 mohor
                    // WISHBONE common signals
289 101 mohor
                    .wb_rst_i         (wb_rst_i),
290
                    .wb_clk_i         (wb_clk_i),
291 80 mohor
 
292
                    // WISHBONE master interface
293 101 mohor
                    .wb_adr_o         (wb_adr_o),
294
                    .wb_dat_o         (wb_dat_o),
295
                    .wb_dat_i         (wb_dat_i),
296
                    .wb_cyc_o         (wb_cyc_o),
297
                    .wb_stb_o         (wb_stb_o),
298
                    .wb_sel_o         (wb_sel_o),
299
                    .wb_we_o          (wb_we_o),
300
                    .wb_ack_i         (wb_ack_i),
301
                    .wb_cab_o         (wb_cab_o),
302
                    .wb_err_i         (wb_err_i),
303
                    .wb_cti_o         (wb_cti_o),
304
                    .wb_bte_o         (wb_bte_o),
305
 
306
                    // CPU signals
307
                    .cpu_clk_i        (cpu_clk_i),
308
                    .cpu_addr_o       (cpu_addr_o),
309
                    .cpu_data_i       (cpu_data_i),
310
                    .cpu_data_o       (cpu_data_o),
311
                    .cpu_bp_i         (cpu_bp_i),
312
                    .cpu_stall_o      (cpu_stall_o),
313
                    .cpu_stall_all_o  (cpu_stall_all_o),
314
                    .cpu_stb_o        (cpu_stb_o),
315
                    .cpu_sel_o        (cpu_sel_o),
316
                    .cpu_we_o         (cpu_we_o),
317
                    .cpu_ack_i        (cpu_ack_i),
318
                    .cpu_rst_o        (cpu_rst_o)
319
 
320
 
321
 
322
 
323 80 mohor
                   );
324 12 mohor
 
325
 
326 99 mohor
 
327 80 mohor
wb_slave_behavioral wb_slave
328
                   (
329 101 mohor
                    .CLK_I            (wb_clk_i),
330
                    .RST_I            (wb_rst_i),
331
                    .ACK_O            (wb_ack_i),
332
                    .ADR_I            (wb_adr_o),
333
                    .CYC_I            (wb_cyc_o),
334
                    .DAT_O            (wb_dat_i),
335
                    .DAT_I            (wb_dat_o),
336
                    .ERR_O            (wb_err_i),
337
                    .RTY_O            (),      // NOT USED for now!
338
                    .SEL_I            (wb_sel_o),
339
                    .STB_I            (wb_stb_o),
340
                    .WE_I             (wb_we_o),
341
                    .CAB_I            (1'b0)
342 80 mohor
                   );
343 2 mohor
 
344
 
345 101 mohor
 
346
cpu_behavioral i_cpu_behavioral
347
                   (
348
                    // CPU signals
349
                    .cpu_rst_i        (wb_rst_i),
350
                    .cpu_clk_o        (cpu_clk_i),
351
                    .cpu_addr_i       (cpu_addr_o),
352
                    .cpu_data_o       (cpu_data_i),
353
                    .cpu_data_i       (cpu_data_o),
354
                    .cpu_bp_o         (cpu_bp_i),
355
                    .cpu_stall_i      (cpu_stall_o),
356
                    .cpu_stall_all_i  (cpu_stall_all_o),
357
                    .cpu_stb_i        (cpu_stb_o),
358
                    .cpu_sel_i        (cpu_sel_o),
359
                    .cpu_we_i         (cpu_we_o),
360
                    .cpu_ack_o        (cpu_ack_i),
361
                    .cpu_rst_o        (cpu_rst_o)
362
                   );
363
 
364
 
365
 
366
 
367 80 mohor
// Initial values
368 2 mohor
initial
369
begin
370 80 mohor
  test_enabled = 1'b0;
371 88 mohor
  wb_data = 32'h01234567;
372 80 mohor
  trst_pad_i = 1'b1;
373
  tms_pad_i = 1'hz;
374
  tck_pad_i = 1'hz;
375
  tdi_pad_i = 1'hz;
376
 
377
  #100;
378
  trst_pad_i = 1'b0;
379
  #100;
380
  trst_pad_i = 1'b1;
381
  #1 test_enabled<=#1 1'b1;
382 2 mohor
end
383
 
384 80 mohor
initial
385
begin
386
  wb_rst_i = 1'b0;
387
  #1000;
388
  wb_rst_i = 1'b1;
389
  #1000;
390
  wb_rst_i = 1'b0;
391 2 mohor
 
392 80 mohor
  // Initial values for wishbone slave model
393 96 mohor
  wb_slave.cycle_response(`ACK_RESPONSE, 9'h55, 8'h2);   // (`ACK_RESPONSE, wbs_waits, wbs_retries);
394 80 mohor
end
395
 
396
initial
397 2 mohor
begin
398 80 mohor
  wb_clk_i = 1'b0;
399
  forever #5 wb_clk_i = ~wb_clk_i;
400 2 mohor
end
401
 
402 80 mohor
always @ (posedge test_enabled)
403
begin
404 2 mohor
 
405 80 mohor
  $display("//////////////////////////////////////////////////////////////////");
406
  $display("//                                                              //");
407
  $display("//  (%0t) dbg_tb starting                                     //", $time);
408
  $display("//                                                              //");
409
  $display("//////////////////////////////////////////////////////////////////");
410 2 mohor
 
411 80 mohor
  initialize_memory(32'h12340000, 32'h00100000);  // Initialize 0x100000 bytes starting from address 0x12340000
412 2 mohor
 
413 80 mohor
  reset_tap;
414 95 mohor
 
415
  #500;
416 80 mohor
  goto_run_test_idle;
417 12 mohor
 
418 80 mohor
  // Testing read and write to internal registers
419
  #10000;
420 111 mohor
 
421 115 mohor
//  set_instruction(`IDCODE);
422
  set_instruction(4'b1100);
423 113 mohor
  read_id_code(id);
424 12 mohor
 
425 113 mohor
  $display("\tRead ID     = 0x%0x", id);
426
  $display("\tExpected ID = 0x%0x", `IDCODE_VALUE);
427
 
428 80 mohor
  set_instruction(`DEBUG);
429
  #10000;
430 2 mohor
 
431 99 mohor
  chain_select(`WISHBONE_SCAN_CHAIN, 1'b0);   // {chain, gen_crc_err}
432 12 mohor
 
433 80 mohor
//  #10000;
434
//  xxx(4'b1001, 32'he579b242);
435 12 mohor
 
436 80 mohor
  #10000;
437 2 mohor
 
438 99 mohor
//  debug_wishbone(`WB_READ8, 1'b0, 32'h12345678, 16'h4, 1'b0, result, "abc 1"); // {command, ready, addr, length, gen_crc_err, result, text}
439
//  debug_wishbone(`WB_READ8, 1'b0, 32'h12345679, 16'h4, 1'b0, result, "abc 2"); // {command, ready, addr, length, gen_crc_err, result, text}
440
//  debug_wishbone(`WB_READ8, 1'b0, 32'h1234567a, 16'h4, 1'b0, result, "abc 3"); // {command, ready, addr, length, gen_crc_err, result, text}
441 88 mohor
//
442 99 mohor
//  debug_wishbone(`WB_READ16, 1'b0, 32'h12345678, 16'h4, 1'b0, result, "abc 4"); // {command, ready, addr, length, gen_crc_err, result, text}
443
//  debug_wishbone(`WB_READ16, 1'b0, 32'h1234567a, 16'h4, 1'b0, result, "abc 5"); // {command, ready, addr, length, gen_crc_err, result, text}
444 88 mohor
//
445 99 mohor
  debug_wishbone(`WB_READ32, 1'b0, 32'h12345678, 16'h4, 1'b0, result, "read32 1"); // {command, ready, addr, length, gen_crc_err, result, text}
446 88 mohor
//
447 99 mohor
//  debug_wishbone(`WB_READ16, 1'b0, 32'h12345679, 16'h4, 1'b0, result, "abc 6"); // {command, ready, addr, length, gen_crc_err, result, text}
448 2 mohor
 
449 80 mohor
  #10000;
450
//  xxx(4'b1001, 32'he579b242);
451
 
452 99 mohor
  debug_wishbone(`WB_READ32, 1'b1, 32'h12345678, 16'h4, 1'b0, result, "read32 2"); // {command, ready, addr, length, gen_crc_err, result, text}
453 87 mohor
 
454
  #10000;
455 96 mohor
  wb_slave.cycle_response(`ACK_RESPONSE, 9'h55, 8'h2);   // (`ACK_RESPONSE, wbs_waits, wbs_retries);
456 99 mohor
  debug_wishbone(`WB_READ32, 1'b1, 32'h12346668, 16'h4, 1'b0, result, "read32 3"); // {command, ready, addr, length, gen_crc_err, result, text}
457 80 mohor
 
458
  #10000;
459 96 mohor
  wb_slave.cycle_response(`ERR_RESPONSE, 9'h03, 8'h2);   // (`ERR_RESPONSE, wbs_waits, wbs_retries);
460 99 mohor
  debug_wishbone(`WB_READ32, 1'b1, 32'h12346668, 16'h4, 1'b0, result, "read32 4"); // {command, ready, addr, length, gen_crc_err, result, text}
461 80 mohor
 
462
  #10000;
463 99 mohor
  debug_wishbone(`WB_STATUS, 1'b0, 32'h0, 16'h0, 1'b0, result, "status 1"); // {command, ready, addr, length, gen_crc_err, result, text}
464 80 mohor
 
465 87 mohor
  #10000;
466 99 mohor
  debug_wishbone(`WB_STATUS, 1'b0, 32'h0, 16'h0, 1'b0, result, "status 2"); // {command, ready, addr, length, gen_crc_err, result, text}
467 80 mohor
 
468 87 mohor
  #10000;
469 96 mohor
  wb_slave.cycle_response(`ACK_RESPONSE, 9'h012, 8'h2);   // (`ACK_RESPONSE, wbs_waits, wbs_retries);
470 99 mohor
  debug_wishbone(`WB_READ32, 1'b1, 32'h12347778, 16'hc, 1'b0, result, "read32 5"); // {command, ready, addr, length, gen_crc_err, result, text}
471 80 mohor
 
472 87 mohor
  #10000;
473 99 mohor
  debug_wishbone(`WB_WRITE32, 1'b0, 32'h12346668, 16'h8, 1'b0, result, "wr32 len8"); // {command, ready, addr, length, gen_crc_err, result, text}
474 87 mohor
 
475
  #10000;
476 99 mohor
  debug_wishbone(`WB_WRITE16, 1'b0, 32'h12344446, 16'h8, 1'b0, result, "wr16 len8"); // {command, ready, addr, length, gen_crc_err, result, text}
477 87 mohor
 
478 88 mohor
  #10000;
479 99 mohor
  debug_wishbone(`WB_WRITE8, 1'b0, 32'h1234010e, 16'h8, 1'b0, result, "wr8 len8"); // {command, ready, addr, length, gen_crc_err, result, text}
480 87 mohor
 
481 88 mohor
  #10000;
482 99 mohor
  debug_wishbone(`WB_GO, 1'b0, 32'h0, 16'h0, 1'b0, result, "go 1"); // {command, ready, addr, length, gen_crc_err, result, text}
483 87 mohor
 
484 89 mohor
  #10000;
485 99 mohor
  debug_wishbone(`WB_READ32, 1'b1, 32'h12340100, 16'hc, 1'b0, result, "read32 6"); // {command, ready, addr, length, gen_crc_err, result, text}
486
//  debug_wishbone(`WB_READ32, 1'b1, 32'h12340100, 16'hfffc, 1'b0, result, "read32 6"); // {command, ready, addr, length, gen_crc_err, result, text}
487 88 mohor
 
488 89 mohor
  #10000;
489 99 mohor
//  debug_wishbone(`WB_READ16, 1'b1, 32'h12340102, 16'he, 1'b0, result, "read16 7"); // {command, ready, addr, length, gen_crc_err, result, text}
490
//  debug_wishbone(`WB_READ16, 1'b1, 32'h12340102, 16'hfffe, 1'b0, result, "read16 7"); // {command, ready, addr, length, gen_crc_err, result, text}
491 88 mohor
 
492 90 mohor
  #10000;
493 99 mohor
//  debug_wishbone(`WB_READ8, 1'b1, 32'h12348804, 16'h6, 1'b0, result, "read8 8"); // {command, ready, addr, length, gen_crc_err, result, text}  
494
//  debug_wishbone(`WB_READ8, 1'b1, 32'h12348804, 16'hfffc, 1'b0, result, "read8 8"); // {command, ready, addr, length, gen_crc_err, result, text}
495 89 mohor
 
496 90 mohor
  #10000;
497 99 mohor
  debug_wishbone(`WB_GO, 1'b0, 32'h0, 16'h0, 1'b0, result, "go 2"); // {command, ready, addr, length, gen_crc_err, result, text}
498 89 mohor
 
499 99 mohor
  #10000;
500
  chain_select(`CPU_DEBUG_CHAIN, 1'b0);   // {chain, gen_crc_err}
501 89 mohor
 
502 101 mohor
 
503
 
504
 
505
  // Select cpu0
506 99 mohor
  #10000;
507 101 mohor
  debug_cpu(`CPU_WRITE_REG, `CPU_SEL_ADR, 32'h0, 1'b0, result, "select cpu 0"); // {command, addr, data, gen_crc_err, result, text}
508 90 mohor
 
509 99 mohor
  #10000;
510 101 mohor
  debug_cpu(`CPU_GO, 32'h0, 32'h1, 1'b0, result, "go cpu"); // {command, addr, data, gen_crc_err, result, text}
511
 
512
  // Read register
513
  #10000;
514
  debug_cpu(`CPU_READ_REG, `CPU_SEL_ADR, 32'h0, 1'b0, result, "cpu_read_reg"); // {command, addr, data, gen_crc_err, result, text}
515
 
516
  #10000;
517 99 mohor
  debug_cpu(`CPU_GO, 32'h0, 32'hff, 1'b0, result, "go cpu"); // {command, addr, data, gen_crc_err, result, text}
518 90 mohor
 
519 101 mohor
  // Stall cpu0
520
  #10000;
521
  debug_cpu(`CPU_WRITE_REG, `CPU_OP_ADR, 32'h0, 1'b0, result, "stall cpu0"); // {command, addr, data, gen_crc_err, result, text}
522 99 mohor
 
523 101 mohor
  #10000;
524
  debug_cpu(`CPU_GO, 32'h0, 32'h1, 1'b0, result, "go cpu"); // {command, addr, data, gen_crc_err, result, text}
525
 
526
  // write to cpu 32-bit
527
  #10000;
528
  debug_cpu(`CPU_WRITE32, 32'h32323232, 32'h0, 1'b0, result, "cpu_write_32"); // {command, addr, data, gen_crc_err, result, text}
529
 
530
  #10000;
531
  debug_cpu(`CPU_GO, 32'h0, 32'hdeadbeef, 1'b0, result, "go cpu"); // {command, addr, data, gen_crc_err, result, text}
532
 
533 102 mohor
  // read from cpu 32-bit
534 101 mohor
  #10000;
535
  debug_cpu(`CPU_READ32, 32'h32323232, 32'h0, 1'b0, result, "cpu_read_32"); // {command, addr, data, gen_crc_err, result, text}
536
 
537
  #10000;
538
  debug_cpu(`CPU_GO, 32'h0, 32'hdeadbeef, 1'b0, result, "go cpu"); // {command, addr, data, gen_crc_err, result, text}
539
 
540
  // write to cpu 8-bit
541
  #10000;
542
  debug_cpu(`CPU_WRITE8, 32'h08080808, 32'h0, 1'b0, result, "cpu_write_8"); // {command, addr, data, gen_crc_err, result, text}
543
 
544
  #10000;
545
  debug_cpu(`CPU_GO, 32'h0, 32'hdeadbeef, 1'b0, result, "go cpu"); // {command, addr, data, gen_crc_err, result, text}
546
 
547 102 mohor
  // read from cpu 8-bit
548 101 mohor
  #10000;
549
  debug_cpu(`CPU_READ8, 32'h08080808, 32'h0, 1'b0, result, "cpu_read_8"); // {command, addr, data, gen_crc_err, result, text}
550
 
551
  #10000;
552
  debug_cpu(`CPU_GO, 32'h0, 32'hdeadbeef, 1'b0, result, "go cpu"); // {command, addr, data, gen_crc_err, result, text}
553
 
554 110 mohor
 
555
 
556
 
557
 
558
 
559
 
560
 
561
 
562
 
563
 
564
 
565
 
566 80 mohor
/*
567
  // Testing read and write to CPU0 registers
568
  #10000;
569
  set_instruction(`CHAIN_SELECT);
570
  chain_select(`CPU_DEBUG_CHAIN_0, 8'h12);  // {chain, crc}
571
  set_instruction(`DEBUG);
572
  WriteCPURegister(32'h11001100, 32'h00110011, 8'h86);  // {data, addr, crc}
573
 
574
  ReadCPURegister(32'h11001100, 8'hdb);                 // {addr, crc}
575
  ReadCPURegister(32'h11001100, 8'hdb);                 // {addr, crc}
576
*/
577
  #5000 gen_clk(1);            // One extra TCLK for debugging purposes
578 95 mohor
  $display("\n\nSimulation end.");
579 5 mohor
  #1000 $stop;
580 80 mohor
 
581 2 mohor
end
582
 
583 80 mohor
 
584
task initialize_memory;
585
  input [31:0] start_addr;
586
  input [31:0] length;
587
  integer i;
588
  reg [31:0] addr;
589
  begin
590 96 mohor
//    for (i=0; i<length; i=i+4)    // inverted address
591
//      begin
592
//        addr = start_addr + i;
593
//        wb_slave.wr_mem(addr, {addr[7:0], addr[15:8], addr[23:16], addr[31:24]}, 4'hf);    // adr, data, sel
594
//      end
595 80 mohor
    for (i=0; i<length; i=i+4)
596
      begin
597
        addr = start_addr + i;
598 96 mohor
        wb_slave.wr_mem(addr, {addr[7:0], addr[7:0]+2'd1, addr[7:0]+2'd2, addr[7:0]+2'd3}, 4'hf);    // adr, data, sel
599 80 mohor
      end
600
  end
601
endtask
602
 
603
 
604
 
605 2 mohor
// Generation of the TCLK signal
606 80 mohor
task gen_clk;
607
  input [7:0] num;
608 2 mohor
  integer i;
609
  begin
610 80 mohor
    for(i=0; i<num; i=i+1)
611 2 mohor
      begin
612 80 mohor
        #TCLK tck_pad_i<=1;
613
        #TCLK tck_pad_i<=0;
614 2 mohor
      end
615
  end
616
endtask
617
 
618
 
619
// TAP reset
620 80 mohor
task reset_tap;
621 2 mohor
  begin
622 80 mohor
    $display("(%0t) Task reset_tap", $time);
623
    tms_pad_i<=#1 1'b1;
624 95 mohor
    gen_clk(5);
625 2 mohor
  end
626
endtask
627
 
628
 
629
// Goes to RunTestIdle state
630 80 mohor
task goto_run_test_idle;
631 2 mohor
  begin
632 80 mohor
    $display("(%0t) Task goto_run_test_idle", $time);
633
    tms_pad_i<=#1 1'b0;
634
    gen_clk(1);
635 2 mohor
  end
636
endtask
637
 
638
 
639 115 mohor
 
640 2 mohor
// sets the instruction to the IR register and goes to the RunTestIdle state
641 80 mohor
task set_instruction;
642
  input [3:0] instr;
643 2 mohor
  integer i;
644
 
645
  begin
646 115 mohor
    case (instr)
647
      `EXTEST          : $display("(%0t) Task set_instruction (EXTEST)", $time);
648
      `SAMPLE_PRELOAD  : $display("(%0t) Task set_instruction (SAMPLE_PRELOAD)", $time);
649
      `IDCODE          : $display("(%0t) Task set_instruction (IDCODE)", $time);
650
      `DEBUG           : $display("(%0t) Task set_instruction (DEBUG)", $time);
651
      `MBIST           : $display("(%0t) Task set_instruction (MBIST)", $time);
652
      `BYPASS          : $display("(%0t) Task set_instruction (BYPASS)", $time);
653
      default
654
                       begin
655
                         $display("(%0t) Task set_instruction (Unsupported instruction !!!)", $time);
656
                         $display("\tERROR: Unsupported instruction !!!", $time);
657
                         $stop;
658
                       end
659
    endcase
660
 
661 80 mohor
    tms_pad_i<=#1 1;
662
    gen_clk(2);
663
    tms_pad_i<=#1 0;
664
    gen_clk(2);  // we are in shiftIR
665 2 mohor
 
666
    for(i=0; i<`IR_LENGTH-1; i=i+1)
667
    begin
668 80 mohor
      tdi_pad_i<=#1 instr[i];
669
      gen_clk(1);
670 2 mohor
    end
671
 
672 80 mohor
    tdi_pad_i<=#1 instr[i]; // last shift
673
    tms_pad_i<=#1 1;        // going out of shiftIR
674
    gen_clk(1);
675 90 mohor
    tdi_pad_i<=#1 'hz;    // tri-state
676 80 mohor
    gen_clk(1);
677
    tms_pad_i<=#1 0;
678
    gen_clk(1);       // we are in RunTestIdle
679 2 mohor
  end
680
endtask
681
 
682
 
683 80 mohor
// Reads the ID code
684
task read_id_code;
685 113 mohor
  output [31:0] code;
686
  reg    [31:0] code;
687 80 mohor
  begin
688
    $display("(%0t) Task read_id_code", $time);
689
    tms_pad_i<=#1 1;
690
    gen_clk(1);
691
    tms_pad_i<=#1 0;
692
    gen_clk(2);  // we are in shiftDR
693
 
694
    tdi_pad_i<=#1 0;
695
    gen_clk(31);
696
 
697
    tms_pad_i<=#1 1;        // going out of shiftIR
698
    gen_clk(1);
699
 
700 113 mohor
    code = in_data_le;
701
 
702 80 mohor
    tdi_pad_i<=#1 'hz; // tri-state
703
    gen_clk(1);
704
    tms_pad_i<=#1 0;
705
    gen_clk(1);       // we are in RunTestIdle
706
  end
707
endtask
708
 
709
 
710 2 mohor
// sets the selected scan chain and goes to the RunTestIdle state
711 80 mohor
task chain_select;
712
  input [3:0]  data;
713 99 mohor
  input        gen_crc_err;
714 2 mohor
  integer i;
715
 
716
  begin
717 99 mohor
    case (data)
718
      `CPU_DEBUG_CHAIN      : $display("(%0t) Task chain_select (CPU_DEBUG_CHAIN, gen_crc_err=%0d)", $time, gen_crc_err);
719
      `WISHBONE_SCAN_CHAIN  : $display("(%0t) Task chain_select (WISHBONE_SCAN_CHAIN gen_crc_err=%0d)", $time, gen_crc_err);
720
      default               : $display("(%0t) Task chain_select (ERROR!!! Unknown chain selected)", $time);
721
    endcase
722
 
723 80 mohor
    tms_pad_i<=#1 1;
724
    gen_clk(1);
725
    tms_pad_i<=#1 0;
726
    gen_clk(2);  // we are in shiftDR
727 2 mohor
 
728 114 mohor
    crc_out = 32'hffffffff; // Initialize outgoing CRC
729 80 mohor
    tdi_pad_i<=#1 1'b1; // chain_select bit
730 114 mohor
    calculate_crc(1'b1);
731 80 mohor
    gen_clk(1);
732
 
733 2 mohor
    for(i=0; i<`CHAIN_ID_LENGTH; i=i+1)
734
    begin
735 80 mohor
      tdi_pad_i<=#1 data[i];
736 114 mohor
      calculate_crc(data[i]);
737 80 mohor
      gen_clk(1);
738 2 mohor
    end
739
 
740 99 mohor
    for(i=31; i>=0; i=i-1)
741 2 mohor
    begin
742 99 mohor
      if (gen_crc_err & (i==0))  // Generate crc error at last crc bit
743 114 mohor
        tdi_pad_i<=#1 ~crc_out[i];   // error crc
744 99 mohor
      else
745 114 mohor
        tdi_pad_i<=#1 crc_out[i];    // ok crc
746 99 mohor
 
747 80 mohor
      gen_clk(1);
748 2 mohor
    end
749
 
750 99 mohor
    tdi_pad_i<=#1 'hz;  // tri-state
751
 
752 114 mohor
    crc_in = 32'hffffffff;  // Initialize incoming CRC
753 110 mohor
    gen_clk(`STATUS_LEN);   // Generating 4 clocks to read out status.
754 80 mohor
 
755 110 mohor
 
756 80 mohor
    for(i=0; i<`CRC_LEN -1; i=i+1)
757
      gen_clk(1);
758
 
759
    tms_pad_i<=#1 1;
760
    gen_clk(1);         // to exit1_dr
761
 
762 110 mohor
    if (~crc_match_in)
763
      begin
764
        $display("(%0t) Incoming CRC failed !!!", $time);
765
        $stop;
766
      end
767
 
768 80 mohor
    tms_pad_i<=#1 1;
769
    gen_clk(1);         // to update_dr
770
    tms_pad_i<=#1 0;
771
    gen_clk(1);         // to run_test_idle
772 2 mohor
  end
773 99 mohor
endtask   // chain_select
774 2 mohor
 
775
 
776 87 mohor
 
777
 
778
 
779
 
780
 
781 80 mohor
task debug_wishbone;
782
  input [2:0]   command;
783 87 mohor
  input         ready;
784 80 mohor
  input [31:0]  addr;
785
  input [15:0]  length;
786 99 mohor
  input         gen_crc_err;
787 80 mohor
  output [31:0] result;
788 87 mohor
  input [99:0]  text;
789 80 mohor
  integer i;
790
 
791 2 mohor
  begin
792 80 mohor
   $write("(%0t) Task debug_wishbone: ", $time);
793 2 mohor
 
794 87 mohor
    test_text = text;
795 36 mohor
 
796 80 mohor
    case (command)
797
      `WB_STATUS   :
798
        begin
799 99 mohor
          $display("wb_status (gen_crc_err=%0d (%0s))", gen_crc_err, text);
800
          debug_wishbone_status(command, gen_crc_err);
801 88 mohor
          last_wb_cmd = `WB_STATUS;  last_wb_cmd_text = "WB_STATUS";
802 80 mohor
        end
803
      `WB_READ8    :
804
        begin
805 110 mohor
          $display("wb_read8 (adr=0x%0x, length=0x%0x, gen_crc_err=%0d (%0s))", addr, length, gen_crc_err, text);
806
          debug_wishbone_set_addr(command, addr, length, gen_crc_err);
807 88 mohor
          last_wb_cmd = `WB_READ8;  last_wb_cmd_text = "WB_READ8";
808 80 mohor
        end
809
      `WB_READ16   :
810
        begin
811 110 mohor
          $display("wb_read16 (adr=0x%0x, length=0x%0x, gen_crc_err=%0d (%0s))", addr, length, gen_crc_err, text);
812
          debug_wishbone_set_addr(command, addr, length, gen_crc_err);
813 88 mohor
          last_wb_cmd = `WB_READ16;  last_wb_cmd_text = "WB_READ16";
814 80 mohor
        end
815
      `WB_READ32   :
816
        begin
817 110 mohor
          $display("wb_read32 (adr=0x%0x, length=0x%0x, gen_crc_err=%0d (%0s))", addr, length, gen_crc_err, text);
818
          debug_wishbone_set_addr(command, addr, length, gen_crc_err);
819 88 mohor
          last_wb_cmd = `WB_READ32;  last_wb_cmd_text = "WB_READ32";
820 80 mohor
        end
821
      `WB_WRITE8   :
822
        begin
823 99 mohor
          $display("wb_write8 (adr=0x%0x, length=0x%0x, gen_crc_err=%0d (%0s))", addr, length, gen_crc_err, text);
824 110 mohor
          debug_wishbone_set_addr(command, addr, length, gen_crc_err);
825 88 mohor
          last_wb_cmd = `WB_WRITE8;  last_wb_cmd_text = "WB_WRITE8";
826 80 mohor
        end
827
      `WB_WRITE16  :
828
        begin
829 99 mohor
          $display("wb_write16 (adr=0x%0x, length=0x%0x, gen_crc_err=%0d (%0s))", addr, length, gen_crc_err, text);
830 110 mohor
          debug_wishbone_set_addr(command, addr, length, gen_crc_err);
831 88 mohor
          last_wb_cmd = `WB_WRITE16;  last_wb_cmd_text = "WB_WRITE16";
832 80 mohor
        end
833
      `WB_WRITE32  :
834
        begin
835 99 mohor
          $display("wb_write32 (adr=0x%0x, length=0x%0x, gen_crc_err=%0d (%0s))", addr, length, gen_crc_err, text);
836 110 mohor
          debug_wishbone_set_addr(command, addr, length, gen_crc_err);
837 88 mohor
          last_wb_cmd = `WB_WRITE32;  last_wb_cmd_text = "WB_WRITE32";
838 80 mohor
        end
839
      `WB_GO       :
840
        begin
841 110 mohor
          $display("wb_go, ready=%0d, gen_crc_err=%0d (%0s))", ready, gen_crc_err, text);
842
          debug_wishbone_go(command, ready, gen_crc_err);
843 99 mohor
//          $display("wb_go_tmp, gen_crc_err=0x%0x (%0s))", gen_crc_err, text);
844 93 mohor
//          debug_wishbone_go_tmp(command, crc);
845 88 mohor
          last_wb_cmd = `WB_GO;  last_wb_cmd_text = "WB_GO";
846 80 mohor
        end
847
    endcase
848 2 mohor
  end
849 87 mohor
endtask       // debug_wishbone
850 2 mohor
 
851
 
852 80 mohor
 
853
 
854
 
855
 
856 87 mohor
task debug_wishbone_set_addr;
857 80 mohor
  input [2:0]   command;
858
  input [31:0]  addr;
859
  input [15:0]  length;
860 99 mohor
  input         gen_crc_err;
861 80 mohor
  integer i;
862
 
863
  begin
864 87 mohor
    $display("(%0t) Task debug_wishbone_set_addr: ", $time);
865 80 mohor
 
866
    tms_pad_i<=#1 1;
867
    gen_clk(1);
868
    tms_pad_i<=#1 0;
869
    gen_clk(2);  // we are in shiftDR
870
 
871 114 mohor
    crc_out = 32'hffffffff; // Initialize outgoing CRC
872 99 mohor
 
873 80 mohor
    tdi_pad_i<=#1 1'b0; // chain_select bit = 0
874 114 mohor
    calculate_crc(1'b0);
875 80 mohor
    gen_clk(1);
876
 
877 88 mohor
    for(i=2; i>=0; i=i-1)
878 80 mohor
    begin
879
      tdi_pad_i<=#1 command[i]; // command
880 114 mohor
      calculate_crc(command[i]);
881 80 mohor
      gen_clk(1);
882
    end
883
 
884 88 mohor
    for(i=31; i>=0; i=i-1)       // address
885 80 mohor
    begin
886
      tdi_pad_i<=#1 addr[i];
887 114 mohor
      calculate_crc(addr[i]);
888 80 mohor
      gen_clk(1);
889
    end
890 87 mohor
 
891 88 mohor
    for(i=15; i>=0; i=i-1)       // length
892 80 mohor
    begin
893
      tdi_pad_i<=#1 length[i];
894 114 mohor
      calculate_crc(length[i]);
895 80 mohor
      gen_clk(1);
896
    end
897
 
898 88 mohor
    for(i=31; i>=0; i=i-1)
899 80 mohor
    begin
900 99 mohor
      if (gen_crc_err & (i==0))  // Generate crc error at last crc bit
901 114 mohor
        tdi_pad_i<=#1 ~crc_out[i];   // error crc
902 99 mohor
      else
903 114 mohor
        tdi_pad_i<=#1 crc_out[i];    // ok crc
904 99 mohor
 
905 80 mohor
      gen_clk(1);
906
    end
907
 
908 92 mohor
    tdi_pad_i<=#1 'hz;
909 80 mohor
 
910 114 mohor
    crc_in = 32'hffffffff;  // Initialize incoming CRC
911 110 mohor
    gen_clk(`STATUS_LEN);   // Generating 4 clocks to read out status.
912
 
913 88 mohor
    for(i=0; i<`CRC_LEN -1; i=i+1)  // Getting in the CRC
914 80 mohor
    begin
915
      gen_clk(1);
916
    end
917
 
918
    tms_pad_i<=#1 1;
919
    gen_clk(1);         // to exit1_dr
920
 
921 110 mohor
    if (~crc_match_in)
922
      begin
923
        $display("(%0t) Incoming CRC failed !!!", $time);
924
        $stop;
925
      end
926
 
927 80 mohor
    tms_pad_i<=#1 1;
928
    gen_clk(1);         // to update_dr
929
    tms_pad_i<=#1 0;
930
    gen_clk(1);         // to run_test_idle
931
  end
932 87 mohor
endtask       // debug_wishbone_set_addr
933 80 mohor
 
934
 
935
 
936
 
937
 
938 88 mohor
task debug_wishbone_status;
939
  input [2:0]   command;
940 99 mohor
  input         gen_crc_err;
941 88 mohor
  integer i;
942
 
943
  begin
944
    $display("(%0t) Task debug_wishbone_status: ", $time);
945 80 mohor
 
946 88 mohor
    tms_pad_i<=#1 1;
947
    gen_clk(1);
948
    tms_pad_i<=#1 0;
949
    gen_clk(2);  // we are in shiftDR
950 87 mohor
 
951 114 mohor
    crc_out = 32'hffffffff; // Initialize outgoing CRC
952 99 mohor
 
953 88 mohor
    tdi_pad_i<=#1 1'b0; // chain_select bit = 0
954 114 mohor
    calculate_crc(1'b0);
955 88 mohor
    gen_clk(1);
956 87 mohor
 
957 88 mohor
    for(i=2; i>=0; i=i-1)
958
    begin
959
      tdi_pad_i<=#1 command[i]; // command
960 114 mohor
      calculate_crc(command[i]);
961 88 mohor
      gen_clk(1);
962
    end
963 87 mohor
 
964 99 mohor
    for(i=31; i>=0; i=i-1)
965 88 mohor
    begin
966 99 mohor
      if (gen_crc_err & (i==0))  // Generate crc error at last crc bit
967 114 mohor
        tdi_pad_i<=#1 ~crc_out[i];   // error crc
968 99 mohor
      else
969 114 mohor
        tdi_pad_i<=#1 crc_out[i];    // ok crc
970 99 mohor
 
971 88 mohor
      gen_clk(1);
972
    end
973
 
974 92 mohor
    tdi_pad_i<=#1 1'hz;
975 110 mohor
 
976 114 mohor
    crc_in = 32'hffffffff;  // Initialize incoming CRC
977 110 mohor
 
978 88 mohor
    gen_clk(`STATUS_LEN);   // Generating 4 clocks to read out status.
979
 
980
    for(i=0; i<`CRC_LEN -1; i=i+1)  // Getting in the CRC
981
    begin
982
      gen_clk(1);
983
    end
984
 
985
    tms_pad_i<=#1 1;
986
    gen_clk(1);         // to exit1_dr
987
 
988 110 mohor
    if (~crc_match_in)
989
      begin
990
        $display("(%0t) Incoming CRC failed !!!", $time);
991
        $stop;
992
      end
993
 
994 88 mohor
    tms_pad_i<=#1 1;
995
    gen_clk(1);         // to update_dr
996
    tms_pad_i<=#1 0;
997
    gen_clk(1);         // to run_test_idle
998
  end
999
endtask       // debug_wishbone_status
1000
 
1001
 
1002
 
1003
 
1004
task debug_wishbone_go;
1005
  input [2:0]   command;
1006 110 mohor
  input         wait_for_wb_ready;
1007 99 mohor
  input         gen_crc_err;
1008 90 mohor
  integer i;
1009
  reg   [4:0]   pointer;
1010
 
1011 2 mohor
  begin
1012 88 mohor
    $display("(%0t) Task debug_wishbone_go (previous command was %0s): ", $time, last_wb_cmd_text);
1013
 
1014 80 mohor
    tms_pad_i<=#1 1;
1015
    gen_clk(1);
1016
    tms_pad_i<=#1 0;
1017
    gen_clk(2);  // we are in shiftDR
1018 2 mohor
 
1019 114 mohor
    crc_out = 32'hffffffff; // Initialize outgoing CRC
1020 99 mohor
 
1021 88 mohor
    tdi_pad_i<=#1 1'b0; // chain_select bit = 0
1022 114 mohor
    calculate_crc(1'b0);
1023 80 mohor
    gen_clk(1);
1024 88 mohor
 
1025
    for(i=2; i>=0; i=i-1)
1026
    begin
1027
      tdi_pad_i<=#1 command[i]; // command
1028 114 mohor
      calculate_crc(command[i]);
1029 88 mohor
      gen_clk(1);
1030
    end
1031
 
1032
 
1033
    if ((last_wb_cmd == `WB_WRITE8) | (last_wb_cmd == `WB_WRITE16) | (last_wb_cmd == `WB_WRITE32))  // When WB_WRITEx was previously activated, data needs to be shifted.
1034
      begin
1035 90 mohor
        for (i=0; i<(dbg_tb.i_dbg_top.i_dbg_wb.len << 3); i=i+1)
1036 88 mohor
          begin
1037 90 mohor
            if (!(i%32))
1038 88 mohor
              begin
1039 90 mohor
                wb_data = wb_data + 32'h11111111;
1040
                $display("\t\twb_data = 0x%x", wb_data);
1041 88 mohor
              end
1042 90 mohor
            pointer = 31-i[4:0];
1043
            tdi_pad_i<=#1 wb_data[pointer];
1044 114 mohor
            calculate_crc(wb_data[pointer]);
1045 90 mohor
            gen_clk(1);
1046
 
1047 88 mohor
          end
1048
      end
1049
 
1050 110 mohor
    for(i=31; i>=1; i=i-1)
1051 88 mohor
    begin
1052 114 mohor
      tdi_pad_i<=#1 crc_out[i];
1053 88 mohor
      gen_clk(1);
1054
    end
1055
 
1056 110 mohor
    if (gen_crc_err)  // Generate crc error at last crc bit
1057 114 mohor
      tdi_pad_i<=#1 ~crc_out[0];   // error crc
1058 110 mohor
    else
1059 114 mohor
      tdi_pad_i<=#1 crc_out[0];    // ok crc
1060 99 mohor
 
1061 110 mohor
    if (wait_for_wb_ready)
1062
      begin
1063
        tms_pad_i<=#1 1;
1064
        gen_clk(1);       // to exit1_dr. Last CRC is shifted on this clk
1065
        tms_pad_i<=#1 0;
1066
        gen_clk(1);       // to pause_dr
1067 90 mohor
 
1068 110 mohor
        #2;             // wait a bit for tdo to activate
1069
        while (tdo)     // waiting for wb to send "ready"
1070
        begin
1071
          gen_clk(1);       // staying in pause_dr
1072
        end
1073
 
1074
        tms_pad_i<=#1 1;
1075
        gen_clk(1);       // to exit2_dr
1076
        tms_pad_i<=#1 0;
1077
        gen_clk(1);       // to shift_dr
1078
      end
1079
    else
1080
      begin
1081
        gen_clk(1);       // Last CRC is shifted on this clk
1082
      end
1083 90 mohor
 
1084
 
1085 110 mohor
    tdi_pad_i<=#1 1'hz;
1086 114 mohor
    crc_in = 32'hffffffff;  // Initialize incoming CRC
1087 110 mohor
 
1088 90 mohor
    if ((last_wb_cmd == `WB_READ8) | (last_wb_cmd == `WB_READ16) | (last_wb_cmd == `WB_READ32))  // When WB_WRITEx was previously activated, data needs to be shifted.
1089
      begin
1090 95 mohor
        $display("\t\tGenerating %0d clocks to read %0d data bytes.", dbg_tb.i_dbg_top.i_dbg_wb.data_cnt_limit, dbg_tb.i_dbg_top.i_dbg_wb.data_cnt_limit>>3);
1091
        for (i=0; i<(dbg_tb.i_dbg_top.i_dbg_wb.data_cnt_limit); i=i+1)
1092 92 mohor
          gen_clk(1);
1093 90 mohor
      end
1094
 
1095
 
1096 88 mohor
    gen_clk(`STATUS_LEN);   // Generating 4 clocks to read out status.
1097
 
1098
    for(i=0; i<`CRC_LEN -1; i=i+1)  // Getting in the CRC
1099
    begin
1100
      gen_clk(1);
1101
    end
1102
 
1103
    tms_pad_i<=#1 1;
1104
    gen_clk(1);         // to exit1_dr
1105
 
1106 110 mohor
    if (~crc_match_in)
1107
      begin
1108
        $display("(%0t) Incoming CRC failed !!!", $time);
1109
        $stop;
1110
      end
1111
 
1112 88 mohor
    tms_pad_i<=#1 1;
1113
    gen_clk(1);         // to update_dr
1114 80 mohor
    tms_pad_i<=#1 0;
1115 88 mohor
    gen_clk(1);         // to run_test_idle
1116 2 mohor
  end
1117 88 mohor
endtask       // debug_wishbone_go
1118 2 mohor
 
1119
 
1120 88 mohor
 
1121
 
1122 99 mohor
task debug_cpu;
1123
  input [2:0]   command;
1124
  input [31:0]  addr;
1125
  input [31:0]  data;
1126
  input         gen_crc_err;
1127
  output [31:0] result;
1128
  input [199:0]  text;
1129
  integer i;
1130
 
1131
  begin
1132
   $write("(%0t) Task debug_cpu: ", $time);
1133 88 mohor
 
1134 99 mohor
    test_text = text;
1135
 
1136
    case (command)
1137
//      `WB_STATUS   : 
1138
//        begin
1139
//          $display("wb_status (gen_crc_err=%0d (%0s))", gen_crc_err, text);
1140
//          debug_wishbone_status(command, gen_crc_err);
1141
//          last_wb_cmd = `WB_STATUS;  last_wb_cmd_text = "WB_STATUS";
1142
//        end 
1143
      `CPU_READ_REG   :
1144
        begin
1145
          $display("cpu_read_reg (adr=0x%0x, gen_crc_err=%0d (%0s))", addr, gen_crc_err, text);
1146
          debug_cpu_set_addr(command, addr, gen_crc_err);
1147
          last_wb_cmd = `CPU_READ_REG;  last_wb_cmd_text = "CPU_READ_REG";
1148
        end
1149
      `CPU_WRITE_REG  :
1150
        begin
1151
          $display("cpu_write_reg (adr=0x%0x, gen_crc_err=%0d (%0s))", addr, gen_crc_err, text);
1152
          debug_cpu_set_addr(command, addr, gen_crc_err);
1153
          last_wb_cmd = `CPU_WRITE_REG;  last_wb_cmd_text = "CPU_WRITE_REG";
1154
        end
1155
      `CPU_READ8      :
1156
        begin
1157
          $display("cpu_read8 (adr=0x%0x, gen_crc_err=%0d (%0s))", addr, gen_crc_err, text);
1158
          debug_cpu_set_addr(command, addr, gen_crc_err);
1159
          last_wb_cmd = `CPU_READ8;  last_wb_cmd_text = "CPU_READ8";
1160
        end
1161
      `CPU_READ32     :
1162
        begin
1163
          $display("cpu_read32 (adr=0x%0x, gen_crc_err=%0d (%0s))", addr, gen_crc_err, text);
1164
          debug_cpu_set_addr(command, addr, gen_crc_err);
1165
          last_wb_cmd = `CPU_READ32;  last_wb_cmd_text = "CPU_READ32";
1166
        end
1167
      `CPU_WRITE8     :
1168
        begin
1169
          $display("cpu_write8 (adr=0x%0x, gen_crc_err=%0d (%0s))", addr, gen_crc_err, text);
1170
          debug_cpu_set_addr(command, addr, gen_crc_err);
1171
          last_wb_cmd = `CPU_WRITE8;  last_wb_cmd_text = "CPU_WRITE8";
1172
        end
1173
      `CPU_WRITE32    :
1174
        begin
1175
          $display("cpu_write32 (adr=0x%0x, gen_crc_err=%0d (%0s))", addr, gen_crc_err, text);
1176
          debug_cpu_set_addr(command, addr, gen_crc_err);
1177
          last_wb_cmd = `CPU_WRITE32;  last_wb_cmd_text = "CPU_WRITE32";
1178
        end
1179
      `CPU_GO         :
1180
        begin
1181
          $display("cpu_go, data = 0x%0x, gen_crc_err=%0d (%0s))", data, gen_crc_err, text);
1182
          debug_cpu_go(command, data, gen_crc_err);
1183
          last_wb_cmd = `CPU_GO;  last_wb_cmd_text = "CPU_GO";
1184
        end
1185
      default     :
1186
        begin
1187
          $display("\t\tERROR: Non-existing command while debugging %0s", gen_crc_err, text);
1188
          $stop;
1189
        end
1190
    endcase
1191
  end
1192
endtask       // debug_cpu
1193
 
1194
 
1195
 
1196
task debug_cpu_set_addr;
1197 93 mohor
  input [2:0]   command;
1198 99 mohor
  input [31:0]  addr;
1199
  input         gen_crc_err;
1200 93 mohor
  integer i;
1201 99 mohor
 
1202
  begin
1203
    $display("(%0t) Task debug_cpu_set_addr: ", $time);
1204
 
1205
    tms_pad_i<=#1 1;
1206
    gen_clk(1);
1207
    tms_pad_i<=#1 0;
1208
    gen_clk(2);  // we are in shiftDR
1209
 
1210 114 mohor
    crc_out = 32'hffffffff; // Initialize outgoing CRC
1211 99 mohor
 
1212
    tdi_pad_i<=#1 1'b0; // chain_select bit = 0
1213 114 mohor
    calculate_crc(1'b0);
1214 99 mohor
    gen_clk(1);
1215
 
1216
    for(i=2; i>=0; i=i-1)
1217
    begin
1218
      tdi_pad_i<=#1 command[i]; // command
1219 114 mohor
      calculate_crc(command[i]);
1220 99 mohor
      gen_clk(1);
1221
    end
1222
 
1223
    for(i=31; i>=0; i=i-1)       // address
1224
    begin
1225
      tdi_pad_i<=#1 addr[i];
1226 114 mohor
      calculate_crc(addr[i]);
1227 99 mohor
      gen_clk(1);
1228
    end
1229 93 mohor
 
1230 99 mohor
    for(i=31; i>=0; i=i-1)
1231
    begin
1232
      if (gen_crc_err & (i==0))  // Generate crc error at last crc bit
1233 114 mohor
        tdi_pad_i<=#1 ~crc_out[i];   // error crc
1234 99 mohor
      else
1235 114 mohor
        tdi_pad_i<=#1 crc_out[i];    // ok crc
1236 99 mohor
 
1237
      gen_clk(1);
1238
    end
1239
 
1240
    tdi_pad_i<=#1 'hz;
1241 110 mohor
 
1242 114 mohor
    crc_in = 32'hffffffff;  // Initialize incoming CRC
1243 99 mohor
    gen_clk(`STATUS_LEN);   // Generating 4 clocks to read out status.
1244
 
1245
    for(i=0; i<`CRC_LEN -1; i=i+1)  // Getting in the CRC
1246
    begin
1247
      gen_clk(1);
1248
    end
1249
 
1250
    tms_pad_i<=#1 1;
1251
    gen_clk(1);         // to exit1_dr
1252
 
1253 110 mohor
    if (~crc_match_in)
1254
      begin
1255
        $display("(%0t) Incoming CRC failed !!!", $time);
1256
        $stop;
1257
      end
1258
 
1259 99 mohor
    tms_pad_i<=#1 1;
1260
    gen_clk(1);         // to update_dr
1261
    tms_pad_i<=#1 0;
1262
    gen_clk(1);         // to run_test_idle
1263
  end
1264
endtask       // debug_cpu_set_addr
1265
 
1266
 
1267
 
1268
 
1269
task debug_cpu_go;
1270
  input [2:0]   command;
1271
  input [31:0]  data;
1272
  input         gen_crc_err;
1273
  integer i, len;
1274
 
1275
 
1276 93 mohor
  begin
1277 99 mohor
    $display("(%0t) Task debug_cpu_go (previous command was %0s): ", $time, last_wb_cmd_text);
1278 88 mohor
 
1279 93 mohor
    tms_pad_i<=#1 1;
1280
    gen_clk(1);
1281
    tms_pad_i<=#1 0;
1282
    gen_clk(2);  // we are in shiftDR
1283 88 mohor
 
1284 114 mohor
    crc_out = 32'hffffffff; // Initialize outgoing CRC
1285 93 mohor
    tdi_pad_i<=#1 1'b0; // chain_select bit = 0
1286 114 mohor
    calculate_crc(1'b0);
1287 93 mohor
    gen_clk(1);
1288 88 mohor
 
1289 93 mohor
    for(i=2; i>=0; i=i-1)
1290
    begin
1291
      tdi_pad_i<=#1 command[i]; // command
1292 114 mohor
      calculate_crc(command[i]);
1293 93 mohor
      gen_clk(1);
1294
    end
1295 88 mohor
 
1296
 
1297 99 mohor
    if (last_wb_cmd == `CPU_WRITE32)
1298 93 mohor
      begin
1299 99 mohor
        len = 31;
1300
        $display("\t\tdata = 0x%x", data);
1301
      end
1302
    else if ((last_wb_cmd == `CPU_WRITE8) | (last_wb_cmd == `CPU_WRITE_REG))
1303
      begin
1304
        len = 7;
1305
        $display("\t\tdata = 0x%x", data[7:0]);
1306
      end
1307
    else
1308
      len = 0;
1309
 
1310
    if (len>0)  // When CPU_WRITEx was previously activated, data needs to be shifted.
1311
      begin
1312
        for (i=len; i>=0; i=i-1)
1313 93 mohor
          begin
1314 99 mohor
            tdi_pad_i<=#1 data[i];
1315 114 mohor
            calculate_crc(data[i]);
1316 93 mohor
            gen_clk(1);
1317
          end
1318
      end
1319 2 mohor
 
1320 99 mohor
    for(i=31; i>=0; i=i-1)
1321 93 mohor
    begin
1322 99 mohor
      if (gen_crc_err & (i==0))  // Generate crc error at last crc bit
1323 114 mohor
        tdi_pad_i<=#1 ~crc_out[i];   // error crc
1324 99 mohor
      else
1325 114 mohor
        tdi_pad_i<=#1 crc_out[i];    // ok crc
1326 99 mohor
 
1327 93 mohor
      gen_clk(1);
1328
    end
1329
 
1330
    tdi_pad_i<=#1 1'hz;
1331
 
1332 114 mohor
    crc_in = 32'hffffffff;  // Initialize incoming CRC
1333 93 mohor
 
1334 99 mohor
    if (last_wb_cmd == `CPU_READ32)
1335
      len = 32;
1336
    else if ((last_wb_cmd == `CPU_READ8) | (last_wb_cmd == `CPU_READ_REG))
1337
      len = 8;
1338
    else
1339
      len = 0;
1340 93 mohor
 
1341 99 mohor
    if (len>0)    // When CPU_WRITEx was previously activated, data needs to be shifted.
1342 93 mohor
      begin
1343 99 mohor
        $display("\t\tGenerating %0d clocks to read out the data.", len);
1344
        for (i=0; i<len; i=i+1)
1345 93 mohor
          gen_clk(1);
1346
      end
1347
 
1348
 
1349
    gen_clk(`STATUS_LEN);   // Generating 4 clocks to read out status.
1350
 
1351
    for(i=0; i<`CRC_LEN -1; i=i+1)  // Getting in the CRC
1352
    begin
1353
      gen_clk(1);
1354
    end
1355
 
1356
    tms_pad_i<=#1 1;
1357
    gen_clk(1);         // to exit1_dr
1358
 
1359 110 mohor
    if (~crc_match_in)
1360
      begin
1361
        $display("(%0t) Incoming CRC failed !!!", $time);
1362
        $stop;
1363
      end
1364
 
1365 93 mohor
    tms_pad_i<=#1 1;
1366
    gen_clk(1);         // to update_dr
1367
    tms_pad_i<=#1 0;
1368
    gen_clk(1);         // to run_test_idle
1369
  end
1370 99 mohor
endtask       // debug_cpu_go
1371 93 mohor
 
1372
 
1373
 
1374 113 mohor
always @ (posedge tck_pad_i)
1375
begin
1376
  in_data_be[31:1] <= #1 in_data_be[30:0];
1377
  in_data_be[0]    <= #1 tdo;
1378 93 mohor
 
1379 113 mohor
  in_data_le[31]   <= #1 tdo;
1380
  in_data_le[30:0] <= #1 in_data_le[31:1];
1381
end
1382 93 mohor
 
1383
 
1384
 
1385 114 mohor
// Calculating outgoing CRC
1386
task calculate_crc;
1387
  input data;
1388
 
1389
  begin
1390
    crc_out[0]  <= #1 data          ^ crc_out[31];
1391
    crc_out[1]  <= #1 data          ^ crc_out[0]  ^ crc_out[31];
1392
    crc_out[2]  <= #1 data          ^ crc_out[1]  ^ crc_out[31];
1393
    crc_out[3]  <= #1 crc_out[2];
1394
    crc_out[4]  <= #1 data          ^ crc_out[3]  ^ crc_out[31];
1395
    crc_out[5]  <= #1 data          ^ crc_out[4]  ^ crc_out[31];
1396
    crc_out[6]  <= #1 crc_out[5];
1397
    crc_out[7]  <= #1 data          ^ crc_out[6]  ^ crc_out[31];
1398
    crc_out[8]  <= #1 data          ^ crc_out[7]  ^ crc_out[31];
1399
    crc_out[9]  <= #1 crc_out[8];
1400
    crc_out[10] <= #1 data         ^ crc_out[9]  ^ crc_out[31];
1401
    crc_out[11] <= #1 data         ^ crc_out[10] ^ crc_out[31];
1402
    crc_out[12] <= #1 data         ^ crc_out[11] ^ crc_out[31];
1403
    crc_out[13] <= #1 crc_out[12];
1404
    crc_out[14] <= #1 crc_out[13];
1405
    crc_out[15] <= #1 crc_out[14];
1406
    crc_out[16] <= #1 data         ^ crc_out[15] ^ crc_out[31];
1407
    crc_out[17] <= #1 crc_out[16];
1408
    crc_out[18] <= #1 crc_out[17];
1409
    crc_out[19] <= #1 crc_out[18];
1410
    crc_out[20] <= #1 crc_out[19];
1411
    crc_out[21] <= #1 crc_out[20];
1412
    crc_out[22] <= #1 data         ^ crc_out[21] ^ crc_out[31];
1413
    crc_out[23] <= #1 data         ^ crc_out[22] ^ crc_out[31];
1414
    crc_out[24] <= #1 crc_out[23];
1415
    crc_out[25] <= #1 crc_out[24];
1416
    crc_out[26] <= #1 data         ^ crc_out[25] ^ crc_out[31];
1417
    crc_out[27] <= #1 crc_out[26];
1418
    crc_out[28] <= #1 crc_out[27];
1419
    crc_out[29] <= #1 crc_out[28];
1420
    crc_out[30] <= #1 crc_out[29];
1421
    crc_out[31] <= #1 crc_out[30];
1422
  end
1423
endtask // calculate_crc
1424 93 mohor
 
1425
 
1426 114 mohor
// Calculating and checking input CRC
1427
always @(posedge tck_pad_i)
1428
begin
1429
  crc_in[0]  <= #1 tdo           ^ crc_in[31];
1430
  crc_in[1]  <= #1 tdo           ^ crc_in[0]  ^ crc_in[31];
1431
  crc_in[2]  <= #1 tdo           ^ crc_in[1]  ^ crc_in[31];
1432
  crc_in[3]  <= #1 crc_in[2];
1433
  crc_in[4]  <= #1 tdo           ^ crc_in[3]  ^ crc_in[31];
1434
  crc_in[5]  <= #1 tdo           ^ crc_in[4]  ^ crc_in[31];
1435
  crc_in[6]  <= #1 crc_in[5];
1436
  crc_in[7]  <= #1 tdo           ^ crc_in[6]  ^ crc_in[31];
1437
  crc_in[8]  <= #1 tdo           ^ crc_in[7]  ^ crc_in[31];
1438
  crc_in[9]  <= #1 crc_in[8];
1439
  crc_in[10] <= #1 tdo          ^ crc_in[9]  ^ crc_in[31];
1440
  crc_in[11] <= #1 tdo          ^ crc_in[10] ^ crc_in[31];
1441
  crc_in[12] <= #1 tdo          ^ crc_in[11] ^ crc_in[31];
1442
  crc_in[13] <= #1 crc_in[12];
1443
  crc_in[14] <= #1 crc_in[13];
1444
  crc_in[15] <= #1 crc_in[14];
1445
  crc_in[16] <= #1 tdo          ^ crc_in[15] ^ crc_in[31];
1446
  crc_in[17] <= #1 crc_in[16];
1447
  crc_in[18] <= #1 crc_in[17];
1448
  crc_in[19] <= #1 crc_in[18];
1449
  crc_in[20] <= #1 crc_in[19];
1450
  crc_in[21] <= #1 crc_in[20];
1451
  crc_in[22] <= #1 tdo          ^ crc_in[21] ^ crc_in[31];
1452
  crc_in[23] <= #1 tdo          ^ crc_in[22] ^ crc_in[31];
1453
  crc_in[24] <= #1 crc_in[23];
1454
  crc_in[25] <= #1 crc_in[24];
1455
  crc_in[26] <= #1 tdo          ^ crc_in[25] ^ crc_in[31];
1456
  crc_in[27] <= #1 crc_in[26];
1457
  crc_in[28] <= #1 crc_in[27];
1458
  crc_in[29] <= #1 crc_in[28];
1459
  crc_in[30] <= #1 crc_in[29];
1460
  crc_in[31] <= #1 crc_in[30];
1461
end
1462 93 mohor
 
1463 114 mohor
assign crc_match_in = crc_in == 32'h0;
1464
 
1465
 
1466
 
1467 2 mohor
/**********************************************************************************
1468
*                                                                                 *
1469
*   Printing the information to the screen                                        *
1470
*                                                                                 *
1471
**********************************************************************************/
1472
 
1473 80 mohor
always @ (posedge tck_pad_i)
1474 2 mohor
begin
1475 80 mohor
  if(dbg_tb.i_tap_top.update_ir)
1476
    case(dbg_tb.i_tap_top.jtag_ir[`IR_LENGTH-1:0])
1477
      `EXTEST         : $display("\tInstruction EXTEST entered");
1478
      `SAMPLE_PRELOAD : $display("\tInstruction SAMPLE_PRELOAD entered");
1479
      `IDCODE         : $display("\tInstruction IDCODE entered");
1480
      `MBIST          : $display("\tInstruction MBIST entered");
1481
      `DEBUG          : $display("\tInstruction DEBUG entered");
1482
      `BYPASS         : $display("\tInstruction BYPASS entered");
1483
                default           :     $display("\n\tInstruction not valid. Instruction BYPASS activated !!!");
1484 2 mohor
    endcase
1485
end
1486
 
1487
 
1488
 
1489 80 mohor
// We never use following states: exit2_ir,  exit2_dr,  pause_ir or pause_dr
1490
always @ (posedge tck_pad_i)
1491 2 mohor
begin
1492 80 mohor
  if(dbg_tb.i_tap_top.pause_ir | dbg_tb.i_tap_top.exit2_ir)
1493 2 mohor
    begin
1494 80 mohor
      $display("\n(%0t) ERROR: State pause_ir or exit2_ir detected.", $time);
1495
      $display("(%0t) Simulation stopped !!!", $time);
1496
      $stop;
1497 2 mohor
    end
1498
end
1499
 
1500
 
1501 80 mohor
 
1502 73 mohor
 
1503 88 mohor
// Detecting CRC error
1504 114 mohor
always @ (posedge dbg_tb.i_dbg_top.i_dbg_wb.crc_cnt_end or posedge dbg_tb.i_dbg_top.chain_latch_en or posedge dbg_tb.i_dbg_top.i_dbg_cpu.crc_cnt_end)
1505 88 mohor
begin
1506
  #2;
1507
  if (~dbg_tb.i_dbg_top.crc_match)
1508
    begin
1509
      $display("\t\tCRC ERROR !!!");
1510 90 mohor
      $stop;
1511 88 mohor
    end
1512
end
1513 80 mohor
 
1514 88 mohor
 
1515 90 mohor
 
1516
// Detecting errors in counters
1517
always @ (dbg_tb.i_dbg_top.i_dbg_wb.cmd_cnt or
1518
          dbg_tb.i_dbg_top.i_dbg_wb.cmd_cnt_end or
1519
          dbg_tb.i_dbg_top.i_dbg_wb.addr_len_cnt or
1520
          dbg_tb.i_dbg_top.i_dbg_wb.addr_len_cnt_end or
1521
          dbg_tb.i_dbg_top.i_dbg_wb.data_cnt or
1522
          dbg_tb.i_dbg_top.i_dbg_wb.data_cnt_end or
1523
          dbg_tb.i_dbg_top.i_dbg_wb.cmd_cnt_en or
1524
          dbg_tb.i_dbg_top.i_dbg_wb.addr_len_cnt_en or
1525
          dbg_tb.i_dbg_top.i_dbg_wb.data_cnt_en or
1526
          dbg_tb.i_dbg_top.i_dbg_wb.crc_cnt_en or
1527
          dbg_tb.i_dbg_top.i_dbg_wb.status_cnt1
1528
          //dbg_tb.i_dbg_top.i_dbg_wb.status_cnt2 or
1529
          //dbg_tb.i_dbg_top.i_dbg_wb.status_cnt3 or
1530
          //dbg_tb.i_dbg_top.i_dbg_wb.status_cnt4
1531
          // dbg_tb.i_dbg_top.i_dbg_wb. or
1532
         )
1533
begin
1534
  if ((~dbg_tb.i_dbg_top.i_dbg_wb.cmd_cnt_end) & (
1535
                                                  dbg_tb.i_dbg_top.i_dbg_wb.addr_len_cnt_en |
1536
                                                  dbg_tb.i_dbg_top.i_dbg_wb.data_cnt_en     |
1537
                                                  dbg_tb.i_dbg_top.i_dbg_wb.crc_cnt_en      |
1538
                                                  dbg_tb.i_dbg_top.i_dbg_wb.status_cnt1
1539
                                                 )
1540
     )
1541
    begin
1542
      $display("\n\n\t\t(%0t) ERROR in counters !!!", $time);
1543
      #10000;
1544
      $stop;
1545
    end
1546
 
1547
 
1548
 
1549
end
1550
 
1551
 
1552
 
1553
 
1554
 
1555 91 mohor
 
1556 80 mohor
endmodule // dbg_tb
1557
 
1558
 

powered by: WebSVN 2.1.0

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