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

Subversion Repositories or1k

[/] [or1k/] [trunk/] [rc203soc/] [rtl/] [verilog/] [dbg_interface/] [rtl/] [verilog/] [dbg_top.v] - Blame information for rev 1771

Go to most recent revision | Details | Compare with Previous | View Log

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

powered by: WebSVN 2.1.0

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