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

Subversion Repositories dbg_interface

[/] [dbg_interface/] [tags/] [asyst_3/] [rtl/] [verilog/] [dbg_top.v] - Blame information for rev 158

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 mohor
//////////////////////////////////////////////////////////////////////
2
////                                                              ////
3
////  dbg_top.v                                                   ////
4
////                                                              ////
5
////                                                              ////
6 139 igorm
////  This file is part of the SoC Debug Interface.               ////
7 36 mohor
////  http://www.opencores.org/projects/DebugInterface/           ////
8 2 mohor
////                                                              ////
9
////  Author(s):                                                  ////
10 81 mohor
////       Igor Mohor (igorm@opencores.org)                       ////
11 2 mohor
////                                                              ////
12
////                                                              ////
13 81 mohor
////  All additional information is avaliable in the README.txt   ////
14 2 mohor
////  file.                                                       ////
15
////                                                              ////
16
//////////////////////////////////////////////////////////////////////
17
////                                                              ////
18 139 igorm
//// 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 144 igorm
// Revision 1.44  2004/03/28 20:27:02  igorm
47
// New release of the debug interface (3rd. release).
48
//
49 139 igorm
// Revision 1.43  2004/03/22 16:35:46  igorm
50
// Temp version before changing dbg interface.
51
//
52 138 igorm
// Revision 1.42  2004/01/30 10:24:31  mohor
53
// Defines WISHBONE_SUPPORTED and CPU_SUPPORTED added. By default both are
54
// turned on.
55
//
56 128 mohor
// Revision 1.41  2004/01/25 14:04:18  mohor
57
// All flipflops are reset.
58
//
59 123 mohor
// Revision 1.40  2004/01/20 14:23:47  mohor
60
// Define name changed.
61
//
62 117 mohor
// Revision 1.39  2004/01/19 07:32:41  simons
63
// Reset values width added because of FV, a good sentence changed because some tools can not handle it.
64
//
65 108 simons
// Revision 1.38  2004/01/18 09:22:47  simons
66
// Sensitivity list updated.
67
//
68 106 simons
// Revision 1.37  2004/01/17 17:01:14  mohor
69
// Almost finished.
70
//
71 101 mohor
// Revision 1.36  2004/01/16 14:51:33  mohor
72
// cpu registers added.
73
//
74 99 mohor
// Revision 1.35  2004/01/14 22:59:16  mohor
75
// Temp version.
76
//
77 95 mohor
// Revision 1.34  2003/12/23 15:07:34  mohor
78
// New directory structure. New version of the debug interface.
79
// Files that are not needed removed.
80
//
81 81 mohor
// Revision 1.33  2003/10/23 16:17:01  mohor
82
// CRC logic changed.
83
//
84 73 mohor
// Revision 1.32  2003/09/18 14:00:47  simons
85
// Lower two address lines must be always zero.
86
//
87 67 simons
// Revision 1.31  2003/09/17 14:38:57  simons
88
// WB_CNTL register added, some syncronization fixes.
89
//
90 65 simons
// Revision 1.30  2003/08/28 13:55:22  simons
91
// Three more chains added for cpu debug access.
92
//
93 63 simons
// Revision 1.29  2003/07/31 12:19:49  simons
94
// Multiple cpu support added.
95
//
96 57 simons
// Revision 1.28  2002/11/06 14:22:41  mohor
97
// Trst signal is not inverted here any more. Inverted on higher layer !!!.
98
//
99 52 mohor
// Revision 1.27  2002/10/10 02:42:55  mohor
100 73 mohor
// WISHBONE Scan Chain is changed to reflect state of the WISHBONE access (WBInProgress bit added). 
101
// Internal counter is used (counts 256 wb_clk cycles) and when counter exceeds that value, 
102
// wb_cyc_o is negated.
103 52 mohor
//
104 51 mohor
// Revision 1.26  2002/05/07 14:43:59  mohor
105
// mon_cntl_o signals that controls monitor mux added.
106
//
107 47 mohor
// Revision 1.25  2002/04/22 12:54:11  mohor
108
// Signal names changed to lower case.
109
//
110 44 mohor
// Revision 1.24  2002/04/17 13:17:01  mohor
111
// Intentional error removed.
112
//
113 43 mohor
// Revision 1.23  2002/04/17 11:16:33  mohor
114
// A block for checking possible simulation/synthesis missmatch added.
115
//
116 42 mohor
// Revision 1.22  2002/03/12 10:31:53  mohor
117
// tap_top and dbg_top modules are put into two separate modules. tap_top
118
// contains only tap state machine and related logic. dbg_top contains all
119
// logic necessery for debugging.
120
//
121 37 mohor
// Revision 1.21  2002/03/08 15:28:16  mohor
122
// Structure changed. Hooks for jtag chain added.
123
//
124 36 mohor
// Revision 1.20  2002/02/06 12:23:09  mohor
125 81 mohor
// latched_jtag_ir used when muxing TDO instead of JTAG_IR.
126 36 mohor
//
127 33 mohor
// Revision 1.19  2002/02/05 13:34:51  mohor
128
// Stupid bug that was entered by previous update fixed.
129
//
130 32 mohor
// Revision 1.18  2002/02/05 12:41:01  mohor
131
// trst synchronization is not needed and was removed.
132
//
133 31 mohor
// Revision 1.17  2002/01/25 07:58:35  mohor
134
// IDCODE bug fixed, chains reused to decreas size of core. Data is shifted-in
135
// not filled-in. Tested in hw.
136
//
137 30 mohor
// Revision 1.16  2001/12/20 11:17:26  mohor
138
// TDO and TDO Enable signal are separated into two signals.
139
//
140 28 mohor
// Revision 1.15  2001/12/05 13:28:21  mohor
141
// trst signal is synchronized to wb_clk_i.
142
//
143 25 mohor
// Revision 1.14  2001/11/28 09:36:15  mohor
144
// Register length fixed.
145
//
146 22 mohor
// Revision 1.13  2001/11/27 13:37:43  mohor
147
// CRC is returned when chain selection data is transmitted.
148
//
149 21 mohor
// Revision 1.12  2001/11/26 10:47:09  mohor
150
// Crc generation is different for read or write commands. Small synthesys fixes.
151
//
152 20 mohor
// Revision 1.11  2001/11/14 10:10:41  mohor
153
// Wishbone data latched on wb_clk_i instead of risc_clk.
154
//
155 19 mohor
// Revision 1.10  2001/11/12 01:11:27  mohor
156
// Reset signals are not combined any more.
157
//
158 18 mohor
// Revision 1.9  2001/10/19 11:40:01  mohor
159
// dbg_timescale.v changed to timescale.v This is done for the simulation of
160
// few different cores in a single project.
161
//
162 17 mohor
// Revision 1.8  2001/10/17 10:39:03  mohor
163
// bs_chain_o added.
164
//
165 15 mohor
// Revision 1.7  2001/10/16 10:09:56  mohor
166
// Signal names changed to lowercase.
167 13 mohor
//
168 15 mohor
//
169 13 mohor
// Revision 1.6  2001/10/15 09:55:47  mohor
170
// Wishbone interface added, few fixes for better performance,
171
// hooks for boundary scan testing added.
172
//
173 12 mohor
// Revision 1.5  2001/09/24 14:06:42  mohor
174
// Changes connected to the OpenRISC access (SPR read, SPR write).
175
//
176 11 mohor
// Revision 1.4  2001/09/20 10:11:25  mohor
177
// Working version. Few bugs fixed, comments added.
178
//
179 9 mohor
// Revision 1.3  2001/09/19 11:55:13  mohor
180
// Asynchronous set/reset not used in trace any more.
181
//
182 8 mohor
// Revision 1.2  2001/09/18 14:13:47  mohor
183
// Trace fixed. Some registers changed, trace simplified.
184
//
185 5 mohor
// Revision 1.1.1.1  2001/09/13 13:49:19  mohor
186
// Initial official release.
187
//
188 2 mohor
// Revision 1.3  2001/06/01 22:22:35  mohor
189
// This is a backup. It is not a fully working version. Not for use, yet.
190
//
191
// Revision 1.2  2001/05/18 13:10:00  mohor
192
// Headers changed. All additional information is now avaliable in the README.txt file.
193
//
194
// Revision 1.1.1.1  2001/05/18 06:35:02  mohor
195
// Initial release
196
//
197
//
198
 
