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

Subversion Repositories socgen

[/] [socgen/] [trunk/] [Projects/] [opencores.org/] [adv_debug_sys/] [Hardware/] [adv_dbg_if/] [rtl/] [verilog/] [adbg_top.v] - Blame information for rev 131

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 131 jt_eaton
//////////////////////////////////////////////////////////////////////
2
////                                                              ////
3
////  adbg_top.v                                                  ////
4
////                                                              ////
5
////                                                              ////
6
////  This file is part of the SoC Advanced Debug Interface.      ////
7
////                                                              ////
8
////  Author(s):                                                  ////
9
////       Nathan Yawn (nathan.yawn@opencores.org)                ////
10
////                                                              ////
11
////                                                              ////
12
////                                                              ////
13
//////////////////////////////////////////////////////////////////////
14
////                                                              ////
15
//// Copyright (C) 2008-2010 Authors                              ////
16
////                                                              ////
17
//// This source file may be used and distributed without         ////
18
//// restriction provided that this copyright statement is not    ////
19
//// removed from the file and that any derivative work contains  ////
20
//// the original copyright notice and the associated disclaimer. ////
21
////                                                              ////
22
//// This source file is free software; you can redistribute it   ////
23
//// and/or modify it under the terms of the GNU Lesser General   ////
24
//// Public License as published by the Free Software Foundation; ////
25
//// either version 2.1 of the License, or (at your option) any   ////
26
//// later version.                                               ////
27
////                                                              ////
28
//// This source is distributed in the hope that it will be       ////
29
//// useful, but WITHOUT ANY WARRANTY; without even the implied   ////
30
//// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR      ////
31
//// PURPOSE.  See the GNU Lesser General Public License for more ////
32
//// details.                                                     ////
33
////                                                              ////
34
//// You should have received a copy of the GNU Lesser General    ////
35
//// Public License along with this source; if not, download it   ////
36
//// from http://www.opencores.org/lgpl.shtml                     ////
37
////                                                              ////
38
//////////////////////////////////////////////////////////////////////
39
 
40
 
41
 
42
 
43
 
44
// Top module
45
module `VARIANT (
46
                // JTAG signals
47
                tck_i,
48
                tdi_i,
49
                tdo_o,
50
                rst_i,
51
 
52
 
53
                // TAP states
54
                shift_dr_i,
55
                update_dr_i,
56
                capture_dr_i,
57
 
58
                // Instructions
59
                debug_select_i
60
 
61
 
62
                `ifdef DBG_WISHBONE_SUPPORTED
63
                // WISHBONE common signals
64
                ,
65
                wb_clk_i,
66
                wb_rst_i,
67
 
68
                // WISHBONE master interface
69
                wb_adr_o,
70
                wb_dat_o,
71
                wb_dat_i,
72
                wb_cyc_o,
73
                wb_stb_o,
74
                wb_sel_o,
75
                wb_we_o,
76
                wb_ack_i,
77
                wb_cab_o,
78
                wb_err_i,
79
                wb_cti_o,
80
                wb_bte_o
81
                `endif
82
 
83
                `ifdef DBG_CPU0_SUPPORTED
84
                // CPU signals
85
                ,
86
                cpu0_clk_i,
87
                cpu0_addr_o,
88
                cpu0_data_i,
89
                cpu0_data_o,
90
                cpu0_bp_i,
91
                cpu0_stall_o,
92
                cpu0_stb_o,
93
                cpu0_we_o,
94
                cpu0_ack_i,
95
                cpu0_rst_o
96
                `endif
97
 
98
                `ifdef DBG_CPU1_SUPPORTED
99
                // CPU signals
100
                ,
101
                cpu1_clk_i,
102
                cpu1_addr_o,
103
                cpu1_data_i,
104
                cpu1_data_o,
105
                cpu1_bp_i,
106
                cpu1_stall_o,
107
                cpu1_stb_o,
108
                cpu1_we_o,
109
                cpu1_ack_i,
110
                cpu1_rst_o
111
                `endif
112
 
113
                `ifdef DBG_JSP_SUPPORTED
114
                ,
115
                `ifndef DBG_WISHBONE_SUPPORTED
116
                wb_clk_i,
117
                wb_rst_i,
118
                `endif
119
 
120
                // WISHBONE target interface
121
                wb_jsp_adr_i,
122
                wb_jsp_dat_o,
123
                wb_jsp_dat_i,
124
                wb_jsp_cyc_i,
125
                wb_jsp_stb_i,
126
                wb_jsp_sel_i,
127
                wb_jsp_we_i,
128
                wb_jsp_ack_o,
129
                wb_jsp_cab_i,
130
                wb_jsp_err_o,
131
                wb_jsp_cti_i,
132
                wb_jsp_bte_i,
133
                int_o,
134
                biu_wr_strobe,
