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 96

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 80 mohor
//// Copyright (C) 2000 - 2003 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 96 mohor
// Revision 1.23  2004/01/14 22:59:01  mohor
47
// Temp version.
48
//
49 95 mohor
// Revision 1.22  2004/01/13 11:28:30  mohor
50
// tmp version.
51
//
52 93 mohor
// Revision 1.21  2004/01/10 07:50:41  mohor
53
// temp version.
54
//
55 92 mohor
// Revision 1.20  2004/01/09 12:49:23  mohor
56
// tmp version.
57
//
58 91 mohor
// Revision 1.19  2004/01/08 17:53:12  mohor
59
// tmp version.
60
//
61 90 mohor
// Revision 1.18  2004/01/07 11:59:48  mohor
62
// temp4 version.
63
//
64 89 mohor
// Revision 1.17  2004/01/06 17:14:59  mohor
65
// temp3 version.
66
//
67 88 mohor
// Revision 1.16  2004/01/05 12:16:50  mohor
68
// tmp2 version.
69
//
70 87 mohor
// Revision 1.15  2003/12/23 14:26:01  mohor
71
// New version of the debug interface. Not finished, yet.
72
//
73 80 mohor
// Revision 1.14  2003/10/23 16:16:30  mohor
74
// CRC logic changed.
75
//
76 73 mohor
// Revision 1.13  2003/08/28 13:54:33  simons
77
// Three more chains added for cpu debug access.
78
//
79 63 simons
// Revision 1.12  2002/05/07 14:44:52  mohor
80
// mon_cntl_o signals that controls monitor mux added.
81
//
82 47 mohor
// Revision 1.11  2002/03/12 14:32:26  mohor
83
// Few outputs for boundary scan chain added.
84
//
85 38 mohor
// Revision 1.10  2002/03/08 15:27:08  mohor
86
// Structure changed. Hooks for jtag chain added.
87
//
88 36 mohor
// Revision 1.9  2001/10/19 11:39:20  mohor
89
// dbg_timescale.v changed to timescale.v This is done for the simulation of
90
// few different cores in a single project.
91
//
92 17 mohor
// Revision 1.8  2001/10/17 10:39:17  mohor
93
// bs_chain_o added.
94
//
95 15 mohor
// Revision 1.7  2001/10/16 10:10:18  mohor
96
// Signal names changed to lowercase.
97
//
98 13 mohor
// Revision 1.6  2001/10/15 09:52:50  mohor
99
// Wishbone interface added, few fixes for better performance,
100
// hooks for boundary scan testing added.
101
//
102 12 mohor
// Revision 1.5  2001/09/24 14:06:12  mohor
103
// Changes connected to the OpenRISC access (SPR read, SPR write).
104
//
105 11 mohor
// Revision 1.4  2001/09/20 10:10:29  mohor
106
// Working version. Few bugs fixed, comments added.
107
//
108 9 mohor
// Revision 1.3  2001/09/19 11:54:03  mohor
109
// Minor changes for simulation.
110
//
111 6 mohor
// Revision 1.2  2001/09/18 14:12:43  mohor
112
// Trace fixed. Some registers changed, trace simplified.
113
//
114 5 mohor
// Revision 1.1.1.1  2001/09/13 13:49:19  mohor
115
// Initial official release.
116
//
117 2 mohor
// Revision 1.3  2001/06/01 22:23:40  mohor
118
// This is a backup. It is not a fully working version. Not for use, yet.
119
//
120
// Revision 1.2  2001/05/18 13:10:05  mohor
121
// Headers changed. All additional information is now avaliable in the README.txt file.
122
//
123
// Revision 1.1.1.1  2001/05/18 06:35:15  mohor
124
// Initial release
125
//
126
//
127
 
128
 
129 17 mohor
`include "timescale.v"
130 2 mohor
`include "dbg_defines.v"
131 80 mohor
`include "dbg_wb_defines.v"
132
//`include "dbg_tb_defines.v"
133 2 mohor
 
134
// Test bench
135
module dbg_tb;
136
 
137 80 mohor
parameter TCLK = 50;   // Clock half period (Clok period = 100 ns => 10 MHz)
138 2 mohor
 
139 80 mohor
reg   tms_pad_i;
140
reg   tck_pad_i;
141
reg   trst_pad_i;
142
reg   tdi_pad_i;
143
wire  tdo_pad_o;
144
wire  tdo_padoe_o;
145 2 mohor
 
146 80 mohor
wire  shift_dr_o;
147
wire  pause_dr_o;
148
wire  update_dr_o;
149 2 mohor
 
150 80 mohor
wire  extest_select_o;
151
wire  sample_preload_select_o;
152
wire  mbist_select_o;
153
wire  debug_select_o;
154 2 mohor
 
155 80 mohor
// WISHBONE common signals
156
reg   wb_rst_i;
157
reg   wb_clk_i;
158
 
159
// WISHBONE master interface
160
wire [31:0] wb_adr_o;
161
wire [31:0] wb_dat_o;
162
wire [31:0] wb_dat_i;
163
wire        wb_cyc_o;
164
wire        wb_stb_o;
165
wire  [3:0] wb_sel_o;
166
wire        wb_we_o;
167
wire        wb_ack_i;
168
wire        wb_cab_o;
169
wire        wb_err_i;
170
wire  [2:0] wb_cti_o;
171
wire  [1:0] wb_bte_o;
172 2 mohor
 
173 87 mohor
// Text used for easier debugging
174
reg  [99:0] test_text;
175 88 mohor
reg   [2:0] last_wb_cmd;
176
reg  [99:0] last_wb_cmd_text;
177
reg  [31:0] wb_data;
178 2 mohor
 
179
 
180 12 mohor
 
181 80 mohor
wire  tdo_o;
182 12 mohor
 
183 80 mohor
wire  debug_tdi_i;
184
wire  bs_chain_tdi_i;
185
wire  mbist_tdi_i;
186 73 mohor
 
187 80 mohor
reg   test_enabled;
188 73 mohor
 
189 80 mohor
reg [31:0] result;
190 2 mohor
 
191 88 mohor
reg [31:0] tmp_crc;
192
reg [31:0] shifted_in_crc;
193
 
194 80 mohor
wire tdo;
195 73 mohor
 
196 80 mohor
assign tdo = tdo_padoe_o? tdo_pad_o : 1'hz;
197 73 mohor
 
