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/] [adv_debug_sys/] [Hardware/] [adv_dbg_if/] [rtl/] [verilog/] [adbg_top.v] - Blame information for rev 21

Details | Compare with Previous | View Log

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

powered by: WebSVN 2.1.0

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