1 |
746 |
lampret |
//////////////////////////////////////////////////////////////////////
|
2 |
|
|
//// ////
|
3 |
|
|
//// dbg_top.v ////
|
4 |
|
|
//// ////
|
5 |
|
|
//// ////
|
6 |
|
|
//// This file is part of the SoC/OpenRISC Development Interface ////
|
7 |
|
|
//// http://www.opencores.org/cores/DebugInterface/ ////
|
8 |
|
|
//// ////
|
9 |
|
|
//// ////
|
10 |
|
|
//// Author(s): ////
|
11 |
|
|
//// Igor Mohor ////
|
12 |
|
|
//// igorm@opencores.org ////
|
13 |
|
|
//// ////
|
14 |
|
|
//// ////
|
15 |
|
|
//// All additional information is avaliable in the README.txt ////
|
16 |
|
|
//// file. ////
|
17 |
|
|
//// ////
|
18 |
|
|
//////////////////////////////////////////////////////////////////////
|
19 |
|
|
//// ////
|
20 |
|
|
//// Copyright (C) 2000,2001 Authors ////
|
21 |
|
|
//// ////
|
22 |
|
|
//// This source file may be used and distributed without ////
|
23 |
|
|
//// restriction provided that this copyright statement is not ////
|
24 |
|
|
//// removed from the file and that any derivative work contains ////
|
25 |
|
|
//// the original copyright notice and the associated disclaimer. ////
|
26 |
|
|
//// ////
|
27 |
|
|
//// This source file is free software; you can redistribute it ////
|
28 |
|
|
//// and/or modify it under the terms of the GNU Lesser General ////
|
29 |
|
|
//// Public License as published by the Free Software Foundation; ////
|
30 |
|
|
//// either version 2.1 of the License, or (at your option) any ////
|
31 |
|
|
//// later version. ////
|
32 |
|
|
//// ////
|
33 |
|
|
//// This source is distributed in the hope that it will be ////
|
34 |
|
|
//// useful, but WITHOUT ANY WARRANTY; without even the implied ////
|
35 |
|
|
//// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR ////
|
36 |
|
|
//// PURPOSE. See the GNU Lesser General Public License for more ////
|
37 |
|
|
//// details. ////
|
38 |
|
|
//// ////
|
39 |
|
|
//// You should have received a copy of the GNU Lesser General ////
|
40 |
|
|
//// Public License along with this source; if not, download it ////
|
41 |
|
|
//// from http://www.opencores.org/lgpl.shtml ////
|
42 |
|
|
//// ////
|
43 |
|
|
//////////////////////////////////////////////////////////////////////
|
44 |
|
|
//
|
45 |
|
|
// CVS Revision History
|
46 |
|
|
//
|
47 |
|
|
// $Log: not supported by cvs2svn $
|
48 |
|
|
// Revision 1.20 2002/02/06 12:23:09 mohor
|
49 |
|
|
// LatchedJTAG_IR used when muxing TDO instead of JTAG_IR.
|
50 |
|
|
//
|
51 |
|
|
// Revision 1.19 2002/02/05 13:34:51 mohor
|
52 |
|
|
// Stupid bug that was entered by previous update fixed.
|
53 |
|
|
//
|
54 |
|
|
// Revision 1.18 2002/02/05 12:41:01 mohor
|
55 |
|
|
// trst synchronization is not needed and was removed.
|
56 |
|
|
//
|
57 |
|
|
// Revision 1.17 2002/01/25 07:58:35 mohor
|
58 |
|
|
// IDCODE bug fixed, chains reused to decreas size of core. Data is shifted-in
|
59 |
|
|
// not filled-in. Tested in hw.
|
60 |
|
|
//
|
61 |
|
|
// Revision 1.16 2001/12/20 11:17:26 mohor
|
62 |
|
|
// TDO and TDO Enable signal are separated into two signals.
|
63 |
|
|
//
|
64 |
|
|
// Revision 1.15 2001/12/05 13:28:21 mohor
|
65 |
|
|
// trst signal is synchronized to wb_clk_i.
|
66 |
|
|
//
|
67 |
|
|
// Revision 1.14 2001/11/28 09:36:15 mohor
|
68 |
|
|
// Register length fixed.
|
69 |
|
|
//
|
70 |
|
|
// Revision 1.13 2001/11/27 13:37:43 mohor
|
71 |
|
|
// CRC is returned when chain selection data is transmitted.
|
72 |
|
|
//
|
73 |
|
|
// Revision 1.12 2001/11/26 10:47:09 mohor
|
74 |
|
|
// Crc generation is different for read or write commands. Small synthesys fixes.
|
75 |
|
|
//
|
76 |
|
|
// Revision 1.11 2001/11/14 10:10:41 mohor
|
77 |
|
|
// Wishbone data latched on wb_clk_i instead of risc_clk.
|
78 |
|
|
//
|
79 |
|
|
// Revision 1.10 2001/11/12 01:11:27 mohor
|
80 |
|
|
// Reset signals are not combined any more.
|
81 |
|
|
//
|
82 |
|
|
// Revision 1.9 2001/10/19 11:40:01 mohor
|
83 |
|
|
// dbg_timescale.v changed to timescale.v This is done for the simulation of
|
84 |
|
|
// few different cores in a single project.
|
85 |
|
|
//
|
86 |
|
|
// Revision 1.8 2001/10/17 10:39:03 mohor
|
87 |
|
|
// bs_chain_o added.
|
88 |
|
|
//
|
89 |
|
|
// Revision 1.7 2001/10/16 10:09:56 mohor
|
90 |
|
|
// Signal names changed to lowercase.
|
91 |
|
|
//
|
92 |
|
|
//
|
93 |
|
|
// Revision 1.6 2001/10/15 09:55:47 mohor
|
94 |
|
|
// Wishbone interface added, few fixes for better performance,
|
95 |
|
|
// hooks for boundary scan testing added.
|
96 |
|
|
//
|
97 |
|
|
// Revision 1.5 2001/09/24 14:06:42 mohor
|
98 |
|
|
// Changes connected to the OpenRISC access (SPR read, SPR write).
|
99 |
|
|
//
|
100 |
|
|
// Revision 1.4 2001/09/20 10:11:25 mohor
|
101 |
|
|
// Working version. Few bugs fixed, comments added.
|
102 |
|
|
//
|
103 |
|
|
// Revision 1.3 2001/09/19 11:55:13 mohor
|
104 |
|
|
// Asynchronous set/reset not used in trace any more.
|
105 |
|
|
//
|
106 |
|
|
// Revision 1.2 2001/09/18 14:13:47 mohor
|
107 |
|
|
// Trace fixed. Some registers changed, trace simplified.
|
108 |
|
|
//
|
109 |
|
|
// Revision 1.1.1.1 2001/09/13 13:49:19 mohor
|
110 |
|
|
// Initial official release.
|
111 |
|
|
//
|
112 |
|
|
// Revision 1.3 2001/06/01 22:22:35 mohor
|
113 |
|
|
// This is a backup. It is not a fully working version. Not for use, yet.
|
114 |
|
|
//
|
115 |
|
|
// Revision 1.2 2001/05/18 13:10:00 mohor
|
116 |
|
|
// Headers changed. All additional information is now avaliable in the README.txt file.
|
117 |
|
|
//
|
118 |
|
|
// Revision 1.1.1.1 2001/05/18 06:35:02 mohor
|
119 |
|
|
// Initial release
|
120 |
|
|
//
|
121 |
|
|
//
|
122 |
|
|
|
123 |
|
|
// synopsys translate_off
|
124 |
|
|
`include "timescale.v"
|
125 |
|
|
// synopsys translate_on
|
126 |
|
|
`include "dbg_defines.v"
|
127 |
|
|
|
128 |
|
|
// Top module
|
129 |
|
|
module dbg_top(
|
130 |
|
|
// JTAG pins
|
131 |
|
|
tms_pad_i, tck_pad_i, trst_pad_i, tdi_pad_i, tdo_pad_o, tdo_padoen_o,
|
132 |
|
|
|
133 |
|
|
// Boundary Scan signals
|
134 |
|
|
capture_dr_o, shift_dr_o, update_dr_o, extest_selected_o, bs_chain_i, bs_chain_o,
|
135 |
|
|
|
136 |
|
|
// RISC signals
|
137 |
|
|
risc_clk_i, risc_addr_o, risc_data_i, risc_data_o, wp_i,
|
138 |
|
|
bp_i, opselect_o, lsstatus_i, istatus_i, risc_stall_o, reset_o,
|
139 |
|
|
|
140 |
|
|
// WISHBONE common signals
|
141 |
|
|
wb_rst_i, wb_clk_i,
|
142 |
|
|
|
143 |
|
|
// WISHBONE master interface
|
144 |
|
|
wb_adr_o, wb_dat_o, wb_dat_i, wb_cyc_o, wb_stb_o, wb_sel_o,
|
145 |
|
|
wb_we_o, wb_ack_i, wb_cab_o, wb_err_i
|
146 |
|
|
|
147 |
|
|
|
148 |
|
|
);
|
149 |
|
|
|
150 |
|
|
parameter Tp = 1;
|
151 |
|
|
|
152 |
|
|
// JTAG pins
|
153 |
|
|
input tms_pad_i; // JTAG test mode select pad
|
154 |
|
|
input tck_pad_i; // JTAG test clock pad
|
155 |
|
|
input trst_pad_i; // JTAG test reset pad
|
156 |
|
|
input tdi_pad_i; // JTAG test data input pad
|
157 |
|
|
output tdo_pad_o; // JTAG test data output pad
|
158 |
|
|
output tdo_padoen_o; // Output enable for JTAG test data output pad
|
159 |
|
|
|
160 |
|
|
|
161 |
|
|
// Boundary Scan signals
|
162 |
|
|
output capture_dr_o;
|
163 |
|
|
output shift_dr_o;
|
164 |
|
|
output update_dr_o;
|
165 |
|
|
output extest_selected_o;
|
166 |
|
|
input bs_chain_i;
|
167 |
|
|
output bs_chain_o;
|
168 |
|
|
|
169 |
|
|
// RISC signals
|
170 |
|
|
input risc_clk_i; // Master clock (RISC clock)
|
171 |
|
|
input [31:0] risc_data_i; // RISC data inputs (data that is written to the RISC registers)
|
172 |
|
|
input [10:0] wp_i; // Watchpoint inputs
|
173 |
|
|
input bp_i; // Breakpoint input
|
174 |
|
|
input [3:0] lsstatus_i; // Load/store status inputs
|
175 |
|
|
input [1:0] istatus_i; // Instruction status inputs
|
176 |
|
|
output [31:0] risc_addr_o; // RISC address output (for adressing registers within RISC)
|
177 |
|
|
output [31:0] risc_data_o; // RISC data output (data read from risc registers)
|
178 |
|
|
output [`OPSELECTWIDTH-1:0] opselect_o; // Operation selection (selecting what kind of data is set to the risc_data_i)
|
179 |
|
|
output risc_stall_o; // Stalls the RISC
|
180 |
|
|
output reset_o; // Resets the RISC
|
181 |
|
|
|
182 |
|
|
|
183 |
|
|
// WISHBONE common signals
|
184 |
|
|
input wb_rst_i; // WISHBONE reset
|
185 |
|
|
input wb_clk_i; // WISHBONE clock
|
186 |
|
|
|
187 |
|
|
// WISHBONE master interface
|
188 |
|
|
output [31:0] wb_adr_o;
|
189 |
|
|
output [31:0] wb_dat_o;
|
190 |
|
|
input [31:0] wb_dat_i;
|
191 |
|
|
output wb_cyc_o;
|
192 |
|
|
output wb_stb_o;
|
193 |
|
|
output [3:0] wb_sel_o;
|
194 |
|
|
output wb_we_o;
|
195 |
|
|
input wb_ack_i;
|
196 |
|
|
output wb_cab_o;
|
197 |
|
|
input wb_err_i;
|
198 |
|
|
|
199 |
|
|
reg wb_cyc_o;
|
200 |
|
|
|
201 |
|
|
// TAP states
|
202 |
|
|
reg TestLogicReset;
|
203 |
|
|
reg RunTestIdle;
|
204 |
|
|
reg SelectDRScan;
|
205 |
|
|
reg CaptureDR;
|
206 |
|
|
reg ShiftDR;
|
207 |
|
|
reg Exit1DR;
|
208 |
|
|
reg PauseDR;
|
209 |
|
|
reg Exit2DR;
|
210 |
|
|
reg UpdateDR;
|
211 |
|
|
|
212 |
|
|
reg SelectIRScan;
|
213 |
|
|
reg CaptureIR;
|
214 |
|
|
reg ShiftIR;
|
215 |
|
|
reg Exit1IR;
|
216 |
|
|
reg PauseIR;
|
217 |
|
|
reg Exit2IR;
|
218 |
|
|
reg UpdateIR;
|
219 |
|
|
|
220 |
|
|
|
221 |
|
|
// Defining which instruction is selected
|
222 |
|
|
reg EXTESTSelected;
|
223 |
|
|
reg SAMPLE_PRELOADSelected;
|
224 |
|
|
reg IDCODESelected;
|
225 |
|
|
reg CHAIN_SELECTSelected;
|
226 |
|
|
reg INTESTSelected;
|
227 |
|
|
reg CLAMPSelected;
|
228 |
|
|
reg CLAMPZSelected;
|
229 |
|
|
reg HIGHZSelected;
|
230 |
|
|
reg DEBUGSelected;
|
231 |
|
|
reg BYPASSSelected;
|
232 |
|
|
|
233 |
|
|
reg [31:0] ADDR;
|
234 |
|
|
reg [31:0] DataOut;
|
235 |
|
|
|
236 |
|
|
reg [`OPSELECTWIDTH-1:0] opselect_o; // Operation selection (selecting what kind of data is set to the risc_data_i)
|
237 |
|
|
|
238 |
|
|
reg [`CHAIN_ID_LENGTH-1:0] Chain; // Selected chain
|
239 |
|
|
reg [31:0] DataReadLatch; // Data when reading register or RISC is latched one risc_clk_i clock after the data is read.
|
240 |
|
|
reg RegAccessTck; // Indicates access to the registers (read or write)
|
241 |
|
|
reg RISCAccessTck; // Indicates access to the RISC (read or write)
|
242 |
|
|
reg [7:0] BitCounter; // Counting bits in the ShiftDR and Exit1DR stages
|
243 |
|
|
reg RW; // Read/Write bit
|
244 |
|
|
reg CrcMatch; // The crc that is shifted in and the internaly calculated crc are equal
|
245 |
|
|
|
246 |
|
|
reg RegAccess_q; // Delayed signals used for accessing the registers
|
247 |
|
|
reg RegAccess_q2; // Delayed signals used for accessing the registers
|
248 |
|
|
reg RISCAccess_q; // Delayed signals used for accessing the RISC
|
249 |
|
|
reg RISCAccess_q2; // Delayed signals used for accessing the RISC
|
250 |
|
|
|
251 |
|
|
reg wb_AccessTck; // Indicates access to the WISHBONE
|
252 |
|
|
reg [31:0] WBReadLatch; // Data latched during WISHBONE read
|
253 |
|
|
reg WBErrorLatch; // Error latched during WISHBONE read
|
254 |
|
|
wire trst; // trst is active high while trst_pad_i is active low
|
255 |
|
|
|
256 |
|
|
reg BypassRegister; // Bypass register
|
257 |
|
|
|
258 |
|
|
|
259 |
|
|
wire TCK = tck_pad_i;
|
260 |
|
|
wire TMS = tms_pad_i;
|
261 |
|
|
wire TDI = tdi_pad_i;
|
262 |
|
|
|
263 |
|
|
wire [31:0] RegDataIn; // Data from registers (read data)
|
264 |
|
|
wire [`CRC_LENGTH-1:0] CalculatedCrcOut; // CRC calculated in this module. This CRC is apended at the end of the TDO.
|
265 |
|
|
|
266 |
|
|
wire RiscStall_reg; // RISC is stalled by setting the register bit
|
267 |
|
|
wire RiscReset_reg; // RISC is reset by setting the register bit
|
268 |
|
|
wire RiscStall_trace; // RISC is stalled by trace module
|
269 |
|
|
|
270 |
|
|
|
271 |
|
|
wire RegisterScanChain; // Register Scan chain selected
|
272 |
|
|
wire RiscDebugScanChain; // Risc Debug Scan chain selected
|
273 |
|
|
wire WishboneScanChain; // WISHBONE Scan chain selected
|
274 |
|
|
|
275 |
|
|
wire RiscStall_read_access; // Stalling RISC because of the read access (SPR read)
|
276 |
|
|
wire RiscStall_write_access; // Stalling RISC because of the write access (SPR write)
|
277 |
|
|
wire RiscStall_access; // Stalling RISC because of the read or write access
|
278 |
|
|
|
279 |
|
|
wire BitCounter_Lt4;
|
280 |
|
|
wire BitCounter_Eq5;
|
281 |
|
|
wire BitCounter_Eq32;
|
282 |
|
|
wire BitCounter_Lt38;
|
283 |
|
|
wire BitCounter_Lt65;
|
284 |
|
|
|
285 |
|
|
assign capture_dr_o = CaptureDR;
|
286 |
|
|
assign shift_dr_o = ShiftDR;
|
287 |
|
|
assign update_dr_o = UpdateDR;
|
288 |
|
|
assign extest_selected_o = EXTESTSelected;
|
289 |
|
|
wire BS_CHAIN_I = bs_chain_i;
|
290 |
|
|
assign bs_chain_o = tdi_pad_i;
|
291 |
|
|
|
292 |
|
|
|
293 |
|
|
// This signals are used only when TRACE is used in the design
|
294 |
|
|
`ifdef TRACE_ENABLED
|
295 |
|
|
wire [39:0] TraceChain; // Chain that comes from trace module
|
296 |
|
|
reg ReadBuffer_Tck; // Command for incrementing the trace read pointer (synchr with TCK)
|
297 |
|
|
wire ReadTraceBuffer; // Command for incrementing the trace read pointer (synchr with MClk)
|
298 |
|
|
reg ReadTraceBuffer_q; // Delayed command for incrementing the trace read pointer (synchr with MClk)
|
299 |
|
|
wire ReadTraceBufferPulse; // Pulse for reading the trace buffer (valid for only one Mclk command)
|
300 |
|
|
|
301 |
|
|
// Outputs from registers
|
302 |
|
|
wire ContinMode; // Trace working in continous mode
|
303 |
|
|
wire TraceEnable; // Trace enabled
|
304 |
|
|
|
305 |
|
|
wire [10:0] WpTrigger; // Watchpoint starts trigger
|
306 |
|
|
wire BpTrigger; // Breakpoint starts trigger
|
307 |
|
|
wire [3:0] LSSTrigger; // Load/store status starts trigger
|
308 |
|
|
wire [1:0] ITrigger; // Instruction status starts trigger
|
309 |
|
|
wire [1:0] TriggerOper; // Trigger operation
|
310 |
|
|
|
311 |
|
|
wire WpTriggerValid; // Watchpoint trigger is valid
|
312 |
|
|
wire BpTriggerValid; // Breakpoint trigger is valid
|
313 |
|
|
wire LSSTriggerValid; // Load/store status trigger is valid
|
314 |
|
|
wire ITriggerValid; // Instruction status trigger is valid
|
315 |
|
|
|
316 |
|
|
wire [10:0] WpQualif; // Watchpoint starts qualifier
|
317 |
|
|
wire BpQualif; // Breakpoint starts qualifier
|
318 |
|
|
wire [3:0] LSSQualif; // Load/store status starts qualifier
|
319 |
|
|
wire [1:0] IQualif; // Instruction status starts qualifier
|
320 |
|
|
wire [1:0] QualifOper; // Qualifier operation
|
321 |
|
|
|
322 |
|
|
wire WpQualifValid; // Watchpoint qualifier is valid
|
323 |
|
|
wire BpQualifValid; // Breakpoint qualifier is valid
|
324 |
|
|
wire LSSQualifValid; // Load/store status qualifier is valid
|
325 |
|
|
wire IQualifValid; // Instruction status qualifier is valid
|
326 |
|
|
|
327 |
|
|
wire [10:0] WpStop; // Watchpoint stops recording of the trace
|
328 |
|
|
wire BpStop; // Breakpoint stops recording of the trace
|
329 |
|
|
wire [3:0] LSSStop; // Load/store status stops recording of the trace
|
330 |
|
|
wire [1:0] IStop; // Instruction status stops recording of the trace
|
331 |
|
|
wire [1:0] StopOper; // Stop operation
|
332 |
|
|
|
333 |
|
|
wire WpStopValid; // Watchpoint stop is valid
|
334 |
|
|
wire BpStopValid; // Breakpoint stop is valid
|
335 |
|
|
wire LSSStopValid; // Load/store status stop is valid
|
336 |
|
|
wire IStopValid; // Instruction status stop is valid
|
337 |
|
|
|
338 |
|
|
wire RecordPC; // Recording program counter
|
339 |
|
|
wire RecordLSEA; // Recording load/store effective address
|
340 |
|
|
wire RecordLDATA; // Recording load data
|
341 |
|
|
wire RecordSDATA; // Recording store data
|
342 |
|
|
wire RecordReadSPR; // Recording read SPR
|
343 |
|
|
wire RecordWriteSPR; // Recording write SPR
|
344 |
|
|
wire RecordINSTR; // Recording instruction
|
345 |
|
|
|
346 |
|
|
// End: Outputs from registers
|
347 |
|
|
|
348 |
|
|
wire TraceTestScanChain; // Trace Test Scan chain selected
|
349 |
|
|
wire [47:0] Trace_Data; // Trace data
|
350 |
|
|
|
351 |
|
|
wire [`OPSELECTWIDTH-1:0]opselect_trace;// Operation selection (trace selecting what kind of
|
352 |
|
|
// data is set to the risc_data_i)
|
353 |
|
|
wire BitCounter_Lt40;
|
354 |
|
|
|
355 |
|
|
`endif
|
356 |
|
|
|
357 |
|
|
|
358 |
|
|
/**********************************************************************************
|
359 |
|
|
* *
|
360 |
|
|
* Synchronizing TRST to clock signal *
|
361 |
|
|
* *
|
362 |
|
|
**********************************************************************************/
|
363 |
|
|
assign trst = ~trst_pad_i; // trst_pad_i is active low
|
364 |
|
|
|
365 |
|
|
|
366 |
|
|
/**********************************************************************************
|
367 |
|
|
* *
|
368 |
|
|
* TAP State Machine: Fully JTAG compliant *
|
369 |
|
|
* *
|
370 |
|
|
**********************************************************************************/
|
371 |
|
|
|
372 |
|
|
// TestLogicReset state
|
373 |
|
|
always @ (posedge TCK or posedge trst)
|
374 |
|
|
begin
|
375 |
|
|
if(trst)
|
376 |
|
|
TestLogicReset<=#Tp 1;
|
377 |
|
|
else
|
378 |
|
|
begin
|
379 |
|
|
if(TMS & (TestLogicReset | SelectIRScan))
|
380 |
|
|
TestLogicReset<=#Tp 1;
|
381 |
|
|
else
|
382 |
|
|
TestLogicReset<=#Tp 0;
|
383 |
|
|
end
|
384 |
|
|
end
|
385 |
|
|
|
386 |
|
|
// RunTestIdle state
|
387 |
|
|
always @ (posedge TCK or posedge trst)
|
388 |
|
|
begin
|
389 |
|
|
if(trst)
|
390 |
|
|
RunTestIdle<=#Tp 0;
|
391 |
|
|
else
|
392 |
|
|
begin
|
393 |
|
|
if(~TMS & (TestLogicReset | RunTestIdle | UpdateDR | UpdateIR))
|
394 |
|
|
RunTestIdle<=#Tp 1;
|
395 |
|
|
else
|
396 |
|
|
RunTestIdle<=#Tp 0;
|
397 |
|
|
end
|
398 |
|
|
end
|
399 |
|
|
|
400 |
|
|
// SelectDRScan state
|
401 |
|
|
always @ (posedge TCK or posedge trst)
|
402 |
|
|
begin
|
403 |
|
|
if(trst)
|
404 |
|
|
SelectDRScan<=#Tp 0;
|
405 |
|
|
else
|
406 |
|
|
begin
|
407 |
|
|
if(TMS & (RunTestIdle | UpdateDR | UpdateIR))
|
408 |
|
|
SelectDRScan<=#Tp 1;
|
409 |
|
|
else
|
410 |
|
|
SelectDRScan<=#Tp 0;
|
411 |
|
|
end
|
412 |
|
|
end
|
413 |
|
|
|
414 |
|
|
// CaptureDR state
|
415 |
|
|
always @ (posedge TCK or posedge trst)
|
416 |
|
|
begin
|
417 |
|
|
if(trst)
|
418 |
|
|
CaptureDR<=#Tp 0;
|
419 |
|
|
else
|
420 |
|
|
begin
|
421 |
|
|
if(~TMS & SelectDRScan)
|
422 |
|
|
CaptureDR<=#Tp 1;
|
423 |
|
|
else
|
424 |
|
|
CaptureDR<=#Tp 0;
|
425 |
|
|
end
|
426 |
|
|
end
|
427 |
|
|
|
428 |
|
|
// ShiftDR state
|
429 |
|
|
always @ (posedge TCK or posedge trst)
|
430 |
|
|
begin
|
431 |
|
|
if(trst)
|
432 |
|
|
ShiftDR<=#Tp 0;
|
433 |
|
|
else
|
434 |
|
|
begin
|
435 |
|
|
if(~TMS & (CaptureDR | ShiftDR | Exit2DR))
|
436 |
|
|
ShiftDR<=#Tp 1;
|
437 |
|
|
else
|
438 |
|
|
ShiftDR<=#Tp 0;
|
439 |
|
|
end
|
440 |
|
|
end
|
441 |
|
|
|
442 |
|
|
// Exit1DR state
|
443 |
|
|
always @ (posedge TCK or posedge trst)
|
444 |
|
|
begin
|
445 |
|
|
if(trst)
|
446 |
|
|
Exit1DR<=#Tp 0;
|
447 |
|
|
else
|
448 |
|
|
begin
|
449 |
|
|
if(TMS & (CaptureDR | ShiftDR))
|
450 |
|
|
Exit1DR<=#Tp 1;
|
451 |
|
|
else
|
452 |
|
|
Exit1DR<=#Tp 0;
|
453 |
|
|
end
|
454 |
|
|
end
|
455 |
|
|
|
456 |
|
|
// PauseDR state
|
457 |
|
|
always @ (posedge TCK or posedge trst)
|
458 |
|
|
begin
|
459 |
|
|
if(trst)
|
460 |
|
|
PauseDR<=#Tp 0;
|
461 |
|
|
else
|
462 |
|
|
begin
|
463 |
|
|
if(~TMS & (Exit1DR | PauseDR))
|
464 |
|
|
PauseDR<=#Tp 1;
|
465 |
|
|
else
|
466 |
|
|
PauseDR<=#Tp 0;
|
467 |
|
|
end
|
468 |
|
|
end
|
469 |
|
|
|
470 |
|
|
// Exit2DR state
|
471 |
|
|
always @ (posedge TCK or posedge trst)
|
472 |
|
|
begin
|
473 |
|
|
if(trst)
|
474 |
|
|
Exit2DR<=#Tp 0;
|
475 |
|
|
else
|
476 |
|
|
begin
|
477 |
|
|
if(TMS & PauseDR)
|
478 |
|
|
Exit2DR<=#Tp 1;
|
479 |
|
|
else
|
480 |
|
|
Exit2DR<=#Tp 0;
|
481 |
|
|
end
|
482 |
|
|
end
|
483 |
|
|
|
484 |
|
|
// UpdateDR state
|
485 |
|
|
always @ (posedge TCK or posedge trst)
|
486 |
|
|
begin
|
487 |
|
|
if(trst)
|
488 |
|
|
UpdateDR<=#Tp 0;
|
489 |
|
|
else
|
490 |
|
|
begin
|
491 |
|
|
if(TMS & (Exit1DR | Exit2DR))
|
492 |
|
|
UpdateDR<=#Tp 1;
|
493 |
|
|
else
|
494 |
|
|
UpdateDR<=#Tp 0;
|
495 |
|
|
end
|
496 |
|
|
end
|
497 |
|
|
|
498 |
|
|
// Delayed UpdateDR state
|
499 |
|
|
reg UpdateDR_q;
|
500 |
|
|
always @ (posedge TCK)
|
501 |
|
|
begin
|
502 |
|
|
UpdateDR_q<=#Tp UpdateDR;
|
503 |
|
|
end
|
504 |
|
|
|
505 |
|
|
|
506 |
|
|
// SelectIRScan state
|
507 |
|
|
always @ (posedge TCK or posedge trst)
|
508 |
|
|
begin
|
509 |
|
|
if(trst)
|
510 |
|
|
SelectIRScan<=#Tp 0;
|
511 |
|
|
else
|
512 |
|
|
begin
|
513 |
|
|
if(TMS & SelectDRScan)
|
514 |
|
|
SelectIRScan<=#Tp 1;
|
515 |
|
|
else
|
516 |
|
|
SelectIRScan<=#Tp 0;
|
517 |
|
|
end
|
518 |
|
|
end
|
519 |
|
|
|
520 |
|
|
// CaptureIR state
|
521 |
|
|
always @ (posedge TCK or posedge trst)
|
522 |
|
|
begin
|
523 |
|
|
if(trst)
|
524 |
|
|
CaptureIR<=#Tp 0;
|
525 |
|
|
else
|
526 |
|
|
begin
|
527 |
|
|
if(~TMS & SelectIRScan)
|
528 |
|
|
CaptureIR<=#Tp 1;
|
529 |
|
|
else
|
530 |
|
|
CaptureIR<=#Tp 0;
|
531 |
|
|
end
|
532 |
|
|
end
|
533 |
|
|
|
534 |
|
|
// ShiftIR state
|
535 |
|
|
always @ (posedge TCK or posedge trst)
|
536 |
|
|
begin
|
537 |
|
|
if(trst)
|
538 |
|
|
ShiftIR<=#Tp 0;
|
539 |
|
|
else
|
540 |
|
|
begin
|
541 |
|
|
if(~TMS & (CaptureIR | ShiftIR | Exit2IR))
|
542 |
|
|
ShiftIR<=#Tp 1;
|
543 |
|
|
else
|
544 |
|
|
ShiftIR<=#Tp 0;
|
545 |
|
|
end
|
546 |
|
|
end
|
547 |
|
|
|
548 |
|
|
// Exit1IR state
|
549 |
|
|
always @ (posedge TCK or posedge trst)
|
550 |
|
|
begin
|
551 |
|
|
if(trst)
|
552 |
|
|
Exit1IR<=#Tp 0;
|
553 |
|
|
else
|
554 |
|
|
begin
|
555 |
|
|
if(TMS & (CaptureIR | ShiftIR))
|
556 |
|
|
Exit1IR<=#Tp 1;
|
557 |
|
|
else
|
558 |
|
|
Exit1IR<=#Tp 0;
|
559 |
|
|
end
|
560 |
|
|
end
|
561 |
|
|
|
562 |
|
|
// PauseIR state
|
563 |
|
|
always @ (posedge TCK or posedge trst)
|
564 |
|
|
begin
|
565 |
|
|
if(trst)
|
566 |
|
|
PauseIR<=#Tp 0;
|
567 |
|
|
else
|
568 |
|
|
begin
|
569 |
|
|
if(~TMS & (Exit1IR | PauseIR))
|
570 |
|
|
PauseIR<=#Tp 1;
|
571 |
|
|
else
|
572 |
|
|
PauseIR<=#Tp 0;
|
573 |
|
|
end
|
574 |
|
|
end
|
575 |
|
|
|
576 |
|
|
// Exit2IR state
|
577 |
|
|
always @ (posedge TCK or posedge trst)
|
578 |
|
|
begin
|
579 |
|
|
if(trst)
|
580 |
|
|
Exit2IR<=#Tp 0;
|
581 |
|
|
else
|
582 |
|
|
begin
|
583 |
|
|
if(TMS & PauseIR)
|
584 |
|
|
Exit2IR<=#Tp 1;
|
585 |
|
|
else
|
586 |
|
|
Exit2IR<=#Tp 0;
|
587 |
|
|
end
|
588 |
|
|
end
|
589 |
|
|
|
590 |
|
|
// UpdateIR state
|
591 |
|
|
always @ (posedge TCK or posedge trst)
|
592 |
|
|
begin
|
593 |
|
|
if(trst)
|
594 |
|
|
UpdateIR<=#Tp 0;
|
595 |
|
|
else
|
596 |
|
|
begin
|
597 |
|
|
if(TMS & (Exit1IR | Exit2IR))
|
598 |
|
|
UpdateIR<=#Tp 1;
|
599 |
|
|
else
|
600 |
|
|
UpdateIR<=#Tp 0;
|
601 |
|
|
end
|
602 |
|
|
end
|
603 |
|
|
|
604 |
|
|
/**********************************************************************************
|
605 |
|
|
* *
|
606 |
|
|
* End: TAP State Machine *
|
607 |
|
|
* *
|
608 |
|
|
**********************************************************************************/
|
609 |
|
|
|
610 |
|
|
|
611 |
|
|
|
612 |
|
|
/**********************************************************************************
|
613 |
|
|
* *
|
614 |
|
|
* JTAG_IR: JTAG Instruction Register *
|
615 |
|
|
* *
|
616 |
|
|
**********************************************************************************/
|
617 |
|
|
wire [1:0]Status = 2'b10; // Holds current chip status. Core should return this status. For now a constant is used.
|
618 |
|
|
|
619 |
|
|
reg [`IR_LENGTH-1:0]JTAG_IR; // Instruction register
|
620 |
|
|
reg [`IR_LENGTH-1:0]LatchedJTAG_IR;
|
621 |
|
|
|
622 |
|
|
reg TDOInstruction;
|
623 |
|
|
|
624 |
|
|
always @ (posedge TCK or posedge trst)
|
625 |
|
|
begin
|
626 |
|
|
if(trst)
|
627 |
|
|
JTAG_IR[`IR_LENGTH-1:0] <= #Tp 0;
|
628 |
|
|
else
|
629 |
|
|
begin
|
630 |
|
|
if(CaptureIR)
|
631 |
|
|
begin
|
632 |
|
|
JTAG_IR[1:0] <= #Tp 2'b01; // This value is fixed for easier fault detection
|
633 |
|
|
JTAG_IR[3:2] <= #Tp Status[1:0]; // Current status of chip
|
634 |
|
|
end
|
635 |
|
|
else
|
636 |
|
|
begin
|
637 |
|
|
if(ShiftIR)
|
638 |
|
|
begin
|
639 |
|
|
JTAG_IR[`IR_LENGTH-1:0] <= #Tp {TDI, JTAG_IR[`IR_LENGTH-1:1]};
|
640 |
|
|
end
|
641 |
|
|
end
|
642 |
|
|
end
|
643 |
|
|
end
|
644 |
|
|
|
645 |
|
|
|
646 |
|
|
//TDO is changing on the falling edge of TCK
|
647 |
|
|
always @ (negedge TCK)
|
648 |
|
|
begin
|
649 |
|
|
if(ShiftIR)
|
650 |
|
|
TDOInstruction <= #Tp JTAG_IR[0];
|
651 |
|
|
end
|
652 |
|
|
|
653 |
|
|
/**********************************************************************************
|
654 |
|
|
* *
|
655 |
|
|
* End: JTAG_IR *
|
656 |
|
|
* *
|
657 |
|
|
**********************************************************************************/
|
658 |
|
|
|
659 |
|
|
|
660 |
|
|
/**********************************************************************************
|
661 |
|
|
* *
|
662 |
|
|
* JTAG_DR: JTAG Data Register *
|
663 |
|
|
* *
|
664 |
|
|
**********************************************************************************/
|
665 |
|
|
reg [`DR_LENGTH-1:0]JTAG_DR_IN; // Data register
|
666 |
|
|
reg TDOData;
|
667 |
|
|
|
668 |
|
|
|
669 |
|
|
always @ (posedge TCK or posedge trst)
|
670 |
|
|
begin
|
671 |
|
|
if(trst)
|
672 |
|
|
JTAG_DR_IN[`DR_LENGTH-1:0]<=#Tp 0;
|
673 |
|
|
else
|
674 |
|
|
if(IDCODESelected) // To save space JTAG_DR_IN is also used for shifting out IDCODE
|
675 |
|
|
begin
|
676 |
|
|
if(ShiftDR)
|
677 |
|
|
JTAG_DR_IN[31:0] <= #Tp {TDI, JTAG_DR_IN[31:1]};
|
678 |
|
|
else
|
679 |
|
|
JTAG_DR_IN[31:0] <= #Tp `IDCODE_VALUE;
|
680 |
|
|
end
|
681 |
|
|
else
|
682 |
|
|
if(CHAIN_SELECTSelected & ShiftDR)
|
683 |
|
|
JTAG_DR_IN[12:0] <= #Tp {TDI, JTAG_DR_IN[12:1]};
|
684 |
|
|
else
|
685 |
|
|
if(DEBUGSelected & ShiftDR)
|
686 |
|
|
begin
|
687 |
|
|
if(RiscDebugScanChain | WishboneScanChain)
|
688 |
|
|
JTAG_DR_IN[73:0] <= #Tp {TDI, JTAG_DR_IN[73:1]};
|
689 |
|
|
else
|
690 |
|
|
if(RegisterScanChain)
|
691 |
|
|
JTAG_DR_IN[46:0] <= #Tp {TDI, JTAG_DR_IN[46:1]};
|
692 |
|
|
end
|
693 |
|
|
end
|
694 |
|
|
|
695 |
|
|
wire [73:0] RISC_Data;
|
696 |
|
|
wire [46:0] Register_Data;
|
697 |
|
|
wire [73:0] WISHBONE_Data;
|
698 |
|
|
wire [12:0] chain_sel_data;
|
699 |
|
|
wire wb_Access_wbClk;
|
700 |
|
|
|
701 |
|
|
|
702 |
|
|
reg select_crc_out;
|
703 |
|
|
always @ (posedge TCK or posedge trst)
|
704 |
|
|
begin
|
705 |
|
|
if(trst)
|
706 |
|
|
select_crc_out <= 0;
|
707 |
|
|
else
|
708 |
|
|
if( RegisterScanChain & BitCounter_Eq5 |
|
709 |
|
|
RiscDebugScanChain & BitCounter_Eq32 |
|
710 |
|
|
WishboneScanChain & BitCounter_Eq32 )
|
711 |
|
|
select_crc_out <=#Tp TDI;
|
712 |
|
|
else
|
713 |
|
|
if(CHAIN_SELECTSelected)
|
714 |
|
|
select_crc_out <=#Tp 1;
|
715 |
|
|
else
|
716 |
|
|
if(UpdateDR)
|
717 |
|
|
select_crc_out <=#Tp 0;
|
718 |
|
|
end
|
719 |
|
|
|
720 |
|
|
wire [8:0] send_crc;
|
721 |
|
|
|
722 |
|
|
assign send_crc = select_crc_out? {9{BypassRegister}} : // Calculated CRC is returned when read operation is
|
723 |
|
|
{CalculatedCrcOut, 1'b0} ; // performed, else received crc is returned (loopback).
|
724 |
|
|
|
725 |
|
|
assign RISC_Data = {send_crc, DataReadLatch, 33'h0};
|
726 |
|
|
assign Register_Data = {send_crc, DataReadLatch, 6'h0};
|
727 |
|
|
assign WISHBONE_Data = {send_crc, WBReadLatch, 32'h0, WBErrorLatch};
|
728 |
|
|
assign chain_sel_data = {send_crc, 4'h0};
|
729 |
|
|
|
730 |
|
|
|
731 |
|
|
`ifdef TRACE_ENABLED
|
732 |
|
|
assign Trace_Data = {CalculatedCrcOut, TraceChain};
|
733 |
|
|
`endif
|
734 |
|
|
|
735 |
|
|
//TDO is changing on the falling edge of TCK
|
736 |
|
|
always @ (negedge TCK or posedge trst)
|
737 |
|
|
begin
|
738 |
|
|
if(trst)
|
739 |
|
|
begin
|
740 |
|
|
TDOData <= #Tp 0;
|
741 |
|
|
`ifdef TRACE_ENABLED
|
742 |
|
|
ReadBuffer_Tck<=#Tp 0;
|
743 |
|
|
`endif
|
744 |
|
|
end
|
745 |
|
|
else
|
746 |
|
|
if(UpdateDR)
|
747 |
|
|
begin
|
748 |
|
|
TDOData <= #Tp CrcMatch;
|
749 |
|
|
`ifdef TRACE_ENABLED
|
750 |
|
|
if(DEBUGSelected & TraceTestScanChain & TraceChain[0]) // Sample in the trace buffer is valid
|
751 |
|
|
ReadBuffer_Tck<=#Tp 1; // Increment read pointer
|
752 |
|
|
`endif
|
753 |
|
|
end
|
754 |
|
|
else
|
755 |
|
|
begin
|
756 |
|
|
if(ShiftDR)
|
757 |
|
|
begin
|
758 |
|
|
if(IDCODESelected)
|
759 |
|
|
TDOData <= #Tp JTAG_DR_IN[0]; // IDCODE is shifted out 32-bits, then TDI is bypassed
|
760 |
|
|
else
|
761 |
|
|
if(CHAIN_SELECTSelected)
|
762 |
|
|
TDOData <= #Tp chain_sel_data[BitCounter]; // Received crc is sent back
|
763 |
|
|
else
|
764 |
|
|
if(DEBUGSelected)
|
765 |
|
|
begin
|
766 |
|
|
if(RiscDebugScanChain)
|
767 |
|
|
TDOData <= #Tp RISC_Data[BitCounter]; // Data read from RISC in the previous cycle is shifted out
|
768 |
|
|
else
|
769 |
|
|
if(RegisterScanChain)
|
770 |
|
|
TDOData <= #Tp Register_Data[BitCounter]; // Data read from register in the previous cycle is shifted out
|
771 |
|
|
else
|
772 |
|
|
if(WishboneScanChain)
|
773 |
|
|
TDOData <= #Tp WISHBONE_Data[BitCounter]; // Data read from the WISHBONE slave
|
774 |
|
|
`ifdef TRACE_ENABLED
|
775 |
|
|
else
|
776 |
|
|
if(TraceTestScanChain)
|
777 |
|
|
TDOData <= #Tp Trace_Data[BitCounter]; // Data from the trace buffer is shifted out
|
778 |
|
|
`endif
|
779 |
|
|
end
|
780 |
|
|
end
|
781 |
|
|
else
|
782 |
|
|
begin
|
783 |
|
|
TDOData <= #Tp 0;
|
784 |
|
|
`ifdef TRACE_ENABLED
|
785 |
|
|
ReadBuffer_Tck<=#Tp 0;
|
786 |
|
|
`endif
|
787 |
|
|
end
|
788 |
|
|
end
|
789 |
|
|
end
|
790 |
|
|
|
791 |
|
|
/**********************************************************************************
|
792 |
|
|
* *
|
793 |
|
|
* End: JTAG_DR *
|
794 |
|
|
* *
|
795 |
|
|
**********************************************************************************/
|
796 |
|
|
|
797 |
|
|
|
798 |
|
|
|
799 |
|
|
/**********************************************************************************
|
800 |
|
|
* *
|
801 |
|
|
* CHAIN_SELECT logic *
|
802 |
|
|
* *
|
803 |
|
|
**********************************************************************************/
|
804 |
|
|
always @ (posedge TCK or posedge trst)
|
805 |
|
|
begin
|
806 |
|
|
if(trst)
|
807 |
|
|
Chain[`CHAIN_ID_LENGTH-1:0]<=#Tp `GLOBAL_BS_CHAIN; // Global BS chain is selected after reset
|
808 |
|
|
else
|
809 |
|
|
if(UpdateDR & CHAIN_SELECTSelected & CrcMatch)
|
810 |
|
|
Chain[`CHAIN_ID_LENGTH-1:0]<=#Tp JTAG_DR_IN[3:0]; // New chain is selected
|
811 |
|
|
end
|
812 |
|
|
|
813 |
|
|
|
814 |
|
|
|
815 |
|
|
/**********************************************************************************
|
816 |
|
|
* *
|
817 |
|
|
* Register read/write logic *
|
818 |
|
|
* RISC registers read/write logic *
|
819 |
|
|
* *
|
820 |
|
|
**********************************************************************************/
|
821 |
|
|
always @ (posedge TCK or posedge trst)
|
822 |
|
|
begin
|
823 |
|
|
if(trst)
|
824 |
|
|
begin
|
825 |
|
|
ADDR[31:0] <=#Tp 32'h0;
|
826 |
|
|
DataOut[31:0] <=#Tp 32'h0;
|
827 |
|
|
RW <=#Tp 1'b0;
|
828 |
|
|
RegAccessTck <=#Tp 1'b0;
|
829 |
|
|
RISCAccessTck <=#Tp 1'b0;
|
830 |
|
|
wb_AccessTck <=#Tp 1'h0;
|
831 |
|
|
end
|
832 |
|
|
else
|
833 |
|
|
if(UpdateDR & DEBUGSelected & CrcMatch)
|
834 |
|
|
begin
|
835 |
|
|
if(RegisterScanChain)
|
836 |
|
|
begin
|
837 |
|
|
ADDR[4:0] <=#Tp JTAG_DR_IN[4:0]; // Latching address for register access
|
838 |
|
|
RW <=#Tp JTAG_DR_IN[5]; // latch R/W bit
|
839 |
|
|
DataOut[31:0] <=#Tp JTAG_DR_IN[37:6]; // latch data for write
|
840 |
|
|
RegAccessTck <=#Tp 1'b1;
|
841 |
|
|
end
|
842 |
|
|
else
|
843 |
|
|
if(RiscDebugScanChain)
|
844 |
|
|
begin
|
845 |
|
|
ADDR[31:0] <=#Tp JTAG_DR_IN[31:0]; // Latching address for RISC register access
|
846 |
|
|
RW <=#Tp JTAG_DR_IN[32]; // latch R/W bit
|
847 |
|
|
DataOut[31:0] <=#Tp JTAG_DR_IN[64:33]; // latch data for write
|
848 |
|
|
RISCAccessTck <=#Tp 1'b1;
|
849 |
|
|
end
|
850 |
|
|
else
|
851 |
|
|
if(WishboneScanChain)
|
852 |
|
|
begin
|
853 |
|
|
ADDR <=#Tp JTAG_DR_IN[31:0]; // Latching address for WISHBONE slave access
|
854 |
|
|
RW <=#Tp JTAG_DR_IN[32]; // latch R/W bit
|
855 |
|
|
DataOut <=#Tp JTAG_DR_IN[64:33]; // latch data for write
|
856 |
|
|
wb_AccessTck <=#Tp 1'b1; //
|
857 |
|
|
end
|
858 |
|
|
end
|
859 |
|
|
else
|
860 |
|
|
begin
|
861 |
|
|
RegAccessTck <=#Tp 1'b0; // This signals are valid for one TCK clock period only
|
862 |
|
|
RISCAccessTck <=#Tp 1'b0;
|
863 |
|
|
wb_AccessTck <=#Tp 1'b0;
|
864 |
|
|
end
|
865 |
|
|
end
|
866 |
|
|
|
867 |
|
|
|
868 |
|
|
assign wb_adr_o = ADDR;
|
869 |
|
|
assign wb_we_o = RW;
|
870 |
|
|
assign wb_dat_o = DataOut;
|
871 |
|
|
assign wb_sel_o[3:0] = 4'hf;
|
872 |
|
|
assign wb_cab_o = 1'b0;
|
873 |
|
|
|
874 |
|
|
|
875 |
|
|
// Synchronizing the RegAccess signal to risc_clk_i clock
|
876 |
|
|
dbg_sync_clk1_clk2 syn1 (.clk1(risc_clk_i), .clk2(TCK), .reset1(wb_rst_i), .reset2(trst),
|
877 |
|
|
.set2(RegAccessTck), .sync_out(RegAccess)
|
878 |
|
|
);
|
879 |
|
|
|
880 |
|
|
// Synchronizing the RISCAccess signal to risc_clk_i clock
|
881 |
|
|
dbg_sync_clk1_clk2 syn2 (.clk1(risc_clk_i), .clk2(TCK), .reset1(wb_rst_i), .reset2(trst),
|
882 |
|
|
.set2(RISCAccessTck), .sync_out(RISCAccess)
|
883 |
|
|
);
|
884 |
|
|
|
885 |
|
|
|
886 |
|
|
// Synchronizing the wb_Access signal to wishbone clock
|
887 |
|
|
dbg_sync_clk1_clk2 syn3 (.clk1(wb_clk_i), .clk2(TCK), .reset1(wb_rst_i), .reset2(trst),
|
888 |
|
|
.set2(wb_AccessTck), .sync_out(wb_Access_wbClk)
|
889 |
|
|
);
|
890 |
|
|
|
891 |
|
|
|
892 |
|
|
|
893 |
|
|
|
894 |
|
|
|
895 |
|
|
// Delayed signals used for accessing registers and RISC
|
896 |
|
|
always @ (posedge risc_clk_i or posedge wb_rst_i)
|
897 |
|
|
begin
|
898 |
|
|
if(wb_rst_i)
|
899 |
|
|
begin
|
900 |
|
|
RegAccess_q <=#Tp 1'b0;
|
901 |
|
|
RegAccess_q2 <=#Tp 1'b0;
|
902 |
|
|
RISCAccess_q <=#Tp 1'b0;
|
903 |
|
|
RISCAccess_q2 <=#Tp 1'b0;
|
904 |
|
|
end
|
905 |
|
|
else
|
906 |
|
|
begin
|
907 |
|
|
RegAccess_q <=#Tp RegAccess;
|
908 |
|
|
RegAccess_q2 <=#Tp RegAccess_q;
|
909 |
|
|
RISCAccess_q <=#Tp RISCAccess;
|
910 |
|
|
RISCAccess_q2 <=#Tp RISCAccess_q;
|
911 |
|
|
end
|
912 |
|
|
end
|
913 |
|
|
|
914 |
|
|
// Chip select and read/write signals for accessing RISC
|
915 |
|
|
assign RiscStall_write_access = RISCAccess & ~RISCAccess_q & RW;
|
916 |
|
|
assign RiscStall_read_access = RISCAccess & ~RISCAccess_q2 & ~RW;
|
917 |
|
|
assign RiscStall_access = RiscStall_write_access | RiscStall_read_access;
|
918 |
|
|
|
919 |
|
|
|
920 |
|
|
reg wb_Access_wbClk_q;
|
921 |
|
|
// Delayed signals used for accessing WISHBONE
|
922 |
|
|
always @ (posedge wb_clk_i or posedge wb_rst_i)
|
923 |
|
|
begin
|
924 |
|
|
if(wb_rst_i)
|
925 |
|
|
wb_Access_wbClk_q <=#Tp 1'b0;
|
926 |
|
|
else
|
927 |
|
|
wb_Access_wbClk_q <=#Tp wb_Access_wbClk;
|
928 |
|
|
end
|
929 |
|
|
|
930 |
|
|
always @ (posedge wb_clk_i or posedge wb_rst_i)
|
931 |
|
|
begin
|
932 |
|
|
if(wb_rst_i)
|
933 |
|
|
wb_cyc_o <=#Tp 1'b0;
|
934 |
|
|
else
|
935 |
|
|
if(wb_Access_wbClk & ~wb_Access_wbClk_q & ~(wb_ack_i | wb_err_i))
|
936 |
|
|
wb_cyc_o <=#Tp 1'b1;
|
937 |
|
|
else
|
938 |
|
|
if(wb_ack_i | wb_err_i)
|
939 |
|
|
wb_cyc_o <=#Tp 1'b0;
|
940 |
|
|
end
|
941 |
|
|
|
942 |
|
|
assign wb_stb_o = wb_cyc_o;
|
943 |
|
|
|
944 |
|
|
|
945 |
|
|
// Latching data read from registers
|
946 |
|
|
always @ (posedge wb_clk_i or posedge wb_rst_i)
|
947 |
|
|
begin
|
948 |
|
|
if(wb_rst_i)
|
949 |
|
|
WBReadLatch[31:0]<=#Tp 32'h0;
|
950 |
|
|
else
|
951 |
|
|
if(wb_ack_i)
|
952 |
|
|
WBReadLatch[31:0]<=#Tp wb_dat_i[31:0];
|
953 |
|
|
end
|
954 |
|
|
|
955 |
|
|
// Latching WISHBONE error cycle
|
956 |
|
|
always @ (posedge wb_clk_i or posedge wb_rst_i)
|
957 |
|
|
begin
|
958 |
|
|
if(wb_rst_i)
|
959 |
|
|
WBErrorLatch<=#Tp 1'b0;
|
960 |
|
|
else
|
961 |
|
|
if(wb_err_i)
|
962 |
|
|
WBErrorLatch<=#Tp 1'b1; // Latching wb_err_i while performing WISHBONE access
|
963 |
|
|
else
|
964 |
|
|
if(wb_ack_i)
|
965 |
|
|
WBErrorLatch<=#Tp 1'b0; // Clearing status
|
966 |
|
|
end
|
967 |
|
|
|
968 |
|
|
|
969 |
|
|
// Whan enabled, TRACE stalls RISC while saving data to the trace buffer.
|
970 |
|
|
`ifdef TRACE_ENABLED
|
971 |
|
|
assign risc_stall_o = RiscStall_access | RiscStall_reg | RiscStall_trace ;
|
972 |
|
|
`else
|
973 |
|
|
assign risc_stall_o = RiscStall_access | RiscStall_reg;
|
974 |
|
|
`endif
|
975 |
|
|
|
976 |
|
|
assign reset_o = RiscReset_reg;
|
977 |
|
|
|
978 |
|
|
|
979 |
|
|
`ifdef TRACE_ENABLED
|
980 |
|
|
always @ (RiscStall_write_access or RiscStall_read_access or opselect_trace)
|
981 |
|
|
`else
|
982 |
|
|
always @ (RiscStall_write_access or RiscStall_read_access)
|
983 |
|
|
`endif
|
984 |
|
|
begin
|
985 |
|
|
if(RiscStall_write_access)
|
986 |
|
|
opselect_o = `DEBUG_WRITE_SPR; // Write spr
|
987 |
|
|
else
|
988 |
|
|
if(RiscStall_read_access)
|
989 |
|
|
opselect_o = `DEBUG_READ_SPR; // Read spr
|
990 |
|
|
else
|
991 |
|
|
`ifdef TRACE_ENABLED
|
992 |
|
|
opselect_o = opselect_trace;
|
993 |
|
|
`else
|
994 |
|
|
opselect_o = 3'h0;
|
995 |
|
|
`endif
|
996 |
|
|
end
|
997 |
|
|
|
998 |
|
|
|
999 |
|
|
// Latching data read from RISC or registers
|
1000 |
|
|
always @ (posedge risc_clk_i or posedge wb_rst_i)
|
1001 |
|
|
begin
|
1002 |
|
|
if(wb_rst_i)
|
1003 |
|
|
DataReadLatch[31:0]<=#Tp 0;
|
1004 |
|
|
else
|
1005 |
|
|
if(RISCAccess_q & ~RISCAccess_q2)
|
1006 |
|
|
DataReadLatch[31:0]<=#Tp risc_data_i[31:0];
|
1007 |
|
|
else
|
1008 |
|
|
if(RegAccess_q & ~RegAccess_q2)
|
1009 |
|
|
DataReadLatch[31:0]<=#Tp RegDataIn[31:0];
|
1010 |
|
|
end
|
1011 |
|
|
|
1012 |
|
|
assign risc_addr_o = ADDR;
|
1013 |
|
|
assign risc_data_o = DataOut;
|
1014 |
|
|
|
1015 |
|
|
|
1016 |
|
|
|
1017 |
|
|
/**********************************************************************************
|
1018 |
|
|
* *
|
1019 |
|
|
* Read Trace buffer logic *
|
1020 |
|
|
* *
|
1021 |
|
|
**********************************************************************************/
|
1022 |
|
|
`ifdef TRACE_ENABLED
|
1023 |
|
|
|
1024 |
|
|
|
1025 |
|
|
// Synchronizing the trace read buffer signal to risc_clk_i clock
|
1026 |
|
|
dbg_sync_clk1_clk2 syn4 (.clk1(risc_clk_i), .clk2(TCK), .reset1(wb_rst_i), .reset2(trst),
|
1027 |
|
|
.set2(ReadBuffer_Tck), .sync_out(ReadTraceBuffer)
|
1028 |
|
|
);
|
1029 |
|
|
|
1030 |
|
|
|
1031 |
|
|
|
1032 |
|
|
always @(posedge risc_clk_i or posedge wb_rst_i)
|
1033 |
|
|
begin
|
1034 |
|
|
if(wb_rst_i)
|
1035 |
|
|
ReadTraceBuffer_q <=#Tp 0;
|
1036 |
|
|
else
|
1037 |
|
|
ReadTraceBuffer_q <=#Tp ReadTraceBuffer;
|
1038 |
|
|
end
|
1039 |
|
|
|
1040 |
|
|
assign ReadTraceBufferPulse = ReadTraceBuffer & ~ReadTraceBuffer_q;
|
1041 |
|
|
|
1042 |
|
|
`endif
|
1043 |
|
|
|
1044 |
|
|
/**********************************************************************************
|
1045 |
|
|
* *
|
1046 |
|
|
* End: Read Trace buffer logic *
|
1047 |
|
|
* *
|
1048 |
|
|
**********************************************************************************/
|
1049 |
|
|
|
1050 |
|
|
|
1051 |
|
|
/**********************************************************************************
|
1052 |
|
|
* *
|
1053 |
|
|
* Bypass logic *
|
1054 |
|
|
* *
|
1055 |
|
|
**********************************************************************************/
|
1056 |
|
|
reg TDOBypassed;
|
1057 |
|
|
|
1058 |
|
|
always @ (posedge TCK)
|
1059 |
|
|
begin
|
1060 |
|
|
if(ShiftDR)
|
1061 |
|
|
BypassRegister<=#Tp TDI;
|
1062 |
|
|
end
|
1063 |
|
|
|
1064 |
|
|
always @ (negedge TCK)
|
1065 |
|
|
begin
|
1066 |
|
|
TDOBypassed<=#Tp BypassRegister;
|
1067 |
|
|
end
|
1068 |
|
|
/**********************************************************************************
|
1069 |
|
|
* *
|
1070 |
|
|
* End: Bypass logic *
|
1071 |
|
|
* *
|
1072 |
|
|
**********************************************************************************/
|
1073 |
|
|
|
1074 |
|
|
|
1075 |
|
|
|
1076 |
|
|
|
1077 |
|
|
|
1078 |
|
|
/**********************************************************************************
|
1079 |
|
|
* *
|
1080 |
|
|
* Activating Instructions *
|
1081 |
|
|
* *
|
1082 |
|
|
**********************************************************************************/
|
1083 |
|
|
|
1084 |
|
|
// Updating JTAG_IR (Instruction Register)
|
1085 |
|
|
always @ (posedge TCK or posedge trst)
|
1086 |
|
|
begin
|
1087 |
|
|
if(trst)
|
1088 |
|
|
LatchedJTAG_IR <=#Tp `IDCODE; // IDCODE selected after reset
|
1089 |
|
|
else
|
1090 |
|
|
if(UpdateIR)
|
1091 |
|
|
LatchedJTAG_IR <=#Tp JTAG_IR;
|
1092 |
|
|
end
|
1093 |
|
|
|
1094 |
|
|
|
1095 |
|
|
|
1096 |
|
|
// Updating JTAG_IR (Instruction Register)
|
1097 |
|
|
always @ (LatchedJTAG_IR)
|
1098 |
|
|
begin
|
1099 |
|
|
EXTESTSelected = 0;
|
1100 |
|
|
SAMPLE_PRELOADSelected = 0;
|
1101 |
|
|
IDCODESelected = 0;
|
1102 |
|
|
CHAIN_SELECTSelected = 0;
|
1103 |
|
|
INTESTSelected = 0;
|
1104 |
|
|
CLAMPSelected = 0;
|
1105 |
|
|
CLAMPZSelected = 0;
|
1106 |
|
|
HIGHZSelected = 0;
|
1107 |
|
|
DEBUGSelected = 0;
|
1108 |
|
|
BYPASSSelected = 0;
|
1109 |
|
|
|
1110 |
|
|
case(LatchedJTAG_IR)
|
1111 |
|
|
`EXTEST: EXTESTSelected = 1; // External test
|
1112 |
|
|
`SAMPLE_PRELOAD: SAMPLE_PRELOADSelected = 1; // Sample preload
|
1113 |
|
|
`IDCODE: IDCODESelected = 1; // ID Code
|
1114 |
|
|
`CHAIN_SELECT: CHAIN_SELECTSelected = 1; // Chain select
|
1115 |
|
|
`INTEST: INTESTSelected = 1; // Internal test
|
1116 |
|
|
`CLAMP: CLAMPSelected = 1; // Clamp
|
1117 |
|
|
`CLAMPZ: CLAMPZSelected = 1; // ClampZ
|
1118 |
|
|
`HIGHZ: HIGHZSelected = 1; // High Z
|
1119 |
|
|
`DEBUG: DEBUGSelected = 1; // Debug
|
1120 |
|
|
`BYPASS: BYPASSSelected = 1; // BYPASS
|
1121 |
|
|
default: BYPASSSelected = 1; // BYPASS
|
1122 |
|
|
endcase
|
1123 |
|
|
end
|
1124 |
|
|
|
1125 |
|
|
|
1126 |
|
|
/**********************************************************************************
|
1127 |
|
|
* *
|
1128 |
|
|
* Multiplexing TDO and Tristate control *
|
1129 |
|
|
* *
|
1130 |
|
|
**********************************************************************************/
|
1131 |
|
|
wire TDOShifted;
|
1132 |
|
|
assign TDOShifted = (ShiftIR | Exit1IR)? TDOInstruction : TDOData;
|
1133 |
|
|
/**********************************************************************************
|
1134 |
|
|
* *
|
1135 |
|
|
* End: Multiplexing TDO and Tristate control *
|
1136 |
|
|
* *
|
1137 |
|
|
**********************************************************************************/
|
1138 |
|
|
|
1139 |
|
|
|
1140 |
|
|
|
1141 |
|
|
// This multiplexer can be expanded with number of user registers
|
1142 |
|
|
reg TDOMuxed;
|
1143 |
|
|
//always @ (JTAG_IR or TDOShifted or TDOBypassed or BS_CHAIN_I)
|
1144 |
|
|
always @ (LatchedJTAG_IR or TDOShifted or TDOBypassed or BS_CHAIN_I)
|
1145 |
|
|
begin
|
1146 |
|
|
case(JTAG_IR)
|
1147 |
|
|
`IDCODE: // Reading ID code
|
1148 |
|
|
begin
|
1149 |
|
|
TDOMuxed<=#Tp TDOShifted;
|
1150 |
|
|
end
|
1151 |
|
|
`CHAIN_SELECT: // Selecting the chain
|
1152 |
|
|
begin
|
1153 |
|
|
TDOMuxed<=#Tp TDOShifted;
|
1154 |
|
|
end
|
1155 |
|
|
`DEBUG: // Debug
|
1156 |
|
|
begin
|
1157 |
|
|
TDOMuxed<=#Tp TDOShifted;
|
1158 |
|
|
end
|
1159 |
|
|
`SAMPLE_PRELOAD: // Sampling/Preloading
|
1160 |
|
|
begin
|
1161 |
|
|
TDOMuxed<=#Tp BS_CHAIN_I;
|
1162 |
|
|
end
|
1163 |
|
|
`EXTEST: // External test
|
1164 |
|
|
begin
|
1165 |
|
|
TDOMuxed<=#Tp BS_CHAIN_I;
|
1166 |
|
|
end
|
1167 |
|
|
default: // BYPASS instruction
|
1168 |
|
|
begin
|
1169 |
|
|
TDOMuxed<=#Tp TDOBypassed;
|
1170 |
|
|
end
|
1171 |
|
|
endcase
|
1172 |
|
|
end
|
1173 |
|
|
|
1174 |
|
|
// Tristate control for tdo_pad_o pin
|
1175 |
|
|
//assign tdo_pad_o = (ShiftIR | ShiftDR | Exit1IR | Exit1DR | UpdateDR)? TDOMuxed : 1'bz;
|
1176 |
|
|
assign tdo_pad_o = TDOMuxed;
|
1177 |
|
|
assign tdo_padoen_o = ShiftIR | ShiftDR | Exit1IR | Exit1DR | UpdateDR;
|
1178 |
|
|
|
1179 |
|
|
/**********************************************************************************
|
1180 |
|
|
* *
|
1181 |
|
|
* End: Activating Instructions *
|
1182 |
|
|
* *
|
1183 |
|
|
**********************************************************************************/
|
1184 |
|
|
|
1185 |
|
|
/**********************************************************************************
|
1186 |
|
|
* *
|
1187 |
|
|
* Bit counter *
|
1188 |
|
|
* *
|
1189 |
|
|
**********************************************************************************/
|
1190 |
|
|
|
1191 |
|
|
|
1192 |
|
|
always @ (posedge TCK or posedge trst)
|
1193 |
|
|
begin
|
1194 |
|
|
if(trst)
|
1195 |
|
|
BitCounter[7:0]<=#Tp 0;
|
1196 |
|
|
else
|
1197 |
|
|
if(ShiftDR)
|
1198 |
|
|
BitCounter[7:0]<=#Tp BitCounter[7:0]+1;
|
1199 |
|
|
else
|
1200 |
|
|
if(UpdateDR)
|
1201 |
|
|
BitCounter[7:0]<=#Tp 0;
|
1202 |
|
|
end
|
1203 |
|
|
|
1204 |
|
|
|
1205 |
|
|
|
1206 |
|
|
/**********************************************************************************
|
1207 |
|
|
* *
|
1208 |
|
|
* End: Bit counter *
|
1209 |
|
|
* *
|
1210 |
|
|
**********************************************************************************/
|
1211 |
|
|
|
1212 |
|
|
|
1213 |
|
|
|
1214 |
|
|
/**********************************************************************************
|
1215 |
|
|
* *
|
1216 |
|
|
* Connecting Registers *
|
1217 |
|
|
* *
|
1218 |
|
|
**********************************************************************************/
|
1219 |
|
|
dbg_registers dbgregs(.DataIn(DataOut[31:0]), .DataOut(RegDataIn[31:0]),
|
1220 |
|
|
.Address(ADDR[4:0]), .RW(RW), .Access(RegAccess & ~RegAccess_q), .Clk(risc_clk_i),
|
1221 |
|
|
.Bp(bp_i), .Reset(wb_rst_i),
|
1222 |
|
|
`ifdef TRACE_ENABLED
|
1223 |
|
|
.ContinMode(ContinMode), .TraceEnable(TraceEnable),
|
1224 |
|
|
.WpTrigger(WpTrigger), .BpTrigger(BpTrigger), .LSSTrigger(LSSTrigger),
|
1225 |
|
|
.ITrigger(ITrigger), .TriggerOper(TriggerOper), .WpQualif(WpQualif),
|
1226 |
|
|
.BpQualif(BpQualif), .LSSQualif(LSSQualif), .IQualif(IQualif),
|
1227 |
|
|
.QualifOper(QualifOper), .RecordPC(RecordPC),
|
1228 |
|
|
.RecordLSEA(RecordLSEA), .RecordLDATA(RecordLDATA),
|
1229 |
|
|
.RecordSDATA(RecordSDATA), .RecordReadSPR(RecordReadSPR),
|
1230 |
|
|
.RecordWriteSPR(RecordWriteSPR), .RecordINSTR(RecordINSTR),
|
1231 |
|
|
.WpTriggerValid(WpTriggerValid),
|
1232 |
|
|
.BpTriggerValid(BpTriggerValid), .LSSTriggerValid(LSSTriggerValid),
|
1233 |
|
|
.ITriggerValid(ITriggerValid), .WpQualifValid(WpQualifValid),
|
1234 |
|
|
.BpQualifValid(BpQualifValid), .LSSQualifValid(LSSQualifValid),
|
1235 |
|
|
.IQualifValid(IQualifValid),
|
1236 |
|
|
.WpStop(WpStop), .BpStop(BpStop), .LSSStop(LSSStop), .IStop(IStop),
|
1237 |
|
|
.StopOper(StopOper), .WpStopValid(WpStopValid), .BpStopValid(BpStopValid),
|
1238 |
|
|
.LSSStopValid(LSSStopValid), .IStopValid(IStopValid),
|
1239 |
|
|
`endif
|
1240 |
|
|
.RiscStall(RiscStall_reg), .RiscReset(RiscReset_reg)
|
1241 |
|
|
|
1242 |
|
|
);
|
1243 |
|
|
|
1244 |
|
|
/**********************************************************************************
|
1245 |
|
|
* *
|
1246 |
|
|
* End: Connecting Registers *
|
1247 |
|
|
* *
|
1248 |
|
|
**********************************************************************************/
|
1249 |
|
|
|
1250 |
|
|
|
1251 |
|
|
/**********************************************************************************
|
1252 |
|
|
* *
|
1253 |
|
|
* Connecting CRC module *
|
1254 |
|
|
* *
|
1255 |
|
|
**********************************************************************************/
|
1256 |
|
|
wire AsyncResetCrc = trst;
|
1257 |
|
|
wire SyncResetCrc = UpdateDR_q;
|
1258 |
|
|
wire [7:0] CalculatedCrcIn; // crc calculated from the input data (shifted in)
|
1259 |
|
|
|
1260 |
|
|
assign BitCounter_Lt4 = BitCounter<4;
|
1261 |
|
|
assign BitCounter_Eq5 = BitCounter==5;
|
1262 |
|
|
assign BitCounter_Eq32 = BitCounter==32;
|
1263 |
|
|
assign BitCounter_Lt38 = BitCounter<38;
|
1264 |
|
|
assign BitCounter_Lt65 = BitCounter<65;
|
1265 |
|
|
|
1266 |
|
|
`ifdef TRACE_ENABLED
|
1267 |
|
|
assign BitCounter_Lt40 = BitCounter<40;
|
1268 |
|
|
`endif
|
1269 |
|
|
|
1270 |
|
|
|
1271 |
|
|
wire EnableCrcIn = ShiftDR &
|
1272 |
|
|
( (CHAIN_SELECTSelected & BitCounter_Lt4) |
|
1273 |
|
|
((DEBUGSelected & RegisterScanChain) & BitCounter_Lt38)|
|
1274 |
|
|
((DEBUGSelected & RiscDebugScanChain) & BitCounter_Lt65)|
|
1275 |
|
|
((DEBUGSelected & WishboneScanChain) & BitCounter_Lt65)
|
1276 |
|
|
);
|
1277 |
|
|
|
1278 |
|
|
wire EnableCrcOut= ShiftDR &
|
1279 |
|
|
(
|
1280 |
|
|
((DEBUGSelected & RegisterScanChain) & BitCounter_Lt38)|
|
1281 |
|
|
((DEBUGSelected & RiscDebugScanChain) & BitCounter_Lt65)|
|
1282 |
|
|
((DEBUGSelected & WishboneScanChain) & BitCounter_Lt65)
|
1283 |
|
|
`ifdef TRACE_ENABLED
|
1284 |
|
|
|
|
1285 |
|
|
((DEBUGSelected & TraceTestScanChain) & BitCounter_Lt40)
|
1286 |
|
|
`endif
|
1287 |
|
|
);
|
1288 |
|
|
|
1289 |
|
|
// Calculating crc for input data
|
1290 |
|
|
dbg_crc8_d1 crc1 (.Data(TDI), .EnableCrc(EnableCrcIn), .Reset(AsyncResetCrc), .SyncResetCrc(SyncResetCrc),
|
1291 |
|
|
.CrcOut(CalculatedCrcIn), .Clk(TCK));
|
1292 |
|
|
|
1293 |
|
|
// Calculating crc for output data
|
1294 |
|
|
dbg_crc8_d1 crc2 (.Data(TDOData), .EnableCrc(EnableCrcOut), .Reset(AsyncResetCrc), .SyncResetCrc(SyncResetCrc),
|
1295 |
|
|
.CrcOut(CalculatedCrcOut), .Clk(TCK));
|
1296 |
|
|
|
1297 |
|
|
|
1298 |
|
|
// Generating CrcMatch signal
|
1299 |
|
|
always @ (posedge TCK or posedge trst)
|
1300 |
|
|
begin
|
1301 |
|
|
if(trst)
|
1302 |
|
|
CrcMatch <=#Tp 1'b0;
|
1303 |
|
|
else
|
1304 |
|
|
if(Exit1DR)
|
1305 |
|
|
begin
|
1306 |
|
|
if(CHAIN_SELECTSelected)
|
1307 |
|
|
CrcMatch <=#Tp CalculatedCrcIn == JTAG_DR_IN[11:4];
|
1308 |
|
|
else
|
1309 |
|
|
begin
|
1310 |
|
|
if(RegisterScanChain)
|
1311 |
|
|
CrcMatch <=#Tp CalculatedCrcIn == JTAG_DR_IN[45:38];
|
1312 |
|
|
else
|
1313 |
|
|
if(RiscDebugScanChain)
|
1314 |
|
|
CrcMatch <=#Tp CalculatedCrcIn == JTAG_DR_IN[72:65];
|
1315 |
|
|
else
|
1316 |
|
|
if(WishboneScanChain)
|
1317 |
|
|
CrcMatch <=#Tp CalculatedCrcIn == JTAG_DR_IN[72:65];
|
1318 |
|
|
end
|
1319 |
|
|
end
|
1320 |
|
|
end
|
1321 |
|
|
|
1322 |
|
|
|
1323 |
|
|
// Active chain
|
1324 |
|
|
assign RegisterScanChain = Chain == `REGISTER_SCAN_CHAIN;
|
1325 |
|
|
assign RiscDebugScanChain = Chain == `RISC_DEBUG_CHAIN;
|
1326 |
|
|
assign WishboneScanChain = Chain == `WISHBONE_SCAN_CHAIN;
|
1327 |
|
|
|
1328 |
|
|
`ifdef TRACE_ENABLED
|
1329 |
|
|
assign TraceTestScanChain = Chain == `TRACE_TEST_CHAIN;
|
1330 |
|
|
`endif
|
1331 |
|
|
|
1332 |
|
|
/**********************************************************************************
|
1333 |
|
|
* *
|
1334 |
|
|
* End: Connecting CRC module *
|
1335 |
|
|
* *
|
1336 |
|
|
**********************************************************************************/
|
1337 |
|
|
|
1338 |
|
|
/**********************************************************************************
|
1339 |
|
|
* *
|
1340 |
|
|
* Connecting trace module *
|
1341 |
|
|
* *
|
1342 |
|
|
**********************************************************************************/
|
1343 |
|
|
`ifdef TRACE_ENABLED
|
1344 |
|
|
dbg_trace dbgTrace1(.Wp(wp_i), .Bp(bp_i), .DataIn(risc_data_i), .OpSelect(opselect_trace),
|
1345 |
|
|
.LsStatus(lsstatus_i), .IStatus(istatus_i), .RiscStall_O(RiscStall_trace),
|
1346 |
|
|
.Mclk(risc_clk_i), .Reset(wb_rst_i), .TraceChain(TraceChain),
|
1347 |
|
|
.ContinMode(ContinMode), .TraceEnable_reg(TraceEnable),
|
1348 |
|
|
.WpTrigger(WpTrigger),
|
1349 |
|
|
.BpTrigger(BpTrigger), .LSSTrigger(LSSTrigger), .ITrigger(ITrigger),
|
1350 |
|
|
.TriggerOper(TriggerOper), .WpQualif(WpQualif), .BpQualif(BpQualif),
|
1351 |
|
|
.LSSQualif(LSSQualif), .IQualif(IQualif), .QualifOper(QualifOper),
|
1352 |
|
|
.RecordPC(RecordPC), .RecordLSEA(RecordLSEA),
|
1353 |
|
|
.RecordLDATA(RecordLDATA), .RecordSDATA(RecordSDATA),
|
1354 |
|
|
.RecordReadSPR(RecordReadSPR), .RecordWriteSPR(RecordWriteSPR),
|
1355 |
|
|
.RecordINSTR(RecordINSTR),
|
1356 |
|
|
.WpTriggerValid(WpTriggerValid), .BpTriggerValid(BpTriggerValid),
|
1357 |
|
|
.LSSTriggerValid(LSSTriggerValid), .ITriggerValid(ITriggerValid),
|
1358 |
|
|
.WpQualifValid(WpQualifValid), .BpQualifValid(BpQualifValid),
|
1359 |
|
|
.LSSQualifValid(LSSQualifValid), .IQualifValid(IQualifValid),
|
1360 |
|
|
.ReadBuffer(ReadTraceBufferPulse),
|
1361 |
|
|
.WpStop(WpStop), .BpStop(BpStop), .LSSStop(LSSStop), .IStop(IStop),
|
1362 |
|
|
.StopOper(StopOper), .WpStopValid(WpStopValid), .BpStopValid(BpStopValid),
|
1363 |
|
|
.LSSStopValid(LSSStopValid), .IStopValid(IStopValid)
|
1364 |
|
|
);
|
1365 |
|
|
`endif
|
1366 |
|
|
/**********************************************************************************
|
1367 |
|
|
* *
|
1368 |
|
|
* End: Connecting trace module *
|
1369 |
|
|
* *
|
1370 |
|
|
**********************************************************************************/
|
1371 |
|
|
|
1372 |
|
|
|
1373 |
|
|
|
1374 |
|
|
endmodule
|