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

Subversion Repositories dbg_interface

[/] [dbg_interface/] [trunk/] [rtl/] [verilog/] [dbg_top.v] - Blame information for rev 139

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

powered by: WebSVN 2.1.0

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