135
                jsp_data_out
136
                `endif
137
 
138
                );
139
 
140
 
141
   // JTAG signals
142
   input   tck_i;
143
   input   tdi_i;
144
   output  tdo_o;
145
   input   rst_i;
146
 
147
   // TAP states
148
   input   shift_dr_i;
149
   input   update_dr_i;
150
   input   capture_dr_i;
151
 
152
   // Module select from TAP
153
   input   debug_select_i;
154
 
155
`ifdef DBG_WISHBONE_SUPPORTED
156
   input   wb_clk_i;
157
   input   wb_rst_i;
158
   output [31:0] wb_adr_o;
159
   output [31:0] wb_dat_o;
160
   input [31:0]  wb_dat_i;
161
   output        wb_cyc_o;
162
   output        wb_stb_o;
163
   output [3:0]  wb_sel_o;
164
   output        wb_we_o;
165
   input         wb_ack_i;
166
   output        wb_cab_o;
167
   input         wb_err_i;
168
   output [2:0]  wb_cti_o;
169
   output [1:0]  wb_bte_o;
170
`endif
171
 
172
`ifdef DBG_CPU0_SUPPORTED
173
   // CPU signals
174
   input         cpu0_clk_i;
175
   output [31:0] cpu0_addr_o;
176
   input [31:0]  cpu0_data_i;
177
   output [31:0] cpu0_data_o;
178
   input         cpu0_bp_i;
179
   output        cpu0_stall_o;
180
   output        cpu0_stb_o;
181
   output        cpu0_we_o;
182
   input         cpu0_ack_i;
183
   output        cpu0_rst_o;
184
`endif
185
 
186
`ifdef DBG_CPU1_SUPPORTED
187
   input         cpu1_clk_i;
188
   output [31:0] cpu1_addr_o;
189
   input [31:0]  cpu1_data_i;
190
   output [31:0] cpu1_data_o;
191
   input         cpu1_bp_i;
192
   output        cpu1_stall_o;
193
   output        cpu1_stb_o;
194
   output        cpu1_we_o;
195
   input         cpu1_ack_i;
196
   output        cpu1_rst_o;
197
`endif
198
 
199
`ifdef DBG_JSP_SUPPORTED
200
   `ifndef DBG_WISHBONE_SUPPORTED
201
   input   wb_clk_i;
202
   input   wb_rst_i;
203
   `endif
204
   input [31:0]  wb_jsp_adr_i;
205
   output [31:0] wb_jsp_dat_o;
206
   input [31:0]  wb_jsp_dat_i;
207
   input         wb_jsp_cyc_i;
208
   input         wb_jsp_stb_i;
209
   input [3:0]   wb_jsp_sel_i;
210
   input         wb_jsp_we_i;
211
   output        wb_jsp_ack_o;
212
   input         wb_jsp_cab_i;
213
   output        wb_jsp_err_o;
214
   input [2:0]   wb_jsp_cti_i;
215
   input [1:0]   wb_jsp_bte_i;
216
   output        int_o;
217
   output        biu_wr_strobe;
218
   output [7:0]   jsp_data_out;
219
`endif
220
 
221
   reg           tdo_o;
222
   wire          tdo_wb;
223
   wire          tdo_cpu0;
224
   wire          tdo_cpu1;
225
   wire          tdo_jsp;
226
 
227
   // Registers
228
   reg [`DBG_TOP_MODULE_DATA_LEN-1:0] input_shift_reg;  // 1 bit sel/cmd, 4 bit opcode, 32 bit address, 16 bit length = 53 bits
229
   //reg output_shift_reg;  // Just 1 bit for status (valid module selected)
230
   reg [`DBG_TOP_MODULE_ID_LENGTH -1:0] module_id_reg;   // Module selection register
231
 
232
 
233
   // Control signals
234
   wire                                 select_cmd;  // True when the command (registered at Update_DR) is for top level/module selection
235
   wire [(`DBG_TOP_MODULE_ID_LENGTH - 1) : 0] module_id_in;    // The part of the input_shift_register to be used as the module select data
