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 138

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

powered by: WebSVN 2.1.0

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