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

Subversion Repositories adv_debug_sys

[/] [adv_debug_sys/] [tags/] [ADS_RELEASE_2_5_0/] [Hardware/] [adv_dbg_if/] [rtl/] [verilog/] [adbg_top.v] - Blame information for rev 8

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

Line No. Rev Author Line
1 3 nyawn
//////////////////////////////////////////////////////////////////////
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 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
// CVS Revision History
41
//
42
// $Log: adbg_top.v,v $
43
// Revision 1.2  2009/05/17 20:54:56  Nathan
44
// Changed email address to opencores.org
45
//
46
// Revision 1.1  2008/07/22 20:28:32  Nathan
47
// Changed names of all files and modules (prefixed an a, for advanced).  Cleanup, indenting.  No functional changes.
48
//
49
// Revision 1.10  2008/07/11 08:13:29  Nathan
50
// Latch opcode on posedge, like other signals.  This fixes a problem 
51
// when the module is used with a Xilinx BSCAN TAP.  Added signals to 
52
// allow modules to inhibit latching of a new active module by the top 
53
// module.  This allows the sub-modules to force the top level module 
54
// to ignore the command present in the input shift register after e.g. 
55
// a burst read.
56
//
57
// Revision 1.7  2008/06/30 20:09:20  Nathan
58
// Removed code to select top-level module as active (it served no 
59
// purpose).  Re-numbered modules, requiring changes to testbench and 
60
// software driver.
61
//
62
 
63
 
64
`include "adbg_defines.v"
65
 
66
 
67
// Top module
68
module adbg_top(
69
                // JTAG signals
70
                tck_i,
71
                tdi_i,
72
                tdo_o,
73
                rst_i,
74
 
75
 
76
                // TAP states
77
                shift_dr_i,
78
                pause_dr_i,
79
                update_dr_i,
80
                capture_dr_i,
81
 
82
                // Instructions
83
                debug_select_i
84
 
85
 
86
                `ifdef DBG_WISHBONE_SUPPORTED
87
                // WISHBONE common signals
88
                ,
89
                wb_clk_i,
90
 
91
                // WISHBONE master interface
92
                wb_adr_o,
93
                wb_dat_o,
94
                wb_dat_i,
95
                wb_cyc_o,
96
                wb_stb_o,
97
                wb_sel_o,
98
                wb_we_o,
99
                wb_ack_i,
100
                wb_cab_o,
101
                wb_err_i,
102
                wb_cti_o,
103
                wb_bte_o
104
                `endif
105
 
106
                `ifdef DBG_CPU0_SUPPORTED
107
                // CPU signals
108
                ,
109
                cpu0_clk_i,
110
                cpu0_addr_o,
111
                cpu0_data_i,
112
                cpu0_data_o,
113
                cpu0_bp_i,
114
                cpu0_stall_o,
115
                cpu0_stb_o,
116
                cpu0_we_o,
117
                cpu0_ack_i,
118
                cpu0_rst_o
119
                `endif
120
 
121
                `ifdef DBG_CPU1_SUPPORTED
122
                // CPU signals
123
                ,
124
                cpu1_clk_i,
125
                cpu1_addr_o,
126
                cpu1_data_i,
127
                cpu1_data_o,
128
                cpu1_bp_i,
129
                cpu1_stall_o,
130
                cpu1_stb_o,
131
                cpu1_we_o,
132
                cpu1_ack_i,
133
                cpu1_rst_o
134
                `endif
135
 
136
                );
137
 
138
 
139
   // JTAG signals
140
   input   tck_i;
141
   input   tdi_i;
142
   output  tdo_o;
143
   input   rst_i;
144
 
145
   // TAP states
146
   input   shift_dr_i;
147
   input   pause_dr_i;
148
   input   update_dr_i;
149
   input   capture_dr_i;
150
 
151
   // Module select from TAP
152
   input   debug_select_i;
153
 
154
                `ifdef DBG_WISHBONE_SUPPORTED
155
   input   wb_clk_i;
156
   output [31:0] wb_adr_o;
157
   output [31:0] wb_dat_o;
158
   input [31:0]  wb_dat_i;
159
   output        wb_cyc_o;
160
   output        wb_stb_o;
161
   output [3:0]  wb_sel_o;
162
   output        wb_we_o;
163
   input         wb_ack_i;
164
   output        wb_cab_o;
165
   input         wb_err_i;
166
   output [2:0]  wb_cti_o;
167
   output [1:0]  wb_bte_o;
168
                `endif
169
 
170
                `ifdef DBG_CPU0_SUPPORTED
171
   // CPU signals
172
   input         cpu0_clk_i;
173
   output [31:0] cpu0_addr_o;
174
   input [31:0]  cpu0_data_i;