198 80 mohor
// Connecting TAP module
199
tap_top i_tap_top (
200
                    .tms_pad_i(tms_pad_i),
201
                    .tck_pad_i(tck_pad_i),
202
                    .trst_pad_i(!trst_pad_i),
203
                    .tdi_pad_i(tdi_pad_i),
204
                    .tdo_pad_o(tdo_pad_o),
205
                    .tdo_padoe_o(tdo_padoe_o),
206 38 mohor
 
207 80 mohor
                    // TAP states
208
                    .shift_dr_o(shift_dr_o),
209
                    .pause_dr_o(pause_dr_o),
210
                    .update_dr_o(update_dr_o),
211 38 mohor
 
212 80 mohor
                    // Select signals for boundary scan or mbist
213
                    .extest_select_o(extest_select_o),
214
                    .sample_preload_select_o(sample_preload_select_o),
215
                    .mbist_select_o(mbist_select_o),
216
                    .debug_select_o(debug_select_o),
217 2 mohor
 
218 80 mohor
                    // TDO signal that is connected to TDI of sub-modules.
219
                    .tdo_o(tdo_o),
220 38 mohor
 
221 80 mohor
                    // TDI signals from sub-modules
222
                    .debug_tdi_i(debug_tdi_i),        // from debug module
223
                    .bs_chain_tdi_i(bs_chain_tdi_i),  // from Boundary Scan Chain
224
                    .mbist_tdi_i(mbist_tdi_i)         // from Mbist Chain
225 73 mohor
 
226 38 mohor
               );
227 2 mohor
 
228
 
229 80 mohor
dbg_top i_dbg_top  (
230
                    .tck_i(tck_pad_i),
231
                    .tdi_i(tdo_o),
232
                    .tdo_o(debug_tdi_i),
233
 
234
                    // TAP states
235
                    .shift_dr_i   (shift_dr_o),
236
                    .pause_dr_i   (pause_dr_o),
237
                    .update_dr_i  (update_dr_o),
238
 
239
                    // Instructions
240
                    .debug_select_i(debug_select_o),
241 12 mohor
 
242 80 mohor
                    // WISHBONE common signals
243
                    .wb_rst_i      (wb_rst_i),
244
                    .wb_clk_i      (wb_clk_i),
245
 
246
                    // WISHBONE master interface
247
                    .wb_adr_o      (wb_adr_o),
248
                    .wb_dat_o      (wb_dat_o),
249
                    .wb_dat_i      (wb_dat_i),
250
                    .wb_cyc_o      (wb_cyc_o),
251
                    .wb_stb_o      (wb_stb_o),
252
                    .wb_sel_o      (wb_sel_o),
253
                    .wb_we_o       (wb_we_o),
254
                    .wb_ack_i      (wb_ack_i),
255
                    .wb_cab_o      (wb_cab_o),
256
                    .wb_err_i      (wb_err_i),
257
                    .wb_cti_o      (wb_cti_o),
258
                    .wb_bte_o      (wb_bte_o)
259
                   );
260 12 mohor
 
261
 
