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

Subversion Repositories dbg_interface

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

Details | Compare with Previous | View Log

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

powered by: WebSVN 2.1.0

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