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

Subversion Repositories dbg_interface

[/] [dbg_interface/] [tags/] [rel_21/] [bench/] [verilog/] [dbg_tb.v] - Blame information for rev 116

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

powered by: WebSVN 2.1.0

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