262 80 mohor
wb_slave_behavioral wb_slave
263
                   (
264
                    .CLK_I(wb_clk_i),
265
                    .RST_I(wb_rst_i),
266
                    .ACK_O(wb_ack_i),
267
                    .ADR_I(wb_adr_o),
268
                    .CYC_I(wb_cyc_o),
269
                    .DAT_O(wb_dat_i),
270
                    .DAT_I(wb_dat_o),
271
                    .ERR_O(wb_err_i),
272
                    .RTY_O(),      // NOT USED for now!
273
                    .SEL_I(wb_sel_o),
274
                    .STB_I(wb_stb_o),
275
                    .WE_I (wb_we_o),
276
                    .CAB_I(1'b0)
277
                   );
278 2 mohor
 
279
 
280 80 mohor
// Initial values
281 2 mohor
initial
282
begin
283 80 mohor
  test_enabled = 1'b0;
284 88 mohor
  wb_data = 32'h01234567;
285 80 mohor
  trst_pad_i = 1'b1;
286
  tms_pad_i = 1'hz;
287
  tck_pad_i = 1'hz;
288
  tdi_pad_i = 1'hz;
289
 
290
  #100;
291
  trst_pad_i = 1'b0;
292
  #100;
293
  trst_pad_i = 1'b1;
294
  #1 test_enabled<=#1 1'b1;
295 2 mohor
end
296
 
297 80 mohor
initial
298
begin
299
  wb_rst_i = 1'b0;
300
  #1000;
301
  wb_rst_i = 1'b1;
302
  #1000;
303
  wb_rst_i = 1'b0;
304 2 mohor
 
305 80 mohor
  // Initial values for wishbone slave model
306 96 mohor
  wb_slave.cycle_response(`ACK_RESPONSE, 9'h55, 8'h2);   // (`ACK_RESPONSE, wbs_waits, wbs_retries);
307 80 mohor
end
308
 
309
initial
310 2 mohor
begin
311 80 mohor
  wb_clk_i = 1'b0;
312
  forever #5 wb_clk_i = ~wb_clk_i;
313 2 mohor
end
314
 
315 80 mohor
always @ (posedge test_enabled)
316
begin
317 2 mohor
 
318 80 mohor
  $display("//////////////////////////////////////////////////////////////////");
319
  $display("//                                                              //");
320
  $display("//  (%0t) dbg_tb starting                                     //", $time);
321
  $display("//                                                              //");
322
  $display("//////////////////////////////////////////////////////////////////");
323 2 mohor
 
324 80 mohor
  initialize_memory(32'h12340000, 32'h00100000);  // Initialize 0x100000 bytes starting from address 0x12340000
325 2 mohor
 
326 80 mohor
  reset_tap;
327 95 mohor
 
328
  #500;
329 80 mohor
  goto_run_test_idle;
330 12 mohor
 
331 80 mohor
  // Testing read and write to internal registers
332
  #10000;
333
  set_instruction(`IDCODE);
334
  read_id_code;
335 12 mohor
 
336 80 mohor
  set_instruction(`DEBUG);
337
  #10000;
338 2 mohor
 
339 80 mohor
  chain_select(`WISHBONE_SCAN_CHAIN, 32'hf2bcd929);
340 12 mohor
 
341 80 mohor
//  #10000;
342
//  xxx(4'b1001, 32'he579b242);
343 12 mohor
 
344 80 mohor
  #10000;
345 2 mohor
 
346 88 mohor
//  debug_wishbone(`WB_READ8, 1'b0, 32'h12345678, 16'h4, 32'h57ecda62, result, "abc 1"); // {command, ready, addr, length, crc, result, text}
347
//  debug_wishbone(`WB_READ8, 1'b0, 32'h12345679, 16'h4, 32'h563476e5, result, "abc 2"); // {command, ready, addr, length, crc, result, text}
348
//  debug_wishbone(`WB_READ8, 1'b0, 32'h1234567a, 16'h4, 32'h545d836c, result, "abc 3"); // {command, ready, addr, length, crc, result, text}
349
//
350
//  debug_wishbone(`WB_READ16, 1'b0, 32'h12345678, 16'h4, 32'h86156251, result, "abc 4"); // {command, ready, addr, length, crc, result, text}
351
//  debug_wishbone(`WB_READ16, 1'b0, 32'h1234567a, 16'h4, 32'h85a43b5f, result, "abc 5"); // {command, ready, addr, length, crc, result, text}
352
//
353 90 mohor
  debug_wishbone(`WB_READ32, 1'b0, 32'h12345678, 16'h4, 32'hc9420a40, result, "read32 1"); // {command, ready, addr, length, crc, result, text}
354 88 mohor
//
355
//  debug_wishbone(`WB_READ16, 1'b0, 32'h12345679, 16'h4, 32'h87cdced6, result, "abc 6"); // {command, ready, addr, length, crc, result, text}
356 2 mohor
 
357 80 mohor
  #10000;
358
//  xxx(4'b1001, 32'he579b242);
359
 
360 90 mohor
  debug_wishbone(`WB_READ32, 1'b1, 32'h12345678, 16'h4, 32'hc9420a40, result, "read32 2"); // {command, ready, addr, length, crc, result, text}
361 87 mohor
 
362
  #10000;
363 96 mohor
  wb_slave.cycle_response(`ACK_RESPONSE, 9'h55, 8'h2);   // (`ACK_RESPONSE, wbs_waits, wbs_retries);
364 90 mohor
  debug_wishbone(`WB_READ32, 1'b1, 32'h12346668, 16'h4, 32'hc935a962, result, "read32 3"); // {command, ready, addr, length, crc, result, text}
365 80 mohor
 
366
  #10000;
367 96 mohor
  wb_slave.cycle_response(`ERR_RESPONSE, 9'h03, 8'h2);   // (`ERR_RESPONSE, wbs_waits, wbs_retries);
368 90 mohor
  debug_wishbone(`WB_READ32, 1'b1, 32'h12346668, 16'h4, 32'hc935a962, result, "read32 4"); // {command, ready, addr, length, crc, result, text}
369 80 mohor
 
370
  #10000;
371 88 mohor
  debug_wishbone(`WB_STATUS, 1'b0, 32'h0, 16'h0, 32'hc7b0424d, result, "status 1"); // {command, ready, addr, length, crc, result, text}
372 80 mohor
 
373 87 mohor
  #10000;
374 88 mohor
  debug_wishbone(`WB_STATUS, 1'b0, 32'h0, 16'h0, 32'hc7b0424d, result, "status 2"); // {command, ready, addr, length, crc, result, text}
375 80 mohor
 
376 87 mohor
  #10000;
377 96 mohor
  wb_slave.cycle_response(`ACK_RESPONSE, 9'h012, 8'h2);   // (`ACK_RESPONSE, wbs_waits, wbs_retries);
378 90 mohor
  debug_wishbone(`WB_READ32, 1'b1, 32'h12347778, 16'hc, 32'hd9ce3bbe, result, "read32 5"); // {command, ready, addr, length, crc, result, text}
379 80 mohor
 
380 87 mohor
  #10000;
381 90 mohor
  debug_wishbone(`WB_WRITE32, 1'b0, 32'h12346668, 16'h8, 32'hc5a58ff5, result, "wr32 len8"); // {command, ready, addr, length, crc, result, text}
382 87 mohor
 
383
  #10000;
384 90 mohor
  debug_wishbone(`WB_WRITE16, 1'b0, 32'h12344446, 16'h8, 32'hed029606, result, "wr16 len8"); // {command, ready, addr, length, crc, result, text}
385 87 mohor
 
386 88 mohor
  #10000;
387 91 mohor
  debug_wishbone(`WB_WRITE8, 1'b0, 32'h1234010e, 16'h8, 32'h359e2d2a, result, "wr8 len8"); // {command, ready, addr, length, crc, result, text}
388 87 mohor
 
389 88 mohor
  #10000;
390 90 mohor
  debug_wishbone(`WB_GO, 1'b0, 32'h0, 16'h0, 32'h5e9dd377, result, "go 1"); // {command, ready, addr, length, crc, result, text}
391 87 mohor
 
392 89 mohor
  #10000;
393 90 mohor
  debug_wishbone(`WB_READ32, 1'b1, 32'h12340100, 16'hc, 32'h8bbeb90d, result, "read32 6"); // {command, ready, addr, length, crc, result, text}
394 96 mohor
//  debug_wishbone(`WB_READ32, 1'b1, 32'h12340100, 16'hfffc, 32'h4cb960cd, result, "read32 6"); // {command, ready, addr, length, crc, result, text}
395 88 mohor
 
396 89 mohor
  #10000;
397 96 mohor
//  debug_wishbone(`WB_READ16, 1'b1, 32'h12340102, 16'he, 32'hcedab37c, result, "read16 7"); // {command, ready, addr, length, crc, result, text}
398
//  debug_wishbone(`WB_READ16, 1'b1, 32'h12340102, 16'hfffe, 32'h9dd6abc, result, "read16 7"); // {command, ready, addr, length, crc, result, text}
399 88 mohor
 
400 90 mohor
  #10000;
401 96 mohor
//  debug_wishbone(`WB_READ8, 1'b1, 32'h12348804, 16'h6, 32'hbe993245, result, "read8 8"); // {command, ready, addr, length, crc, result, text}  
402
//  debug_wishbone(`WB_READ8, 1'b1, 32'h12348804, 16'hfffc, 32'h56143d53, result, "read8 8"); // {command, ready, addr, length, crc, result, text}
403 89 mohor
 
404 90 mohor
  #10000;
405
  debug_wishbone(`WB_GO, 1'b0, 32'h0, 16'h0, 32'hd4b43491, result, "go 2"); // {command, ready, addr, length, crc, result, text}
406 89 mohor
 
407
 
408 90 mohor
 
409
 
410 80 mohor
/*
411
  // Testing read and write to CPU0 registers
412
  #10000;
413
  set_instruction(`CHAIN_SELECT);
414
  chain_select(`CPU_DEBUG_CHAIN_0, 8'h12);  // {chain, crc}
415
  set_instruction(`DEBUG);
416
  WriteCPURegister(32'h11001100, 32'h00110011, 8'h86);  // {data, addr, crc}
417
 
418
  ReadCPURegister(32'h11001100, 8'hdb);                 // {addr, crc}
419
  ReadCPURegister(32'h11001100, 8'hdb);                 // {addr, crc}
420
*/
421
  #5000 gen_clk(1);            // One extra TCLK for debugging purposes
422 95 mohor
  $display("\n\nSimulation end.");
423 5 mohor
  #1000 $stop;
424 80 mohor
 
425 2 mohor
end
426
 
427 80 mohor
 
428
task initialize_memory;
429
  input [31:0] start_addr;
430
  input [31:0] length;
431
  integer i;
432
  reg [31:0] addr;
433
  begin
434 96 mohor
//    for (i=0; i<length; i=i+4)    // inverted address
435
//      begin
436
//        addr = start_addr + i;
437
//        wb_slave.wr_mem(addr, {addr[7:0], addr[15:8], addr[23:16], addr[31:24]}, 4'hf);    // adr, data, sel
438
//      end
439 80 mohor
    for (i=0; i<length; i=i+4)
440
      begin
441
        addr = start_addr + i;
442 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
443 80 mohor
      end
444
  end
445
endtask
446
 
447
 
448
 
449 2 mohor
// Generation of the TCLK signal
450 80 mohor
task gen_clk;
451
  input [7:0] num;
452 2 mohor
  integer i;
453
  begin
454 80 mohor
    for(i=0; i<num; i=i+1)
455 2 mohor
      begin
456 80 mohor
        #TCLK tck_pad_i<=1;
457
        #TCLK tck_pad_i<=0;
458 2 mohor
      end
459
  end
460
endtask
461
 
462
 
463
// TAP reset
464 80 mohor
task reset_tap;
465 2 mohor
  begin
466 80 mohor
    $display("(%0t) Task reset_tap", $time);
467
    tms_pad_i<=#1 1'b1;
468 95 mohor
    gen_clk(5);
469 2 mohor
  end
470
endtask
471
 
472
 
473
// Goes to RunTestIdle state
474 80 mohor
task goto_run_test_idle;
475 2 mohor
  begin
476 80 mohor
    $display("(%0t) Task goto_run_test_idle", $time);
477
    tms_pad_i<=#1 1'b0;
478
    gen_clk(1);
479 2 mohor
  end
480
endtask
481
 
482
 
483
// sets the instruction to the IR register and goes to the RunTestIdle state
484 80 mohor
task set_instruction;
485
  input [3:0] instr;
486 2 mohor
  integer i;
487
 
488
  begin
489 80 mohor
    $display("(%0t) Task set_instruction", $time);
490
    tms_pad_i<=#1 1;
491
    gen_clk(2);
492
    tms_pad_i<=#1 0;
493
    gen_clk(2);  // we are in shiftIR
494 2 mohor
 
495
    for(i=0; i<`IR_LENGTH-1; i=i+1)
496
    begin
497 80 mohor
      tdi_pad_i<=#1 instr[i];
498
      gen_clk(1);
499 2 mohor
    end
500
 
501 80 mohor
    tdi_pad_i<=#1 instr[i]; // last shift
502
    tms_pad_i<=#1 1;        // going out of shiftIR
503
    gen_clk(1);
504 90 mohor
    tdi_pad_i<=#1 'hz;    // tri-state
505 80 mohor
    gen_clk(1);
506
    tms_pad_i<=#1 0;
507
    gen_clk(1);       // we are in RunTestIdle
508 2 mohor
  end
509
endtask
510
 
511
 
512 80 mohor
// Reads the ID code
513
task read_id_code;
514
  begin
515
    $display("(%0t) Task read_id_code", $time);
516
    tms_pad_i<=#1 1;
517
    gen_clk(1);
518
    tms_pad_i<=#1 0;
519
    gen_clk(2);  // we are in shiftDR
520
 
521
    tdi_pad_i<=#1 0;
522
    gen_clk(31);
523
 
524
    tms_pad_i<=#1 1;        // going out of shiftIR
525
    gen_clk(1);
526
 
527
    tdi_pad_i<=#1 'hz; // tri-state
528
    gen_clk(1);
529
    tms_pad_i<=#1 0;
530
    gen_clk(1);       // we are in RunTestIdle
531
  end
532
endtask
533
 
534
 
535 2 mohor
// sets the selected scan chain and goes to the RunTestIdle state
536 80 mohor
task chain_select;
537
  input [3:0]  data;
538
  input [31:0] crc;
539 2 mohor
  integer i;
540
 
541
  begin
542 80 mohor
    $display("(%0t) Task chain_select", $time);
543
    tms_pad_i<=#1 1;
544
    gen_clk(1);
545
    tms_pad_i<=#1 0;
546
    gen_clk(2);  // we are in shiftDR
547 2 mohor
 
548 80 mohor
    tdi_pad_i<=#1 1'b1; // chain_select bit
549
    gen_clk(1);
550
 
551 2 mohor
    for(i=0; i<`CHAIN_ID_LENGTH; i=i+1)
552
    begin
553 80 mohor
      tdi_pad_i<=#1 data[i];
554
      gen_clk(1);
555 2 mohor
    end
556
 
557 80 mohor
    for(i=0; i<`CRC_LEN; i=i+1)
558 2 mohor
    begin
559 80 mohor
      tdi_pad_i<=#1 crc[`CRC_LEN -1-i];
560
      gen_clk(1);
561 2 mohor
    end
562
 
563 80 mohor
    gen_clk(`STATUS_LEN);   // Generating 5 clocks to read out status.
564
 
565
 
566
    for(i=0; i<`CRC_LEN -1; i=i+1)
567
    begin
568
      tdi_pad_i<=#1 1'b0;
569
      gen_clk(1);
570
    end
571
 
572
    tdi_pad_i<=#1 crc[i]; // last crc
573
    tms_pad_i<=#1 1;
574
    gen_clk(1);         // to exit1_dr
575
 
576
    tdi_pad_i<=#1 'hz;  // tri-state
577
    tms_pad_i<=#1 1;
578
    gen_clk(1);         // to update_dr
579
    tms_pad_i<=#1 0;
580
    gen_clk(1);         // to run_test_idle
581 2 mohor
  end
582
endtask
583
 
584
 
585 87 mohor
 
586
 
587
 
588
 
589
 
590 80 mohor
task debug_wishbone;
591
  input [2:0]   command;
592 87 mohor
  input         ready;
593 80 mohor
  input [31:0]  addr;
594
  input [15:0]  length;
595
  input [31:0]  crc;
596
  output [31:0] result;
597 87 mohor
  input [99:0]  text;
598 80 mohor
  integer i;
599
 
600 2 mohor
  begin
601 80 mohor
   $write("(%0t) Task debug_wishbone: ", $time);
602 2 mohor
 
603 87 mohor
    test_text = text;
604 88 mohor
    shifted_in_crc = crc;
605 36 mohor
 
606 80 mohor
    case (command)
607
      `WB_STATUS   :
608
        begin
609 88 mohor
          $display("wb_status (crc=0x%0x (%0s))", crc, text);
610
          debug_wishbone_status(command, crc);
611
          last_wb_cmd = `WB_STATUS;  last_wb_cmd_text = "WB_STATUS";
612 80 mohor
        end
613
      `WB_READ8    :
614
        begin
615 87 mohor
          $display("wb_read8 (ready=%0d, adr=0x%0x, length=0x%0x, crc=0x%0x (%0s))", ready, addr, length, crc, text);
616
          debug_wishbone_set_addr(command, ready, addr, length, crc);
617 88 mohor
          last_wb_cmd = `WB_READ8;  last_wb_cmd_text = "WB_READ8";
618 80 mohor
        end
619
      `WB_READ16   :
620
        begin
621 87 mohor
          $display("wb_read16 (ready=%0d, adr=0x%0x, length=0x%0x, crc=0x%0x (%0s))", ready, addr, length, crc, text);
622
          debug_wishbone_set_addr(command, ready, addr, length, crc);
623 88 mohor
          last_wb_cmd = `WB_READ16;  last_wb_cmd_text = "WB_READ16";
624 80 mohor
        end
625
      `WB_READ32   :
626
        begin
627 87 mohor
          $display("wb_read32 (ready=%0d, adr=0x%0x, length=0x%0x, crc=0x%0x (%0s))", ready, addr, length, crc, text);
628
          debug_wishbone_set_addr(command, ready, addr, length, crc);
629 88 mohor
          last_wb_cmd = `WB_READ32;  last_wb_cmd_text = "WB_READ32";
630 80 mohor
        end
631
      `WB_WRITE8   :
632
        begin
633 88 mohor
          $display("wb_write8 (adr=0x%0x, length=0x%0x, crc=0x%0x (%0s))", addr, length, crc, text);
634 87 mohor
          debug_wishbone_set_addr(command, ready, addr, length, crc);
635 88 mohor
          last_wb_cmd = `WB_WRITE8;  last_wb_cmd_text = "WB_WRITE8";
636 80 mohor
        end
637
      `WB_WRITE16  :
638
        begin
639 88 mohor
          $display("wb_write16 (adr=0x%0x, length=0x%0x, crc=0x%0x (%0s))", addr, length, crc, text);
640 87 mohor
          debug_wishbone_set_addr(command, ready, addr, length, crc);
641 88 mohor
          last_wb_cmd = `WB_WRITE16;  last_wb_cmd_text = "WB_WRITE16";
642 80 mohor
        end
643
      `WB_WRITE32  :
644
        begin
645 88 mohor
          $display("wb_write32 (adr=0x%0x, length=0x%0x, crc=0x%0x (%0s))", addr, length, crc, text);
646 87 mohor
          debug_wishbone_set_addr(command, ready, addr, length, crc);
647 88 mohor
          last_wb_cmd = `WB_WRITE32;  last_wb_cmd_text = "WB_WRITE32";
648 80 mohor
        end
649
      `WB_GO       :
650
        begin
651 87 mohor
          $display("wb_go, crc=0x%0x (%0s))", crc, text);
652 88 mohor
          debug_wishbone_go(command, crc);
653 93 mohor
//          $display("wb_go_tmp, crc=0x%0x (%0s))", crc, text);
654
//          debug_wishbone_go_tmp(command, crc);
655 88 mohor
          last_wb_cmd = `WB_GO;  last_wb_cmd_text = "WB_GO";
656 80 mohor
        end
657
    endcase
658 2 mohor
  end
659 87 mohor
endtask       // debug_wishbone
660 2 mohor
 
661
 
662 80 mohor
 
663
 
664
 
665
 
666 87 mohor
task debug_wishbone_set_addr;
667 80 mohor
  input [2:0]   command;
668 87 mohor
  input         wait_for_wb_ready;
669 80 mohor
  input [31:0]  addr;
670
  input [15:0]  length;
671
  input [31:0]  crc;
672
  integer i;
673
 
674
  begin
675 87 mohor
    $display("(%0t) Task debug_wishbone_set_addr: ", $time);
676 80 mohor
 
677
    tms_pad_i<=#1 1;
678
    gen_clk(1);
679
    tms_pad_i<=#1 0;
680
    gen_clk(2);  // we are in shiftDR
681
 
682
    tdi_pad_i<=#1 1'b0; // chain_select bit = 0
683
    gen_clk(1);
684
 
685 88 mohor
    for(i=2; i>=0; i=i-1)
686 80 mohor
    begin
687
      tdi_pad_i<=#1 command[i]; // command
688
      gen_clk(1);
689
    end
690
 
691 88 mohor
    for(i=31; i>=0; i=i-1)       // address
692 80 mohor
    begin
693
      tdi_pad_i<=#1 addr[i];
694
      gen_clk(1);
695
    end
696 87 mohor
 
697 88 mohor
    for(i=15; i>=0; i=i-1)       // length
698 80 mohor
    begin
699
      tdi_pad_i<=#1 length[i];
700
      gen_clk(1);
701
    end
702
 
703 88 mohor
    for(i=31; i>=0; i=i-1)
704 80 mohor
    begin
705 88 mohor
      tdi_pad_i<=#1 crc[i];
706 80 mohor
      gen_clk(1);
707
    end
708
 
709 92 mohor
    tdi_pad_i<=#1 'hz;
710 87 mohor
    if (wait_for_wb_ready)
711
      begin
712
        gen_clk(`STATUS_LEN -1);   // Generating 4 clocks to read out status. Going to pause_dr at the end
713
        tms_pad_i<=#1 1;
714
        gen_clk(1);       // to exit1_dr
715
        tms_pad_i<=#1 0;
716
        gen_clk(1);       // to pause_dr
717
 
718
        while (dbg_tb.tdo_pad_o)     // waiting for wb to send "ready" 
719
        begin
720
          gen_clk(1);       // staying in pause_dr
721
        end
722
 
723
        tms_pad_i<=#1 1;
724
        gen_clk(1);       // to exit2_dr
725
        tms_pad_i<=#1 0;
726
        gen_clk(1);       // to shift_dr
727
      end
728
    else
729
      gen_clk(`STATUS_LEN);   // Generating 4 clocks to read out status.
730 80 mohor
 
731 88 mohor
    for(i=0; i<`CRC_LEN -1; i=i+1)  // Getting in the CRC
732 80 mohor
    begin
733
      gen_clk(1);
734
    end
735
 
736
    tms_pad_i<=#1 1;
737
    gen_clk(1);         // to exit1_dr
738
 
739
    tms_pad_i<=#1 1;
740
    gen_clk(1);         // to update_dr
741
    tms_pad_i<=#1 0;
742
    gen_clk(1);         // to run_test_idle
743
  end
744 87 mohor
endtask       // debug_wishbone_set_addr
745 80 mohor
 
746
 
747
 
748
 
749
 
750 88 mohor
task debug_wishbone_status;
751
  input [2:0]   command;
752
  input [31:0]  crc;
753
  integer i;
754
 
755
  begin
756
    $display("(%0t) Task debug_wishbone_status: ", $time);
757 80 mohor
 
758 88 mohor
    tms_pad_i<=#1 1;
759
    gen_clk(1);
760
    tms_pad_i<=#1 0;
761
    gen_clk(2);  // we are in shiftDR
762 87 mohor
 
763 88 mohor
    tdi_pad_i<=#1 1'b0; // chain_select bit = 0
764
    gen_clk(1);
765 87 mohor
 
766 88 mohor
    for(i=2; i>=0; i=i-1)
767
    begin
768
      tdi_pad_i<=#1 command[i]; // command
769
      gen_clk(1);
770
    end
771 87 mohor
 
772 88 mohor
    for(i=31; i>=0; i=i-1)      // crc
773
    begin
774
      tdi_pad_i<=#1 crc[i];
775
      gen_clk(1);
776
    end
777
 
778 92 mohor
    tdi_pad_i<=#1 1'hz;
779 88 mohor
    gen_clk(`STATUS_LEN);   // Generating 4 clocks to read out status.
780
 
781
    for(i=0; i<`CRC_LEN -1; i=i+1)  // Getting in the CRC
782
    begin
783
      gen_clk(1);
784
    end
785
 
786
    tms_pad_i<=#1 1;
787
    gen_clk(1);         // to exit1_dr
788
 
789
    tms_pad_i<=#1 1;
790
    gen_clk(1);         // to update_dr
791
    tms_pad_i<=#1 0;
792
    gen_clk(1);         // to run_test_idle
793
  end
794
endtask       // debug_wishbone_status
795
 
796
 
797
 
798
 
799
task debug_wishbone_go;
800
  input [2:0]   command;
801
  input [31:0]  crc;
802 90 mohor
  integer i;
803
  reg   [4:0]   pointer;
804
 
805 2 mohor
  begin
806 88 mohor
    $display("(%0t) Task debug_wishbone_go (previous command was %0s): ", $time, last_wb_cmd_text);
807
 
808 80 mohor
    tms_pad_i<=#1 1;
809
    gen_clk(1);
810
    tms_pad_i<=#1 0;
811
    gen_clk(2);  // we are in shiftDR
812 2 mohor
 
813 88 mohor
    tdi_pad_i<=#1 1'b0; // chain_select bit = 0
814 80 mohor
    gen_clk(1);
815 88 mohor
 
816
    for(i=2; i>=0; i=i-1)
817
    begin
818
      tdi_pad_i<=#1 command[i]; // command
819
      gen_clk(1);
820
    end
821
 
822
 
823
    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.
824
      begin
825 90 mohor
        for (i=0; i<(dbg_tb.i_dbg_top.i_dbg_wb.len << 3); i=i+1)
826 88 mohor
          begin
827 90 mohor
            if (!(i%32))
828 88 mohor
              begin
829 90 mohor
                wb_data = wb_data + 32'h11111111;
830
                $display("\t\twb_data = 0x%x", wb_data);
831 88 mohor
              end
832 90 mohor
            pointer = 31-i[4:0];
833
            tdi_pad_i<=#1 wb_data[pointer];
834
            gen_clk(1);
835
 
836 88 mohor
          end
837
      end
838
 
839
 
840
    for(i=31; i>=0; i=i-1)      // crc
841
    begin
842
      tdi_pad_i<=#1 crc[i];
843
      gen_clk(1);
844
    end
845
 
846 92 mohor
    tdi_pad_i<=#1 1'hz;
847 90 mohor
 
848
 
849
 
850
    if ((last_wb_cmd == `WB_READ8) | (last_wb_cmd == `WB_READ16) | (last_wb_cmd == `WB_READ32))  // When WB_WRITEx was previously activated, data needs to be shifted.
851
      begin
852 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);
853
        for (i=0; i<(dbg_tb.i_dbg_top.i_dbg_wb.data_cnt_limit); i=i+1)
