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

Subversion Repositories or1k_soc_on_altera_embedded_dev_kit

[/] [or1k_soc_on_altera_embedded_dev_kit/] [trunk/] [soc/] [rtl/] [dbg_interface/] [rtl/] [verilog/] [dbg_top.v] - Blame information for rev 12

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 12 xianfeng
//////////////////////////////////////////////////////////////////////
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.44  2004/03/28 20:27:02  igorm
47
// New release of the debug interface (3rd. release).
48
//
49
// Revision 1.43  2004/03/22 16:35:46  igorm
50
// Temp version before changing dbg interface.
51
//
52
// 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
// Revision 1.41  2004/01/25 14:04:18  mohor
57
// All flipflops are reset.
58
//
59
// Revision 1.40  2004/01/20 14:23:47  mohor
60
// Define name changed.
61
//
62
// 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
// Revision 1.38  2004/01/18 09:22:47  simons
66
// Sensitivity list updated.
67
//
68
// Revision 1.37  2004/01/17 17:01:14  mohor
69
// Almost finished.
70
//
71
// Revision 1.36  2004/01/16 14:51:33  mohor
72
// cpu registers added.
73
//
74
// Revision 1.35  2004/01/14 22:59:16  mohor
75
// Temp version.
76
//
77
// 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
// Revision 1.33  2003/10/23 16:17:01  mohor
82
// CRC logic changed.
83
//
84
// Revision 1.32  2003/09/18 14:00:47  simons
85
// Lower two address lines must be always zero.
86
//
87
// Revision 1.31  2003/09/17 14:38:57  simons
88
// WB_CNTL register added, some syncronization fixes.
89
//
90
// Revision 1.30  2003/08/28 13:55:22  simons
91
// Three more chains added for cpu debug access.
92
//
93
// Revision 1.29  2003/07/31 12:19:49  simons
94
// Multiple cpu support added.
95
//
96
// 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
// Revision 1.27  2002/10/10 02:42:55  mohor
100
// 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
//
104
// Revision 1.26  2002/05/07 14:43:59  mohor
105
// mon_cntl_o signals that controls monitor mux added.
106
//
107
// Revision 1.25  2002/04/22 12:54:11  mohor
108
// Signal names changed to lower case.
109
//
110
// Revision 1.24  2002/04/17 13:17:01  mohor
111
// Intentional error removed.
112
//
113
// Revision 1.23  2002/04/17 11:16:33  mohor
114
// A block for checking possible simulation/synthesis missmatch added.
115
//
116
// 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
// Revision 1.21  2002/03/08 15:28:16  mohor
122
// Structure changed. Hooks for jtag chain added.
123
//
124
// Revision 1.20  2002/02/06 12:23:09  mohor
125
// latched_jtag_ir used when muxing TDO instead of JTAG_IR.
126
//
127
// Revision 1.19  2002/02/05 13:34:51  mohor
128
// Stupid bug that was entered by previous update fixed.
129
//
130
// Revision 1.18  2002/02/05 12:41:01  mohor
131
// trst synchronization is not needed and was removed.
132
//
133
// 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
// Revision 1.16  2001/12/20 11:17:26  mohor
138
// TDO and TDO Enable signal are separated into two signals.
139
//
140
// Revision 1.15  2001/12/05 13:28:21  mohor
141
// trst signal is synchronized to wb_clk_i.
142
//
143
// Revision 1.14  2001/11/28 09:36:15  mohor
144
// Register length fixed.
145
//
146
// Revision 1.13  2001/11/27 13:37:43  mohor
147
// CRC is returned when chain selection data is transmitted.
148
//
149
// 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
// Revision 1.11  2001/11/14 10:10:41  mohor
153
// Wishbone data latched on wb_clk_i instead of risc_clk.
154
//
155
// Revision 1.10  2001/11/12 01:11:27  mohor
156
// Reset signals are not combined any more.
157
//
158
// 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
// Revision 1.8  2001/10/17 10:39:03  mohor
163
// bs_chain_o added.
164
//
165
// Revision 1.7  2001/10/16 10:09:56  mohor
166
// Signal names changed to lowercase.
167
//
168
//
169
// 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
// Revision 1.5  2001/09/24 14:06:42  mohor
174
// Changes connected to the OpenRISC access (SPR read, SPR write).
175
//
176
// Revision 1.4  2001/09/20 10:11:25  mohor
177
// Working version. Few bugs fixed, comments added.
178
//
179
// Revision 1.3  2001/09/19 11:55:13  mohor
180
// Asynchronous set/reset not used in trace any more.
181
//
182
// Revision 1.2  2001/09/18 14:13:47  mohor
183
// Trace fixed. Some registers changed, trace simplified.
184
//
185
// Revision 1.1.1.1  2001/09/13 13:49:19  mohor
186
// Initial official release.
187
//
188
// 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
// synopsys translate_off
200
`include "timescale.v"
201
// synopsys translate_on
202
`include "dbg_defines.v"
203
`include "dbg_cpu_defines.v"
204
 
205
// Top module
206
module dbg_top(
207
                // JTAG signals
208
                tck_i,
209
                tdi_i,
210
                tdo_o,
211
                rst_i,
212
 
213
                // TAP states
214
                shift_dr_i,
215
                pause_dr_i,
216
                update_dr_i,
217
 
218
                // Instructions
219
                debug_select_i
220
 
221
 
222
                `ifdef DBG_WISHBONE_SUPPORTED