199 20 mohor
// synopsys translate_off
200 17 mohor
`include "timescale.v"
201 20 mohor
// synopsys translate_on
202 2 mohor
`include "dbg_defines.v"
203 101 mohor
`include "dbg_cpu_defines.v"
204 2 mohor
 
205
// Top module
206 9 mohor
module dbg_top(
207 81 mohor
                // JTAG signals
208
                tck_i,
209
                tdi_i,
210
                tdo_o,
211 128 mohor
                rst_i,
212 57 simons
 
213 81 mohor
                // TAP states
214
                shift_dr_i,
215
                pause_dr_i,
216
                update_dr_i,
217
 
218
                // Instructions
219 128 mohor
                debug_select_i
220 81 mohor
 
221 128 mohor
 
222 139 igorm
                `ifdef DBG_WISHBONE_SUPPORTED
223 12 mohor
                // WISHBONE common signals
224 128 mohor
                ,
225 101 mohor
                wb_clk_i,
226 81 mohor
 
227 12 mohor
                // WISHBONE master interface
228 101 mohor
                wb_adr_o,
229
                wb_dat_o,
230
                wb_dat_i,
231
                wb_cyc_o,
232
                wb_stb_o,
233
                wb_sel_o,
234
                wb_we_o,
235
                wb_ack_i,