854 92 mohor
          gen_clk(1);
855 90 mohor
      end
856
 
857
 
858 88 mohor
    gen_clk(`STATUS_LEN);   // Generating 4 clocks to read out status.
859
 
860
    for(i=0; i<`CRC_LEN -1; i=i+1)  // Getting in the CRC
861
    begin
862
      gen_clk(1);
863
    end
864
 
865
    tms_pad_i<=#1 1;
866
    gen_clk(1);         // to exit1_dr
867
 
868
    tms_pad_i<=#1 1;
869
    gen_clk(1);         // to update_dr
870 80 mohor
    tms_pad_i<=#1 0;
871 88 mohor
    gen_clk(1);         // to run_test_idle
872 2 mohor
  end
873 88 mohor
endtask       // debug_wishbone_go
874 2 mohor
 
875
 
876 88 mohor
 
877
 
878
 
879 93 mohor
task debug_wishbone_go_tmp;
880
  input [2:0]   command;
881
  input [31:0]  crc;
882
  integer i;
883
  reg   [4:0]   pointer;
884
 
885
  begin
886
    $display("(%0t) Task debug_wishbone_go_tmp (previous command was %0s): ", $time, last_wb_cmd_text);
887 88 mohor
 
888 93 mohor
    tms_pad_i<=#1 1;
