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

Subversion Repositories dbg_interface

[/] [dbg_interface/] [trunk/] [bench/] [verilog/] [dbg_tb.v] - Blame information for rev 117

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

powered by: WebSVN 2.1.0

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