236
   reg [(`DBG_TOP_MAX_MODULES - 1) : 0]       module_selects;  // Select signals for the individual modules
237
   wire                                       select_inhibit;  // OR of inhibit signals from sub-modules, prevents latching of a new module ID
238
   wire [3:0]                                  module_inhibit;  // signals to allow submodules to prevent top level from latching new module ID
239
 
240
   ///////////////////////////////////////
241
   // Combinatorial assignments
242
 
243
assign select_cmd = input_shift_reg[52];
244
assign module_id_in = input_shift_reg[51:50];
245
 
246
//////////////////////////////////////////////////////////
247
// Module select register and select signals
248
 
249
always @ (posedge tck_i or posedge rst_i)
250
begin
251
  if (rst_i)
252
    module_id_reg <= 2'b0;
253
  else if(debug_select_i && select_cmd && update_dr_i && !select_inhibit)       // Chain select
254
    module_id_reg <= module_id_in;
255
end
256
 
257
 
258
always @ (module_id_reg)
259
begin
260
        module_selects                 = `DBG_TOP_MAX_MODULES'h0;
261
        module_selects[module_id_reg]  = 1'b1;
262
end
263
 
264
///////////////////////////////////////////////
265
// Data input shift register
266
 
267
always @ (posedge tck_i or posedge rst_i)
268
begin
269
  if (rst_i)
270
    input_shift_reg <= 53'h0;
271
  else if(debug_select_i && shift_dr_i)
272
    input_shift_reg <= {tdi_i, input_shift_reg[52:1]};
273
end
274
 
275
 
276
//////////////////////////////////////////////
277
// Debug module instantiations
278
 
279
`ifdef DBG_WISHBONE_SUPPORTED
280
// Connecting wishbone module
281
`VARIANT`WB_MODULE i_dbg_wb (
282
                  // JTAG signals
283
                  .tck_i            (tck_i),
284
                  .module_tdo_o     (tdo_wb),
285
                  .tdi_i            (tdi_i),
286
 
287
                  // TAP states
288
                  .capture_dr_i     (capture_dr_i),
289
                  .shift_dr_i       (shift_dr_i),
290
                  .update_dr_i      (update_dr_i),
291
 
292
                  .data_register_i  (input_shift_reg),
293
                  .module_select_i  (module_selects[`DBG_TOP_WISHBONE_DEBUG_MODULE]),