889
    gen_clk(1);
890
    tms_pad_i<=#1 0;
891
    gen_clk(2);  // we are in shiftDR
892 88 mohor
 
893 93 mohor
    tdi_pad_i<=#1 1'b0; // chain_select bit = 0
894
    gen_clk(1);
895 88 mohor
 
896 93 mohor
    for(i=2; i>=0; i=i-1)
897
    begin
898
      tdi_pad_i<=#1 command[i]; // command
899
      gen_clk(1);
900
    end
901 88 mohor
 
902
 
903 93 mohor
    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.
904
      begin
905
        for (i=0; i<(dbg_tb.i_dbg_top.i_dbg_wb.len << 3); i=i+1)
906
          begin
907
            if (!(i%32))
908
              begin
909
                wb_data = wb_data + 32'h11111111;
910
                $display("\t\twb_data = 0x%x", wb_data);
911
              end
912
            pointer = 31-i[4:0];
913
            tdi_pad_i<=#1 wb_data[pointer];
914
            gen_clk(1);
915 2 mohor
 
916 93 mohor
          end
917
      end
918 2 mohor
 
919
 
920 93 mohor
    for(i=31; i>=0; i=i-1)      // crc
921
    begin
922
      tdi_pad_i<=#1 crc[i];
923
      gen_clk(1);