223
                // WISHBONE common signals
224
                ,
225
                wb_clk_i,
226
 
227
                // WISHBONE master interface
228
                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
                wb_bte_o
240
                `endif
241
 
242
                `ifdef DBG_CPU0_SUPPORTED
243
                // CPU signals
244
                ,
245
                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
                `endif
256
 
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
              );
273
 
274
 
275
// JTAG signals
276
input   tck_i;
277
input   tdi_i;
278
output  tdo_o;
279
input   rst_i;
280
 
281
// TAP states
282
input   shift_dr_i;
283
input   pause_dr_i;
284
input   update_dr_i;
285
 
286
// Instructions
287
input   debug_select_i;
288
 
289
`ifdef DBG_WISHBONE_SUPPORTED
290
input         wb_clk_i;
291
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
output  [2:0] wb_cti_o;
302
output  [1:0] wb_bte_o;
303
 
304
reg           wishbone_module;
305
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
`ifdef DBG_CPU0_SUPPORTED
316
// CPU signals
317
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
 
328
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
`else
335
wire          cpu0_crc_en = 1'b0;
336
wire          cpu0_shift_crc = 1'b0;
337
`endif
338
 
339
`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
 
351
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
reg [`DBG_TOP_DATA_CNT -1:0]        data_cnt;
364
reg [`DBG_TOP_CRC_CNT -1:0]         crc_cnt;
365
reg [`DBG_TOP_STATUS_CNT_WIDTH -1:0]      status_cnt;
366
reg [`DBG_TOP_MODULE_DATA_LEN -1:0]  module_dr;
367
reg [`DBG_TOP_MODULE_ID_LENGTH -1:0] module_id;
368
 
369
wire module_latch_en;
370
wire data_cnt_end;
371
wire crc_cnt_end;
372
wire status_cnt_end;
373
reg  crc_cnt_end_q;
374
reg  module_select;
375
reg  module_select_error;
376
wire crc_out;
377
wire crc_match;
378
 
379
wire data_shift_en;
380
wire selecting_command;
381
 
382
reg tdo_o;
383
 
384
 
385
 
386
 
387
wire shift_crc;
388
 
389
// data counter
390
always @ (posedge tck_i or posedge rst_i)
391
begin
392
  if (rst_i)
393
    data_cnt <= #1 {`DBG_TOP_DATA_CNT{1'b0}};
394
  else if(shift_dr_i & (~data_cnt_end))
395
    data_cnt <= #1 data_cnt + 1'b1;
396
  else if (update_dr_i)
397
    data_cnt <= #1 {`DBG_TOP_DATA_CNT{1'b0}};
398
end
399
 
400
 
401
assign data_cnt_end = data_cnt == `DBG_TOP_MODULE_DATA_LEN;
402
 
403
 
404
// crc counter
405
always @ (posedge tck_i or posedge rst_i)
406
begin
407
  if (rst_i)
408
    crc_cnt <= #1 {`DBG_TOP_CRC_CNT{1'b0}};
409
  else if(shift_dr_i & data_cnt_end & (~crc_cnt_end) & module_select)
410
    crc_cnt <= #1 crc_cnt + 1'b1;
411
  else if (update_dr_i)
412
    crc_cnt <= #1 {`DBG_TOP_CRC_CNT{1'b0}};
413
end
414
 
415
assign crc_cnt_end = crc_cnt == `DBG_TOP_CRC_LEN;
416
 
417
 
418
always @ (posedge tck_i or posedge rst_i)
419
begin
420
  if (rst_i)
421
    crc_cnt_end_q  <= #1 1'b0;
422
  else
423
    crc_cnt_end_q  <= #1 crc_cnt_end;
424
end
425
 
426
 
427
// status counter
428
always @ (posedge tck_i or posedge rst_i)
429
begin
430
  if (rst_i)
431
    status_cnt <= #1 {`DBG_TOP_STATUS_CNT_WIDTH{1'b0}};
432
  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
    status_cnt <= #1 {`DBG_TOP_STATUS_CNT_WIDTH{1'b0}};
436
end
437
 
438
assign status_cnt_end = status_cnt == `DBG_TOP_STATUS_LEN;
439
 
440
 
441
assign selecting_command = shift_dr_i & (data_cnt == `DBG_TOP_DATA_CNT'h0) & debug_select_i;
442
 
443
 
444
always @ (posedge tck_i or posedge rst_i)
445
begin
446
  if (rst_i)
447
    module_select <= #1 1'b0;
448
  else if(selecting_command & tdi_i)       // Chain select
449
    module_select <= #1 1'b1;
450
  else if (update_dr_i)
451
    module_select <= #1 1'b0;
452
end
453
 
454
 
455
always @ (module_id)
456
begin
457
  `ifdef DBG_CPU0_SUPPORTED
458
  cpu0_debug_module  <= #1 1'b0;
459
  `endif
460
  `ifdef DBG_CPU1_SUPPORTED
461
  cpu1_debug_module  <= #1 1'b0;
462
  `endif
463
  `ifdef DBG_WISHBONE_SUPPORTED
464
  wishbone_module   <= #1 1'b0;
465
  `endif
466
  module_select_error    <= #1 1'b0;
467
 
468
  case (module_id)                /* synthesis parallel_case */
469
    `ifdef DBG_CPU0_SUPPORTED
470
      `DBG_TOP_CPU0_DEBUG_MODULE     :   cpu0_debug_module   <= #1 1'b1;
471
    `endif
472
    `ifdef DBG_CPU1_SUPPORTED
473
      `DBG_TOP_CPU1_DEBUG_MODULE     :   cpu1_debug_module   <= #1 1'b1;
474
    `endif
475
    `ifdef DBG_WISHBONE_SUPPORTED
476
      `DBG_TOP_WISHBONE_DEBUG_MODULE :   wishbone_module     <= #1 1'b1;
477
    `endif
478
    default                          :   module_select_error <= #1 1'b1;
479
  endcase
480
end
481
 
482
 
483
assign module_latch_en = module_select & crc_cnt_end & (~crc_cnt_end_q);
484
 
485
 
486
always @ (posedge tck_i or posedge rst_i)
487
begin
488
  if (rst_i)
489
    module_id <= {`DBG_TOP_MODULE_ID_LENGTH{1'b1}};
490
  else if(module_latch_en & crc_match)
491
    module_id <= #1 module_dr[`DBG_TOP_MODULE_DATA_LEN -2:0];
492
end
493
 
494
 
495
assign data_shift_en = shift_dr_i & (~data_cnt_end);
496
 
497
 
498
always @ (posedge tck_i or posedge rst_i)
499
begin
500
  if (rst_i)
501
    module_dr <= #1 `DBG_TOP_MODULE_DATA_LEN'h0;
502
  else if (data_shift_en)
503
    module_dr[`DBG_TOP_MODULE_DATA_LEN -1:0] <= #1 {module_dr[`DBG_TOP_MODULE_DATA_LEN -2:0], tdi_i};
504
end
505
 
506
 
507
// 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
              .rst        (rst_i),
514
              .sync_rst   (update_dr_i),
515
              .crc_out    (),
516
              .clk        (tck_i),
517
              .crc_match  (crc_match)
518
             );
519
 
520
 
521
reg tdo_module_select;
522
wire crc_en;
523
wire crc_en_dbg;
524
reg crc_started;
525
 
526
assign crc_en = crc_en_dbg | crc_en_wb | cpu1_crc_en | cpu0_crc_en;
527
 
528
assign crc_en_dbg = shift_dr_i & crc_cnt_end & (~status_cnt_end);
529
 
530
always @ (posedge tck_i or posedge rst_i)
531
begin
532
  if (rst_i)
533
    crc_started <= #1 1'b0;
534
  else if (crc_en)
535
    crc_started <= #1 1'b1;
536
  else if (update_dr_i)
537
    crc_started <= #1 1'b0;
538
end
539
 
540
 
541
reg tdo_tmp;
542
 
543
 
544
// 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
              .rst        (rst_i),
552
              .sync_rst   (update_dr_i),
553
              .crc_out    (crc_out),
554
              .clk        (tck_i),
555
              .crc_match  ()
556
             );
557
 
558
// Following status is shifted out: 
559
// 1. bit:          0 if crc is OK, else 1
560
// 2. bit:          0 if existing module_id is selected, 1 if non-existing module_id is selected
561
// 3. bit:          0 (always) 
562
// 4. bit:          0 (always)
563
 
564
 
565
always @ (status_cnt or crc_match or module_select_error or crc_out)
566
begin
567
  case (status_cnt)                   /* synthesis full_case parallel_case */
568
    `DBG_TOP_STATUS_CNT_WIDTH'd0  : begin
569
                        tdo_module_select = ~crc_match;
570
                      end
571
    `DBG_TOP_STATUS_CNT_WIDTH'd1  : begin
572
                        tdo_module_select = module_select_error;
573
                      end
574
    `DBG_TOP_STATUS_CNT_WIDTH'd2  : begin
575
                        tdo_module_select = 1'b0;
576
                      end
577
    `DBG_TOP_STATUS_CNT_WIDTH'd3  : begin
578
                        tdo_module_select = 1'b0;
579
                      end
580
    `DBG_TOP_STATUS_CNT_WIDTH'd4  : begin
581
                        tdo_module_select = crc_out;
582
                      end
583
  endcase
584
end
585
 
586
 
587
 
588
 
589
assign shift_crc = shift_crc_wb | cpu1_shift_crc | cpu0_shift_crc;
590
 
591
always @ (shift_crc or crc_out or tdo_module_select
592
`ifdef DBG_WISHBONE_SUPPORTED
593
 or wishbone_ce or tdo_wb
594
`endif
595
`ifdef DBG_CPU0_SUPPORTED
596
 or cpu0_ce or cpu0_tdo
597
`endif
598
`ifdef DBG_CPU1_SUPPORTED
599
 or cpu1_ce or cpu1_tdo
600
`endif
601
         )
602
begin
603
  if (shift_crc)          // shifting crc
604
    tdo_tmp = crc_out;
605
  `ifdef DBG_WISHBONE_SUPPORTED
606
  else if (wishbone_ce)   //  shifting data from wb
607
    tdo_tmp = tdo_wb;
608
  `endif
609
  `ifdef DBG_CPU0_SUPPORTED
610
  else if (cpu0_ce)        // shifting data from cpu
611
    tdo_tmp = cpu0_tdo;
612
  `endif
613
  `ifdef DBG_CPU1_SUPPORTED
614
  else if (cpu1_ce)        // shifting data from cpu
615
    tdo_tmp = cpu1_tdo;
616
  `endif
617
  else
618
    tdo_tmp = tdo_module_select;
619
end
620
 
621
 
622
always @ (negedge tck_i)
623
begin
624
  tdo_o <= #1 tdo_tmp;
625
end
626
 
627
 
628
 
629
 
630
// Signals for WISHBONE module
631
 
632
 
633
always @ (posedge tck_i or posedge rst_i)
634
begin
635
  if (rst_i)
636
    begin
637
      `ifdef DBG_WISHBONE_SUPPORTED
638
      wishbone_ce <= #1 1'b0;
639
      `endif
640
      `ifdef DBG_CPU0_SUPPORTED
641
      cpu0_ce <= #1 1'b0;
642
      `endif
643
      `ifdef DBG_CPU1_SUPPORTED
644
      cpu1_ce <= #1 1'b0;
645
      `endif
646
    end
647
  else if(selecting_command & (~tdi_i))
648
    begin
649
      `ifdef DBG_WISHBONE_SUPPORTED
650
      if (wishbone_module)      // wishbone CE
651
        wishbone_ce <= #1 1'b1;
652
      `endif
653
      `ifdef DBG_CPU0_SUPPORTED
654
      if (cpu0_debug_module)     // CPU CE
655
        cpu0_ce <= #1 1'b1;
656
      `endif
657
      `ifdef DBG_CPU1_SUPPORTED
658
      if (cpu1_debug_module)     // CPU CE
659
        cpu1_ce <= #1 1'b1;
660
      `endif
661
    end
662
  else if (update_dr_i)
663
    begin
664
      `ifdef DBG_WISHBONE_SUPPORTED
665
      wishbone_ce <= #1 1'b0;
666
      `endif
667
      `ifdef DBG_CPU0_SUPPORTED
668
      cpu0_ce <= #1 1'b0;
669
      `endif
670
      `ifdef DBG_CPU1_SUPPORTED
671
      cpu1_ce <= #1 1'b0;
672
      `endif
673
    end
674
end
675
 
676
 
677
`ifdef DBG_WISHBONE_SUPPORTED
678
assign tdi_wb  = wishbone_ce & tdi_i;
679
`endif
680
 
681
`ifdef DBG_CPU0_SUPPORTED
682
assign cpu0_tdi = cpu0_ce & tdi_i;
683
`endif
684
`ifdef DBG_CPU1_SUPPORTED
685
assign cpu1_tdi = cpu1_ce & tdi_i;
686
`endif
687
 
688
 
689
`ifdef DBG_WISHBONE_SUPPORTED
690
// Connecting wishbone module
691
dbg_wb i_dbg_wb (
692
                  // JTAG signals
693
                  .tck_i            (tck_i),
694
                  .tdi_i            (tdi_wb),
695
                  .tdo_o            (tdo_wb),
696
 
697
                  // TAP states
698
                  .shift_dr_i       (shift_dr_i),
699
                  .pause_dr_i       (pause_dr_i),
700
                  .update_dr_i      (update_dr_i),
701
 
702
                  .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
                  .rst_i            (rst_i),
707
 
708
                  // WISHBONE common signals
709
                  .wb_clk_i         (wb_clk_i),
710
 
711
                  // WISHBONE master interface
712
                  .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
            );
725
`endif
726
 
727
 
728
 
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
// Connecting cpu module
766
dbg_cpu i_dbg_cpu_8051 (
767
                  // JTAG signals
768
                  .tck_i            (tck_i),
769
                  .tdi_i            (cpu1_tdi),
770
                  .tdo_o            (cpu1_tdo),
771
 
772
                  // TAP states
773
                  .shift_dr_i       (shift_dr_i),
774
                  .pause_dr_i       (pause_dr_i),
775
                  .update_dr_i      (update_dr_i),
776
 
777
                  .cpu_ce_i         (cpu1_ce),
778
                  .crc_match_i      (crc_match),
779
                  .crc_en_o         (cpu1_crc_en),
780
                  .shift_crc_o      (cpu1_shift_crc),
781
                  .rst_i            (rst_i),
782
 
783
                  // CPU signals
784
                  .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
              );
795
`endif
796
 
797
 
798
endmodule

powered by: WebSVN 2.1.0

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