294
                  .top_inhibit_o     (module_inhibit[`DBG_TOP_WISHBONE_DEBUG_MODULE]),
295
                  .rst_i            (rst_i),
296
 
297
                  // WISHBONE common signals
298
                  .wb_clk_i         (wb_clk_i),
299
 
300
                  // WISHBONE master interface
301
                  .wb_adr_o         (wb_adr_o),
302
                  .wb_dat_o         (wb_dat_o),
303
                  .wb_dat_i         (wb_dat_i),
304
                  .wb_cyc_o         (wb_cyc_o),
305
                  .wb_stb_o         (wb_stb_o),
306
                  .wb_sel_o         (wb_sel_o),
307
                  .wb_we_o          (wb_we_o),
308
                  .wb_ack_i         (wb_ack_i),
309
                  .wb_cab_o         (wb_cab_o),
310
                  .wb_err_i         (wb_err_i),
311
                  .wb_cti_o         (wb_cti_o),
312
                  .wb_bte_o         (wb_bte_o)
313
            );
314
`else
315
assign tdo_wb = 1'b0;
316
assign module_inhibit[`DBG_TOP_WISHBONE_DEBUG_MODULE] = 1'b0;
317
`endif
318
 
319
 
320
 
321
`ifdef DBG_CPU0_SUPPORTED
322
`VARIANT`OR1K_MODULE i_dbg_cpu_or1k (
323
                  // JTAG signals
324
                  .tck_i            (tck_i),
325
                  .module_tdo_o     (tdo_cpu0),
326
                  .tdi_i            (tdi_i),
327
 
328
                  // TAP states
329
                  .capture_dr_i     (capture_dr_i),
330
                  .shift_dr_i       (shift_dr_i),
331
                  .update_dr_i      (update_dr_i),
332
 
333
                  .data_register_i  (input_shift_reg),
334
                  .module_select_i  (module_selects[`DBG_TOP_CPU0_DEBUG_MODULE]),
335
                  .top_inhibit_o     (module_inhibit[`DBG_TOP_CPU0_DEBUG_MODULE]),
336
                  .rst_i            (rst_i),
337
 
338
                  // CPU signals
339
                  .cpu_clk_i        (cpu0_clk_i),
340
                  .cpu_addr_o       (cpu0_addr_o),
341
                  .cpu_data_i       (cpu0_data_i),
342
                  .cpu_data_o       (cpu0_data_o),
343
                  .cpu_bp_i         (cpu0_bp_i),
344
                  .cpu_stall_o      (cpu0_stall_o),
345
                  .cpu_stb_o        (cpu0_stb_o),
346
                  .cpu_we_o         (cpu0_we_o),
347
                  .cpu_ack_i        (cpu0_ack_i),
348
                  .cpu_rst_o        (cpu0_rst_o)
349
              );
350
`else
351
assign tdo_cpu0 = 1'b0;
352
assign module_inhibit[`DBG_TOP_CPU0_DEBUG_MODULE] = 1'b0;
353
`endif  //  DBG_CPU0_SUPPORTED
354
 
355
 
356
 
357
`ifdef DBG_CPU1_SUPPORTED
358
// Connecting cpu module
359
`VARIANT`OR1K_MODULE  i_dbg_cpu_2 (
360
                  // JTAG signals
361
                  .tck_i            (tck_i),
362
                  .module_tdo_o     (tdo_cpu1),
363
                  .tdi_i            (tdi_i),
364
 
365
                  // TAP states
366
                  .capture_dr_i     (capture_dr_i),
367
                  .shift_dr_i       (shift_dr_i),
368
                  .update_dr_i      (update_dr_i),
369
 
370
                  .data_register_i  (input_shift_reg),
371
                  .module_select_i  (module_selects[`DBG_TOP_CPU1_DEBUG_MODULE]),
372
                  .top_inhibit_o    (module_inhibit[`DBG_TOP_CPU1_DEBUG_MODULE]),
373
                  .rst_i            (rst_i),
374
 
375
                  // CPU signals
376
                  .cpu_clk_i        (cpu1_clk_i),
377
                  .cpu_addr_o       (cpu1_addr_o),
378
                  .cpu_data_i       (cpu1_data_i),
379
                  .cpu_data_o       (cpu1_data_o),
380
                  .cpu_bp_i         (cpu1_bp_i),
381
                  .cpu_stall_o      (cpu1_stall_o),
382
                  .cpu_stb_o        (cpu1_stb_o),
383
                  .cpu_we_o         (cpu1_we_o),
384
                  .cpu_ack_i        (cpu1_ack_i),
385
                  .cpu_rst_o        (cpu1_rst_o)
386
              );
387
`else
388
assign tdo_cpu1 = 1'b0;
389
assign module_inhibit[`DBG_TOP_CPU1_DEBUG_MODULE] = 1'b0;
390
`endif
391
 
392
`ifdef DBG_JSP_SUPPORTED
393
`VARIANT`JSP_MODULE i_dbg_jsp (
394
                  // JTAG signals
395
                  .tck_i            (tck_i),
396
                  .module_tdo_o     (tdo_jsp),
397
                  .tdi_i            (tdi_i),
398
 
399
                  // TAP states
400
                  .capture_dr_i     (capture_dr_i),
401
                  .shift_dr_i       (shift_dr_i),
402
                  .update_dr_i      (update_dr_i),
403
 
404
                  .data_register_i  (input_shift_reg),
405
                  .module_select_i  (module_selects[`DBG_TOP_JSP_DEBUG_MODULE]),
406
                  .top_inhibit_o     (module_inhibit[`DBG_TOP_JSP_DEBUG_MODULE]),
407
                  .rst_i            (rst_i),
408
 
409
                  // WISHBONE common signals
410
                  .wb_clk_i         (wb_clk_i),
411
                  .wb_rst_i         (wb_rst_i),
412
 
413
                  // WISHBONE master interface
414
                  .wb_adr_i         (wb_jsp_adr_i),
415
                  .wb_dat_o         (wb_jsp_dat_o),
416
                  .wb_dat_i         (wb_jsp_dat_i),
417
                  .wb_cyc_i         (wb_jsp_cyc_i),
418
                  .wb_stb_i         (wb_jsp_stb_i),
419
                  .wb_sel_i         (wb_jsp_sel_i),
420
                  .wb_we_i          (wb_jsp_we_i),
421
                  .wb_ack_o         (wb_jsp_ack_o),
422
                  .wb_cab_i         (wb_jsp_cab_i),
423
                  .wb_err_o         (wb_jsp_err_o),
424
                  .wb_cti_i         (wb_jsp_cti_i),
425
                  .wb_bte_i         (wb_jsp_bte_i),
426
                  .biu_wr_strobe    (biu_wr_strobe),
427
                  .jsp_data_out     (jsp_data_out),
428
                  .int_o            (int_o)
429
            );
430
 
431
`else
432
   assign tdo_jsp = 1'b0;
433
   assign module_inhibit[`DBG_TOP_JSP_DEBUG_MODULE] = 1'b0;
434
`endif
435
 
436
assign select_inhibit = |module_inhibit;
437
 
438
/////////////////////////////////////////////////
439
// TDO output MUX
440
 
441
always @ (module_id_reg or tdo_wb or tdo_cpu0 or tdo_cpu1 or tdo_jsp)
442
begin
443
   case (module_id_reg)
444
     `DBG_TOP_WISHBONE_DEBUG_MODULE: tdo_o = tdo_wb;
445
     `DBG_TOP_CPU0_DEBUG_MODULE:     tdo_o = tdo_cpu0;
446
     `DBG_TOP_CPU1_DEBUG_MODULE:     tdo_o = tdo_cpu1;
447
     `DBG_TOP_JSP_DEBUG_MODULE:      tdo_o = tdo_jsp;
448
       default:                        tdo_o = 1'b0;
449
   endcase
450
end
451
 
452
 
453
endmodule

powered by: WebSVN 2.1.0

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