924
    end
925
 
926
    tdi_pad_i<=#1 1'hz;
927
 
928
 
929
 
930
    if ((last_wb_cmd == `WB_READ8) | (last_wb_cmd == `WB_READ16) | (last_wb_cmd == `WB_READ32))  // When WB_WRITEx was previously activated, data needs to be shifted.
931
      begin
932
        $display("\t\tGenerating %0d clocks to read %0d data bytes.", dbg_tb.i_dbg_top.i_dbg_wb.len << 3, dbg_tb.i_dbg_top.i_dbg_wb.len);
933
        $display("\t\tFirst half");
934
//        for (i=0; i<(dbg_tb.i_dbg_top.i_dbg_wb.len << 3); i=i+1)
935
 
936
        for (i=0; i<(dbg_tb.i_dbg_top.i_dbg_wb.len << 3)/2; i=i+1)
937
          begin
938
          gen_clk(1);
939
          end
940
 
941
        tms_pad_i<=#1 1;
942
        gen_clk(1);         // to exit1_dr
943
        tms_pad_i<=#1 0;
944
        gen_clk(1);         // to pause_dr
945
        gen_clk(1000);      // wait in pause_dr
946
        tms_pad_i<=#1 1;
947
        gen_clk(1);         // to exit2_dr
948
        tms_pad_i<=#1 0;    // to shift_dr
949
        gen_clk(1);
950
 
951
        $display("\t\tSecond half");
952
        for (i=0; i<(dbg_tb.i_dbg_top.i_dbg_wb.len << 3)/2; i=i+1)
953
          begin
954
          gen_clk(1);
955
          end
956
 
957
      end
958
 
959
 
960
    gen_clk(`STATUS_LEN);   // Generating 4 clocks to read out status.
961
 
962
    for(i=0; i<`CRC_LEN -1; i=i+1)  // Getting in the CRC
963
    begin
964
      gen_clk(1);
965
    end
966
 
967
    tms_pad_i<=#1 1;
968
    gen_clk(1);         // to exit1_dr
969
 
970
    tms_pad_i<=#1 1;
971
    gen_clk(1);         // to update_dr
972
    tms_pad_i<=#1 0;
973
    gen_clk(1);         // to run_test_idle
974
  end
975
endtask       // debug_wishbone_go_tmp
976
 
977
 
978
 
979
 
980
 
981
 
982
 
983
 
984
 
985
 
986
 
987
 
988
 
989 2 mohor
/**********************************************************************************
990
*                                                                                 *
991
*   Printing the information to the screen                                        *
992
*                                                                                 *
993
**********************************************************************************/
994
 
995 80 mohor
always @ (posedge tck_pad_i)
996 2 mohor
begin
997 80 mohor
  if(dbg_tb.i_tap_top.update_ir)
998
    case(dbg_tb.i_tap_top.jtag_ir[`IR_LENGTH-1:0])