236
                wb_cab_o,
237
                wb_err_i,
238
                wb_cti_o,
239 128 mohor
                wb_bte_o
240
                `endif
241 101 mohor
 
242 144 igorm
                `ifdef DBG_CPU0_SUPPORTED
243 101 mohor
                // CPU signals
244 128 mohor
                ,
245 144 igorm
                cpu0_clk_i,
246
                cpu0_addr_o,
247
                cpu0_data_i,
248
                cpu0_data_o,
249
                cpu0_bp_i,
250
                cpu0_stall_o,
251
                cpu0_stb_o,
252
                cpu0_we_o,
253
                cpu0_ack_i,
254
                cpu0_rst_o
255 128 mohor
                `endif
256 144 igorm
 
257
                `ifdef DBG_CPU1_SUPPORTED
258
                // CPU signals
259
                ,
260
                cpu1_clk_i,
261
                cpu1_addr_o,
262
                cpu1_data_i,
263
                cpu1_data_o,
264
                cpu1_bp_i,
265
                cpu1_stall_o,
266
                cpu1_stb_o,
267
                cpu1_we_o,
268
                cpu1_ack_i,
269
                cpu1_rst_o
270
                `endif
271
 
272 2 mohor
              );
273
 
274
 
275 81 mohor
// JTAG signals
276
input   tck_i;
277
input   tdi_i;
278
output  tdo_o;
279 128 mohor
input   rst_i;
280 2 mohor
 
281 81 mohor
// TAP states
282
input   shift_dr_i;
283
input   pause_dr_i;
284
input   update_dr_i;
285 2 mohor
 
286 81 mohor
// Instructions
287
input   debug_select_i;
288 2 mohor
 
289 139 igorm
`ifdef DBG_WISHBONE_SUPPORTED
290 128 mohor
input         wb_clk_i;
291 12 mohor
output [31:0] wb_adr_o;
292
output [31:0] wb_dat_o;
293
input  [31:0] wb_dat_i;
294
output        wb_cyc_o;
295
output        wb_stb_o;
296
output  [3:0] wb_sel_o;
297
output        wb_we_o;
298
input         wb_ack_i;
299
output        wb_cab_o;
300
input         wb_err_i;
301 81 mohor
output  [2:0] wb_cti_o;
302
output  [1:0] wb_bte_o;
303 9 mohor
 
304 138 igorm
reg           wishbone_module;
305 128 mohor
reg           wishbone_ce;
306
wire          tdi_wb;
307
wire          tdo_wb;
308
wire          crc_en_wb;
309
wire          shift_crc_wb;
310
`else
311
wire          crc_en_wb = 1'b0;
312
wire          shift_crc_wb = 1'b0;
313
`endif
314
 
315 144 igorm
`ifdef DBG_CPU0_SUPPORTED
316 101 mohor
// CPU signals
317 144 igorm
input         cpu0_clk_i;
318
output [31:0] cpu0_addr_o;
319
input  [31:0] cpu0_data_i;
320
output [31:0] cpu0_data_o;
321
input         cpu0_bp_i;
322
output        cpu0_stall_o;
323
output        cpu0_stb_o;
324
output        cpu0_we_o;
325
input         cpu0_ack_i;
326
output        cpu0_rst_o;
327 2 mohor
 
328 144 igorm
reg           cpu0_debug_module;
329
reg           cpu0_ce;
330
wire          cpu0_tdi;
331
wire          cpu0_tdo;
332
wire          cpu0_crc_en;
333
wire          cpu0_shift_crc;
334 128 mohor
`else
335 144 igorm
wire          cpu0_crc_en = 1'b0;
336
wire          cpu0_shift_crc = 1'b0;
337 128 mohor
`endif
338 2 mohor
 
339 144 igorm
`ifdef DBG_CPU1_SUPPORTED
340
input         cpu1_clk_i;
341
output [31:0] cpu1_addr_o;
342
input  [31:0] cpu1_data_i;
343
output [31:0] cpu1_data_o;
344
input         cpu1_bp_i;
345
output        cpu1_stall_o;
346
output        cpu1_stb_o;
347
output        cpu1_we_o;
348
input         cpu1_ack_i;
349
output        cpu1_rst_o;
350 128 mohor
 