175
   output [31:0] cpu0_data_o;
176
   input         cpu0_bp_i;
177
   output        cpu0_stall_o;
178
   output        cpu0_stb_o;
179
   output        cpu0_we_o;
180
   input         cpu0_ack_i;
181
   output        cpu0_rst_o;
182
                `endif
183
 
184
                `ifdef DBG_CPU1_SUPPORTED
185
   input         cpu1_clk_i;
186
   output [31:0] cpu1_addr_o;
187
   input [31:0]  cpu1_data_i;
188
   output [31:0] cpu1_data_o;
189
   input         cpu1_bp_i;
190
   output        cpu1_stall_o;
191
   output        cpu1_stb_o;
192
   output        cpu1_we_o;
193
   input         cpu1_ack_i;
194
   output        cpu1_rst_o;
195
                `endif
196
 
197
 
198
   reg           tdo_o;
199
   wire          tdo_wb;
200
   wire          tdo_cpu0;
201
   wire          tdo_cpu1;
202
 
203
 
204
   // Registers
205
   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
206
   //reg output_shift_reg;  // Just 1 bit for status (valid module selected)
207
   reg [`DBG_TOP_MODULE_ID_LENGTH -1:0] module_id_reg;   // Module selection register
208
 
209
 
210
   // Control signals
211
   wire                                 select_cmd;  // True when the command (registered at Update_DR) is for top level/module selection
212
   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
213
   reg [(`DBG_TOP_MAX_MODULES - 1) : 0]       module_selects;  // Select signals for the individual modules
214
   wire                                       select_inhibit;  // OR of inhibit signals from sub-modules, prevents latching of a new module ID
215
   wire [2:0]                                  module_inhibit;  // signals to allow submodules to prevent top level from latching new module ID
216
 
217
   ///////////////////////////////////////
218
   // Combinatorial assignments
219
 
220
assign select_cmd = input_shift_reg[52];
221
assign module_id_in = input_shift_reg[51:50];
222
 
223
//////////////////////////////////////////////////////////
224
// Module select register and select signals
225
 
226
always @ (posedge tck_i or posedge rst_i)
227
begin
228
  if (rst_i)
229
    module_id_reg <= 2'b0;
230
  else if(debug_select_i && select_cmd && update_dr_i && !select_inhibit)       // Chain select
231
    module_id_reg <= module_id_in;
232
end
233
 
234
 
235
always @ (module_id_reg)
236
begin
237
        module_selects <= `DBG_TOP_MODULE_ID_LENGTH'h0;
238
        module_selects[module_id_reg] <= 1'b1;
239
end
240
 
241
///////////////////////////////////////////////
242
// Data input shift register
243
 
244
always @ (posedge tck_i or posedge rst_i)
245
begin
246
  if (rst_i)
247
    input_shift_reg <= 53'h0;
248
  else if(debug_select_i && shift_dr_i)
249
    input_shift_reg <= {tdi_i, input_shift_reg[52:1]};
250
end
251
 
252
 
253
//////////////////////////////////////////////
254
// Debug module instantiations
255
 
256
`ifdef DBG_WISHBONE_SUPPORTED
257
// Connecting wishbone module
258
adbg_wb_module i_dbg_wb (
259
                  // JTAG signals
260
                  .tck_i            (tck_i),
261
                  .module_tdo_o     (tdo_wb),
262
                  .tdi_i            (tdi_i),
263
 
264
                  // TAP states
265
                  .capture_dr_i     (capture_dr_i),
266
                  .shift_dr_i       (shift_dr_i),
267
                  .update_dr_i      (update_dr_i),
268
 
269
                  .data_register_i  (input_shift_reg),
270
                  .module_select_i  (module_selects[`DBG_TOP_WISHBONE_DEBUG_MODULE]),