999
      `EXTEST         : $display("\tInstruction EXTEST entered");
1000
      `SAMPLE_PRELOAD : $display("\tInstruction SAMPLE_PRELOAD entered");
1001
      `IDCODE         : $display("\tInstruction IDCODE entered");
1002
      `MBIST          : $display("\tInstruction MBIST entered");
1003
      `DEBUG          : $display("\tInstruction DEBUG entered");
1004
      `BYPASS         : $display("\tInstruction BYPASS entered");
1005
                default           :     $display("\n\tInstruction not valid. Instruction BYPASS activated !!!");
1006 2 mohor
    endcase
1007
end
1008
 
1009
 
1010
 
1011
// Print shifted IDCode
1012 80 mohor
reg [31:0] tmp_data;
1013
always @ (posedge tck_pad_i)
1014 2 mohor
begin
1015 80 mohor
  if(dbg_tb.i_tap_top.idcode_select)
1016 2 mohor
    begin
1017 80 mohor
      if(dbg_tb.i_tap_top.shift_dr)
1018
        tmp_data[31:0]<=#1 {dbg_tb.tdo, tmp_data[31:1]};
1019 2 mohor
      else
1020 80 mohor
      if(dbg_tb.i_tap_top.update_dr)
1021
        if (tmp_data[31:0] != `IDCODE_VALUE)
1022 73 mohor
          begin
1023
            $display("(%0t) ERROR: IDCODE not correct", $time);
1024
            $stop;
1025
          end
1026
        else
1027 80 mohor
          $display("\t\tIDCode = 0x%h", tmp_data[31:0]);
1028 2 mohor
    end
1029
end
1030
 
1031
 
1032 80 mohor
// We never use following states: exit2_ir,  exit2_dr,  pause_ir or pause_dr
1033
always @ (posedge tck_pad_i)
1034 2 mohor
begin
1035 80 mohor
  if(dbg_tb.i_tap_top.pause_ir | dbg_tb.i_tap_top.exit2_ir)
1036 2 mohor
    begin
1037 80 mohor
      $display("\n(%0t) ERROR: State pause_ir or exit2_ir detected.", $time);
1038
      $display("(%0t) Simulation stopped !!!", $time);
1039
      $stop;
1040 2 mohor
    end
1041
end
1042
 
1043
 
1044 80 mohor
// sets the selected scan chain and goes to the RunTestIdle state
1045
task xxx;
1046
  input [3:0]  data;
1047
  input [31:0] crc;
1048
  integer i;
1049
 
1050
  begin
1051
    $display("(%0t) Task xxx", $time);
1052
    tms_pad_i<=#1 1;
1053
    gen_clk(1);
1054
    tms_pad_i<=#1 0;
1055
    gen_clk(2);  // we are in shiftDR
1056
 
1057
    for(i=0; i<4; i=i+1)
1058 73 mohor
    begin
1059 80 mohor
      tdi_pad_i<=#1 data[i];
1060
      gen_clk(1);
1061 73 mohor
    end
1062
 
1063 80 mohor
    for(i=0; i<`CRC_LEN; i=i+1)