351 144 igorm
reg           cpu1_debug_module;
352
reg           cpu1_ce;
353
wire          cpu1_tdi;
354
wire          cpu1_tdo;
355
wire          cpu1_crc_en;
356
wire          cpu1_shift_crc;
357
`else
358
wire          cpu1_crc_en = 1'b0;
359
wire          cpu1_shift_crc = 1'b0;
360
`endif
361
 
362
 
363 139 igorm
reg [`DBG_TOP_DATA_CNT -1:0]        data_cnt;
364
reg [`DBG_TOP_CRC_CNT -1:0]         crc_cnt;
365 138 igorm
reg [`DBG_TOP_STATUS_CNT_WIDTH -1:0]      status_cnt;
366 139 igorm
reg [`DBG_TOP_MODULE_DATA_LEN -1:0]  module_dr;
367
reg [`DBG_TOP_MODULE_ID_LENGTH -1:0] module_id;
368 9 mohor
 
369 138 igorm
wire module_latch_en;
370 81 mohor
wire data_cnt_end;
371
wire crc_cnt_end;
372
wire status_cnt_end;
373
reg  crc_cnt_end_q;
374 138 igorm
reg  module_select;
375
reg  module_select_error;
376 81 mohor
wire crc_out;
377
wire crc_match;
378 36 mohor
 
379 81 mohor
wire data_shift_en;
380
wire selecting_command;
381 2 mohor
 
382 81 mohor
reg tdo_o;
383 73 mohor
 
384 99 mohor
 
385
 
386 128 mohor
 
387 99 mohor
wire shift_crc;
388
 
389 81 mohor
// data counter
390 128 mohor
always @ (posedge tck_i or posedge rst_i)
391 81 mohor
begin
392 128 mohor
  if (rst_i)
393 139 igorm
    data_cnt <= #1 {`DBG_TOP_DATA_CNT{1'b0}};
394 81 mohor
  else if(shift_dr_i & (~data_cnt_end))
395
    data_cnt <= #1 data_cnt + 1'b1;
396
  else if (update_dr_i)
397 139 igorm
    data_cnt <= #1 {`DBG_TOP_DATA_CNT{1'b0}};
398 81 mohor
end
399 9 mohor
 
400 11 mohor
 
401 139 igorm
assign data_cnt_end = data_cnt == `DBG_TOP_MODULE_DATA_LEN;
402 2 mohor
 
403
 
404 81 mohor
// crc counter
405 128 mohor
always @ (posedge tck_i or posedge rst_i)
406 2 mohor
begin
407 128 mohor
  if (rst_i)
408 139 igorm
    crc_cnt <= #1 {`DBG_TOP_CRC_CNT{1'b0}};
409 138 igorm
  else if(shift_dr_i & data_cnt_end & (~crc_cnt_end) & module_select)
410 81 mohor
    crc_cnt <= #1 crc_cnt + 1'b1;
411
  else if (update_dr_i)
412 139 igorm
    crc_cnt <= #1 {`DBG_TOP_CRC_CNT{1'b0}};
413 2 mohor
end
414
 
415 138 igorm
assign crc_cnt_end = crc_cnt == `DBG_TOP_CRC_LEN;
416 2 mohor
 
417 12 mohor
 
418 128 mohor
always @ (posedge tck_i or posedge rst_i)
419 123 mohor
begin
420 128 mohor
  if (rst_i)
421 123 mohor
    crc_cnt_end_q  <= #1 1'b0;
422
  else
423 81 mohor
    crc_cnt_end_q  <= #1 crc_cnt_end;
424 123 mohor
end
425 20 mohor
 
426 2 mohor
 
427 81 mohor
// status counter
428 128 mohor
always @ (posedge tck_i or posedge rst_i)
429 2 mohor
begin
430 128 mohor
  if (rst_i)
431 138 igorm
    status_cnt <= #1 {`DBG_TOP_STATUS_CNT_WIDTH{1'b0}};
432 81 mohor
  else if(shift_dr_i & crc_cnt_end & (~status_cnt_end))
433
    status_cnt <= #1 status_cnt + 1'b1;
434
  else if (update_dr_i)
435 138 igorm
    status_cnt <= #1 {`DBG_TOP_STATUS_CNT_WIDTH{1'b0}};
436 2 mohor
end
437
 
438 138 igorm
assign status_cnt_end = status_cnt == `DBG_TOP_STATUS_LEN;
439 42 mohor
 
440
 
441 139 igorm
assign selecting_command = shift_dr_i & (data_cnt == `DBG_TOP_DATA_CNT'h0) & debug_select_i;
442 42 mohor
 
443
 
444 128 mohor
always @ (posedge tck_i or posedge rst_i)
445 2 mohor
begin
446 128 mohor
  if (rst_i)
447 138 igorm
    module_select <= #1 1'b0;
448 81 mohor
  else if(selecting_command & tdi_i)       // Chain select
449 138 igorm
    module_select <= #1 1'b1;
450 81 mohor
  else if (update_dr_i)
451 138 igorm
    module_select <= #1 1'b0;
452 2 mohor
end
453
 
454
 
455 138 igorm
always @ (module_id)
456 2 mohor
begin
457 144 igorm
  `ifdef DBG_CPU0_SUPPORTED
458
  cpu0_debug_module  <= #1 1'b0;
459 128 mohor
  `endif
460 144 igorm
  `ifdef DBG_CPU1_SUPPORTED
461
  cpu1_debug_module  <= #1 1'b0;
462
  `endif
463 139 igorm
  `ifdef DBG_WISHBONE_SUPPORTED
464 138 igorm
  wishbone_module   <= #1 1'b0;
465 128 mohor
  `endif
466 138 igorm
  module_select_error    <= #1 1'b0;
467 81 mohor
 
468 138 igorm
  case (module_id)                /* synthesis parallel_case */
469 144 igorm
    `ifdef DBG_CPU0_SUPPORTED
470
      `DBG_TOP_CPU0_DEBUG_MODULE     :   cpu0_debug_module   <= #1 1'b1;
471 128 mohor
    `endif
472 144 igorm
    `ifdef DBG_CPU1_SUPPORTED
473
      `DBG_TOP_CPU1_DEBUG_MODULE     :   cpu1_debug_module   <= #1 1'b1;
474
    `endif
475 139 igorm
    `ifdef DBG_WISHBONE_SUPPORTED
476 144 igorm
      `DBG_TOP_WISHBONE_DEBUG_MODULE :   wishbone_module     <= #1 1'b1;
477 128 mohor
    `endif
478 144 igorm
    default                          :   module_select_error <= #1 1'b1;
479 81 mohor
  endcase
480 2 mohor
end
481
 
482 20 mohor
 
483 138 igorm
assign module_latch_en = module_select & crc_cnt_end & (~crc_cnt_end_q);
484 99 mohor
 
485
 
486 128 mohor
always @ (posedge tck_i or posedge rst_i)
487 67 simons
begin
488 128 mohor
  if (rst_i)
489 139 igorm
    module_id <= {`DBG_TOP_MODULE_ID_LENGTH{1'b1}};
490 138 igorm
  else if(module_latch_en & crc_match)
491 139 igorm
    module_id <= #1 module_dr[`DBG_TOP_MODULE_DATA_LEN -2:0];
492 67 simons
end
493
 
494 2 mohor
 
495 81 mohor
assign data_shift_en = shift_dr_i & (~data_cnt_end);
496 2 mohor
 
497
 
498 128 mohor
always @ (posedge tck_i or posedge rst_i)
499 2 mohor
begin
500 128 mohor
  if (rst_i)
501 139 igorm
    module_dr <= #1 `DBG_TOP_MODULE_DATA_LEN'h0;
502 123 mohor
  else if (data_shift_en)
503 139 igorm
    module_dr[`DBG_TOP_MODULE_DATA_LEN -1:0] <= #1 {module_dr[`DBG_TOP_MODULE_DATA_LEN -2:0], tdi_i};
504 2 mohor
end
505
 
506
 
507 81 mohor
// Calculating crc for input data
508
dbg_crc32_d1 i_dbg_crc32_d1_in
509
             (
510
              .data       (tdi_i),
511
              .enable     (shift_dr_i),
512
              .shift      (1'b0),
513 128 mohor
              .rst        (rst_i),
514 81 mohor
              .sync_rst   (update_dr_i),
515
              .crc_out    (),
516
              .clk        (tck_i),
517
              .crc_match  (crc_match)
518
             );
519 2 mohor
 
520 12 mohor
 
521 138 igorm
reg tdo_module_select;
522 81 mohor
wire crc_en;
523
wire crc_en_dbg;
524
reg crc_started;
525 128 mohor
 
526 144 igorm
assign crc_en = crc_en_dbg | crc_en_wb | cpu1_crc_en | cpu0_crc_en;
527 128 mohor
 
528 81 mohor
assign crc_en_dbg = shift_dr_i & crc_cnt_end & (~status_cnt_end);
529 12 mohor
 
530 128 mohor
always @ (posedge tck_i or posedge rst_i)
531 12 mohor
begin
532 128 mohor
  if (rst_i)
533 123 mohor
    crc_started <= #1 1'b0;
534
  else if (crc_en)
535 81 mohor
    crc_started <= #1 1'b1;
536
  else if (update_dr_i)
537
    crc_started <= #1 1'b0;
538 12 mohor
end
539
 
540
 
541 81 mohor
reg tdo_tmp;
542 12 mohor
 
543 51 mohor
 
544 81 mohor
// Calculating crc for input data
545
dbg_crc32_d1 i_dbg_crc32_d1_out
546
             (
547
              .data       (tdo_tmp),
548
              .enable     (crc_en), // enable has priority
549
//              .shift      (1'b0),
550
              .shift      (shift_dr_i & crc_started & (~crc_en)),
551 128 mohor
              .rst        (rst_i),
552 81 mohor
              .sync_rst   (update_dr_i),
553
              .crc_out    (crc_out),
554
              .clk        (tck_i),
555
              .crc_match  ()
556
             );
557 51 mohor
 
558 81 mohor
// Following status is shifted out: 
559 138 igorm
// 1. bit:          0 if crc is OK, else 1
560 139 igorm
// 2. bit:          0 if existing module_id is selected, 1 if non-existing module_id is selected
561
// 3. bit:          0 (always) 
562 138 igorm
// 4. bit:          0 (always)
563 51 mohor
 
564
 
565 139 igorm
always @ (status_cnt or crc_match or module_select_error or crc_out)
566 51 mohor
begin
567 81 mohor
  case (status_cnt)                   /* synthesis full_case parallel_case */
568 138 igorm
    `DBG_TOP_STATUS_CNT_WIDTH'd0  : begin
569
                        tdo_module_select = ~crc_match;
570 81 mohor
                      end
571 138 igorm
    `DBG_TOP_STATUS_CNT_WIDTH'd1  : begin
572 139 igorm
                        tdo_module_select = module_select_error;
573 81 mohor
                      end
574 138 igorm
    `DBG_TOP_STATUS_CNT_WIDTH'd2  : begin
575 139 igorm
                        tdo_module_select = 1'b0;
576 81 mohor
                      end
577 138 igorm
    `DBG_TOP_STATUS_CNT_WIDTH'd3  : begin
578
                        tdo_module_select = 1'b0;
579 81 mohor
                      end
580 138 igorm
    `DBG_TOP_STATUS_CNT_WIDTH'd4  : begin
581
                        tdo_module_select = crc_out;
582 81 mohor
                      end
583
  endcase
584 51 mohor
end
585
 
586
 
587 5 mohor
 
588 99 mohor
 
589 144 igorm
assign shift_crc = shift_crc_wb | cpu1_shift_crc | cpu0_shift_crc;
590 99 mohor
 
591 138 igorm
always @ (shift_crc or crc_out or tdo_module_select
592 139 igorm
`ifdef DBG_WISHBONE_SUPPORTED
593 128 mohor
 or wishbone_ce or tdo_wb
594
`endif
595 144 igorm
`ifdef DBG_CPU0_SUPPORTED
596
 or cpu0_ce or cpu0_tdo
597 128 mohor
`endif
598 144 igorm
`ifdef DBG_CPU1_SUPPORTED
599
 or cpu1_ce or cpu1_tdo
600
`endif
601 128 mohor
         )
602 11 mohor
begin
603 99 mohor
  if (shift_crc)          // shifting crc
604 81 mohor
    tdo_tmp = crc_out;
605 139 igorm
  `ifdef DBG_WISHBONE_SUPPORTED
606 81 mohor
  else if (wishbone_ce)   //  shifting data from wb
607
    tdo_tmp = tdo_wb;
608 128 mohor
  `endif
609 144 igorm
  `ifdef DBG_CPU0_SUPPORTED
610
  else if (cpu0_ce)        // shifting data from cpu
611
    tdo_tmp = cpu0_tdo;
612 128 mohor
  `endif
613 144 igorm
  `ifdef DBG_CPU1_SUPPORTED
614
  else if (cpu1_ce)        // shifting data from cpu
615
    tdo_tmp = cpu1_tdo;
616
  `endif
617 11 mohor
  else
618 138 igorm
    tdo_tmp = tdo_module_select;
619 11 mohor
end
620 9 mohor
 
621 11 mohor
 
622 81 mohor
always @ (negedge tck_i)
623 2 mohor
begin
624 81 mohor
  tdo_o <= #1 tdo_tmp;
625 2 mohor
end
626
 
627
 
628
 
629
 
630 81 mohor
// Signals for WISHBONE module
631 9 mohor
 
632
 
633 128 mohor
always @ (posedge tck_i or posedge rst_i)
634 2 mohor
begin
635 128 mohor
  if (rst_i)
636 99 mohor
    begin
637 139 igorm
      `ifdef DBG_WISHBONE_SUPPORTED
638 99 mohor
      wishbone_ce <= #1 1'b0;
639 128 mohor
      `endif
640 144 igorm
      `ifdef DBG_CPU0_SUPPORTED
641
      cpu0_ce <= #1 1'b0;
642 128 mohor
      `endif
643 144 igorm
      `ifdef DBG_CPU1_SUPPORTED
644
      cpu1_ce <= #1 1'b0;
645
      `endif
646 99 mohor
    end
647
  else if(selecting_command & (~tdi_i))
648
    begin
649 139 igorm
      `ifdef DBG_WISHBONE_SUPPORTED
650 138 igorm
      if (wishbone_module)      // wishbone CE
651 99 mohor
        wishbone_ce <= #1 1'b1;
652 128 mohor
      `endif
653 144 igorm
      `ifdef DBG_CPU0_SUPPORTED
654
      if (cpu0_debug_module)     // CPU CE
655
        cpu0_ce <= #1 1'b1;
656 128 mohor
      `endif
657 144 igorm
      `ifdef DBG_CPU1_SUPPORTED
658
      if (cpu1_debug_module)     // CPU CE
659
        cpu1_ce <= #1 1'b1;
660
      `endif
661 99 mohor
    end
662 138 igorm
  else if (update_dr_i)
663 99 mohor
    begin
664 139 igorm
      `ifdef DBG_WISHBONE_SUPPORTED
665 99 mohor
      wishbone_ce <= #1 1'b0;
666 128 mohor
      `endif
667 144 igorm
      `ifdef DBG_CPU0_SUPPORTED
668
      cpu0_ce <= #1 1'b0;
669 128 mohor
      `endif
670 144 igorm
      `ifdef DBG_CPU1_SUPPORTED
671
      cpu1_ce <= #1 1'b0;
672
      `endif
673 99 mohor
    end
674 2 mohor
end
675
 
676
 
677 139 igorm
`ifdef DBG_WISHBONE_SUPPORTED
678 99 mohor
assign tdi_wb  = wishbone_ce & tdi_i;
679 128 mohor
`endif
680
 
681 144 igorm
`ifdef DBG_CPU0_SUPPORTED
682
assign cpu0_tdi = cpu0_ce & tdi_i;
683 128 mohor
`endif
684 144 igorm
`ifdef DBG_CPU1_SUPPORTED
685
assign cpu1_tdi = cpu1_ce & tdi_i;
686
`endif
687 2 mohor
 
688 99 mohor
 
689 139 igorm
`ifdef DBG_WISHBONE_SUPPORTED
690 81 mohor
// Connecting wishbone module
691
dbg_wb i_dbg_wb (
692
                  // JTAG signals
693 101 mohor
                  .tck_i            (tck_i),
694
                  .tdi_i            (tdi_wb),
695
                  .tdo_o            (tdo_wb),
696 2 mohor
 
697 81 mohor
                  // TAP states
698 101 mohor
                  .shift_dr_i       (shift_dr_i),
699
                  .pause_dr_i       (pause_dr_i),
700
                  .update_dr_i      (update_dr_i),
701 2 mohor
 
702 101 mohor
                  .wishbone_ce_i    (wishbone_ce),
703
                  .crc_match_i      (crc_match),
704
                  .crc_en_o         (crc_en_wb),
705
                  .shift_crc_o      (shift_crc_wb),
706 128 mohor
                  .rst_i            (rst_i),
707 2 mohor
 
708 81 mohor
                  // WISHBONE common signals
709 101 mohor
                  .wb_clk_i         (wb_clk_i),
710 5 mohor
 
711 81 mohor
                  // WISHBONE master interface
712 101 mohor
                  .wb_adr_o         (wb_adr_o),
713
                  .wb_dat_o         (wb_dat_o),
714
                  .wb_dat_i         (wb_dat_i),
715
                  .wb_cyc_o         (wb_cyc_o),
716
                  .wb_stb_o         (wb_stb_o),
717
                  .wb_sel_o         (wb_sel_o),
718
                  .wb_we_o          (wb_we_o),
719
                  .wb_ack_i         (wb_ack_i),
720
                  .wb_cab_o         (wb_cab_o),
721
                  .wb_err_i         (wb_err_i),
722
                  .wb_cti_o         (wb_cti_o),
723
                  .wb_bte_o         (wb_bte_o)
724 81 mohor
            );
725 128 mohor
`endif
726 2 mohor
 
727 99 mohor
 
728 144 igorm
 
729
`ifdef DBG_CPU0_SUPPORTED
730
dbg_cpu i_dbg_cpu_or1k (
731
                  // JTAG signals
732
                  .tck_i            (tck_i),
733
                  .tdi_i            (cpu0_tdi),
734
                  .tdo_o            (cpu0_tdo),
735
 
736
                  // TAP states
737
                  .shift_dr_i       (shift_dr_i),
738
                  .pause_dr_i       (pause_dr_i),
739
                  .update_dr_i      (update_dr_i),
740
 
741
                  .cpu_ce_i         (cpu0_ce),
742
                  .crc_match_i      (crc_match),
743
                  .crc_en_o         (cpu0_crc_en),
744
                  .shift_crc_o      (cpu0_shift_crc),
745
                  .rst_i            (rst_i),
746
 
747
                  // CPU signals
748
                  .cpu_clk_i        (cpu0_clk_i),
749
                  .cpu_addr_o       (cpu0_addr_o),
750
                  .cpu_data_i       (cpu0_data_i),
751
                  .cpu_data_o       (cpu0_data_o),
752
                  .cpu_bp_i         (cpu0_bp_i),
753
                  .cpu_stall_o      (cpu0_stall_o),
754
                  .cpu_stb_o        (cpu0_stb_o),
755
                  .cpu_we_o         (cpu0_we_o),
756
                  .cpu_ack_i        (cpu0_ack_i),
757
                  .cpu_rst_o        (cpu0_rst_o)
758
              );
759
 
760
`endif  //  DBG_CPU0_SUPPORTED
761
 
762
 
763
 
764
`ifdef DBG_CPU1_SUPPORTED
765 99 mohor
// Connecting cpu module
766 144 igorm
dbg_cpu i_dbg_cpu_8051 (
767 99 mohor
                  // JTAG signals
768 101 mohor
                  .tck_i            (tck_i),
769 144 igorm
                  .tdi_i            (cpu1_tdi),
770
                  .tdo_o            (cpu1_tdo),
771 99 mohor
 
772
                  // TAP states
773 101 mohor
                  .shift_dr_i       (shift_dr_i),
774
                  .pause_dr_i       (pause_dr_i),
775
                  .update_dr_i      (update_dr_i),
776 99 mohor
 
777 144 igorm
                  .cpu_ce_i         (cpu1_ce),
778 101 mohor
                  .crc_match_i      (crc_match),
779 144 igorm
                  .crc_en_o         (cpu1_crc_en),
780
                  .shift_crc_o      (cpu1_shift_crc),
781 128 mohor
                  .rst_i            (rst_i),
782 101 mohor
 
783
                  // CPU signals
784 144 igorm
                  .cpu_clk_i        (cpu1_clk_i),
785
                  .cpu_addr_o       (cpu1_addr_o),
786
                  .cpu_data_i       (cpu1_data_i),
787
                  .cpu_data_o       (cpu1_data_o),
788
                  .cpu_bp_i         (cpu1_bp_i),
789
                  .cpu_stall_o      (cpu1_stall_o),
790
                  .cpu_stb_o        (cpu1_stb_o),
791
                  .cpu_we_o         (cpu1_we_o),
792
                  .cpu_ack_i        (cpu1_ack_i),
793
                  .cpu_rst_o        (cpu1_rst_o)
794 128 mohor
              );
795 144 igorm
`endif
796 101 mohor
 
797
 
798 9 mohor
endmodule

powered by: WebSVN 2.1.0

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