271
                  .top_inhibit_o     (module_inhibit[`DBG_TOP_WISHBONE_DEBUG_MODULE]),
272
                  .rst_i            (rst_i),
273
 
274
                  // WISHBONE common signals
275
                  .wb_clk_i         (wb_clk_i),
276
 
277
                  // WISHBONE master interface
278
                  .wb_adr_o         (wb_adr_o),
279
                  .wb_dat_o         (wb_dat_o),
280
                  .wb_dat_i         (wb_dat_i),
281
                  .wb_cyc_o         (wb_cyc_o),
282
                  .wb_stb_o         (wb_stb_o),
283
                  .wb_sel_o         (wb_sel_o),
284
                  .wb_we_o          (wb_we_o),
285
                  .wb_ack_i         (wb_ack_i),
286
                  .wb_cab_o         (wb_cab_o),
287
                  .wb_err_i         (wb_err_i),
288
                  .wb_cti_o         (wb_cti_o),
289
                  .wb_bte_o         (wb_bte_o)
290
            );
291
`else
292
assign tdo_wb = 1'b0;
293
assign module_inhibit[`DBG_TOP_WISHBONE_DEBUG_MODULE] = 1'b0;
294
`endif
295
 
296
 
297
 
298
`ifdef DBG_CPU0_SUPPORTED
299
adbg_or1k_module i_dbg_cpu_or1k (
300
                  // JTAG signals
301
                  .tck_i            (tck_i),
302
                  .module_tdo_o     (tdo_cpu0),
303
                  .tdi_i            (tdi_i),
304
 
305
                  // TAP states
306
                  .capture_dr_i     (capture_dr_i),
307
                  .shift_dr_i       (shift_dr_i),
308
                  .update_dr_i      (update_dr_i),
309
 
310
                  .data_register_i  (input_shift_reg),
311
                  .module_select_i  (module_selects[`DBG_TOP_CPU0_DEBUG_MODULE]),
312
                  .top_inhibit_o     (module_inhibit[`DBG_TOP_CPU0_DEBUG_MODULE]),
313
                  .rst_i            (rst_i),
314
 
315
                  // CPU signals
316
                  .cpu_clk_i        (cpu0_clk_i),
317
                  .cpu_addr_o       (cpu0_addr_o),
318
                  .cpu_data_i       (cpu0_data_i),
319
                  .cpu_data_o       (cpu0_data_o),
320
                  .cpu_bp_i         (cpu0_bp_i),
321
                  .cpu_stall_o      (cpu0_stall_o),
322
                  .cpu_stb_o        (cpu0_stb_o),
323
                  .cpu_we_o         (cpu0_we_o),
324
                  .cpu_ack_i        (cpu0_ack_i),
325
                  .cpu_rst_o        (cpu0_rst_o)
326
              );
327
`else
328
assign tdo_cpu0 = 1'b0;
329
assign module_inhibit[`DBG_TOP_CPU0_DEBUG_MODULE] = 1'b0;
330
`endif  //  DBG_CPU0_SUPPORTED
331
 
332
 
333
 
334
`ifdef DBG_CPU1_SUPPORTED
335
// Connecting cpu module
336
adbg_or1k_module i_dbg_cpu_8051 (
337
                  // JTAG signals
338
                  .tck_i            (tck_i),
339
                  .module_tdo_o     (tdo_cpu1),
340
                  .tdi_i            (tdi_i),
341
 
342
                  // TAP states
343
                  .capture_dr_i     (capture_dr_i),
344
                  .shift_dr_i       (shift_dr_i),
345
                  .update_dr_i      (update_dr_i),
346
 
347
                  .data_register_i  (input_shift_reg),
348
                  .module_select_i  (module_selects[`DBG_TOP_CPU1_DEBUG_MODULE]),
349
                  .top_inhibit_o    (module_inhibit[`DBG_TOP_CPU1_DEBUG_MODULE]),
350
                  .rst_i            (rst_i),
351
 
352
                  // CPU signals
353
                  .cpu_clk_i        (cpu1_clk_i),
354
                  .cpu_addr_o       (cpu1_addr_o),
355
                  .cpu_data_i       (cpu1_data_i),
356
                  .cpu_data_o       (cpu1_data_o),
357
                  .cpu_bp_i         (cpu1_bp_i),
358
                  .cpu_stall_o      (cpu1_stall_o),
359
                  .cpu_stb_o        (cpu1_stb_o),
360
                  .cpu_we_o         (cpu1_we_o),
361
                  .cpu_ack_i        (cpu1_ack_i),
362
                  .cpu_rst_o        (cpu1_rst_o)
363
              );
364
`else
365
assign tdo_cpu1 = 1'b0;
366
assign module_inhibit[`DBG_TOP_CPU1_DEBUG_MODULE] = 1'b0;
367
`endif
368
 
369
assign select_inhibit = |module_inhibit;
370
 
371
/////////////////////////////////////////////////
372
// TDO output MUX
373
 
374
always @ (module_id_reg or tdo_wb or tdo_cpu0 or tdo_cpu1)
375
begin
376
        case (module_id_reg)
377
                `DBG_TOP_WISHBONE_DEBUG_MODULE: tdo_o <= tdo_wb;
378
                `DBG_TOP_CPU0_DEBUG_MODULE:     tdo_o <= tdo_cpu0;
379
                `DBG_TOP_CPU1_DEBUG_MODULE:     tdo_o <= tdo_cpu1;
380
                default:                        tdo_o <= 1'b0;
381
        endcase
382
 
383
end
384
 
385
 
386
endmodule

powered by: WebSVN 2.1.0

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