1064
    begin
1065
      tdi_pad_i<=#1 crc[`CRC_LEN - 1 - i];
1066
      gen_clk(1);
1067
    end
1068 73 mohor
 
1069 80 mohor
    gen_clk(`STATUS_LEN);   // Generating 5 clocks to read out status.
1070 73 mohor
 
1071
 
1072 80 mohor
    for(i=0; i<`CRC_LEN -1; i=i+1)
1073
    begin
1074
      tdi_pad_i<=#1 1'b0;
1075
      gen_clk(1);
1076
    end
1077 73 mohor
 
1078 80 mohor
    tdi_pad_i<=#1 crc[i]; // last crc
1079
    tms_pad_i<=#1 1;
1080
    gen_clk(1);         // to exit1_dr
1081 73 mohor
 
1082 80 mohor
    tdi_pad_i<=#1 'hz;  // tri-state
1083
    tms_pad_i<=#1 1;
1084
    gen_clk(1);         // to update_dr
1085
    tms_pad_i<=#1 0;
1086
    gen_clk(1);         // to run_test_idle
1087
  end
1088
endtask
1089 2 mohor
 
1090
 
1091 88 mohor
// Printing CRC
1092
//always @ (posedge dbg_tb.i_dbg_top.i_dbg_wb.data_cnt_end)
1093 96 mohor
always @ (dbg_tb.i_dbg_top.i_dbg_wb.crc_cnt or dbg_tb.i_dbg_top.i_dbg_crc32_d1_in.crc)
1094 88 mohor
begin
1095
  #2;
1096 96 mohor
  if (dbg_tb.i_dbg_top.i_dbg_wb.crc_cnt == 0)
1097 88 mohor
    tmp_crc = dbg_tb.i_dbg_top.i_dbg_crc32_d1_in.crc;
1098
end
1099 80 mohor
 
1100
 
1101 88 mohor
// Detecting CRC error
1102
always @ (posedge dbg_tb.i_dbg_top.i_dbg_wb.crc_cnt_end)
1103
begin
1104
  #2;
1105
  if (~dbg_tb.i_dbg_top.crc_match)
1106
    begin
1107
      $display("\t\tCRC ERROR !!!");
1108
      $display("\t\tCRC needed (%0s) = 0x%0x , shifted_in = 0x%0x", test_text, tmp_crc, shifted_in_crc);
1109 90 mohor
      $stop;
1110 88 mohor
    end
1111
end
1112 80 mohor
 
1113 88 mohor
 
1114 90 mohor
 
1115
// Detecting errors in counters
1116
always @ (dbg_tb.i_dbg_top.i_dbg_wb.cmd_cnt or
1117
          dbg_tb.i_dbg_top.i_dbg_wb.cmd_cnt_end or
1118
          dbg_tb.i_dbg_top.i_dbg_wb.addr_len_cnt or
1119
          dbg_tb.i_dbg_top.i_dbg_wb.addr_len_cnt_end or
1120
          dbg_tb.i_dbg_top.i_dbg_wb.data_cnt or
1121
          dbg_tb.i_dbg_top.i_dbg_wb.data_cnt_end or
1122
          dbg_tb.i_dbg_top.i_dbg_wb.cmd_cnt_en or
1123
          dbg_tb.i_dbg_top.i_dbg_wb.addr_len_cnt_en or
1124
          dbg_tb.i_dbg_top.i_dbg_wb.data_cnt_en or
1125
          dbg_tb.i_dbg_top.i_dbg_wb.crc_cnt_en or
1126
          dbg_tb.i_dbg_top.i_dbg_wb.status_cnt1
1127
          //dbg_tb.i_dbg_top.i_dbg_wb.status_cnt2 or
1128
          //dbg_tb.i_dbg_top.i_dbg_wb.status_cnt3 or
1129
          //dbg_tb.i_dbg_top.i_dbg_wb.status_cnt4
1130
          // dbg_tb.i_dbg_top.i_dbg_wb. or
1131
         )
1132
begin
1133
  if ((~dbg_tb.i_dbg_top.i_dbg_wb.cmd_cnt_end) & (
1134
                                                  dbg_tb.i_dbg_top.i_dbg_wb.addr_len_cnt_en |
1135
                                                  dbg_tb.i_dbg_top.i_dbg_wb.data_cnt_en     |
1136
                                                  dbg_tb.i_dbg_top.i_dbg_wb.crc_cnt_en      |
1137
                                                  dbg_tb.i_dbg_top.i_dbg_wb.status_cnt1
1138
                                                 )
1139
     )
1140
    begin
1141
      $display("\n\n\t\t(%0t) ERROR in counters !!!", $time);
1142
      #10000;
1143
      $stop;
1144
    end
1145
 
1146
 
1147
 
1148
end
1149
 
1150
 
1151
 
1152
 
1153
 
1154 91 mohor
 
1155 80 mohor
endmodule // dbg_tb
1156
 
1157
 

powered by: WebSVN 2.1.0

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