1 |
746 |
lampret |
//////////////////////////////////////////////////////////////////////
|
2 |
|
|
//// ////
|
3 |
|
|
//// dbg_registers.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.5 2001/11/26 10:47:09 mohor
|
49 |
|
|
// Crc generation is different for read or write commands. Small synthesys fixes.
|
50 |
|
|
//
|
51 |
|
|
// Revision 1.4 2001/10/19 11:40:02 mohor
|
52 |
|
|
// dbg_timescale.v changed to timescale.v This is done for the simulation of
|
53 |
|
|
// few different cores in a single project.
|
54 |
|
|
//
|
55 |
|
|
// Revision 1.3 2001/10/15 09:55:47 mohor
|
56 |
|
|
// Wishbone interface added, few fixes for better performance,
|
57 |
|
|
// hooks for boundary scan testing added.
|
58 |
|
|
//
|
59 |
|
|
// Revision 1.2 2001/09/18 14:13:47 mohor
|
60 |
|
|
// Trace fixed. Some registers changed, trace simplified.
|
61 |
|
|
//
|
62 |
|
|
// Revision 1.1.1.1 2001/09/13 13:49:19 mohor
|
63 |
|
|
// Initial official release.
|
64 |
|
|
//
|
65 |
|
|
// Revision 1.3 2001/06/01 22:22:35 mohor
|
66 |
|
|
// This is a backup. It is not a fully working version. Not for use, yet.
|
67 |
|
|
//
|
68 |
|
|
// Revision 1.2 2001/05/18 13:10:00 mohor
|
69 |
|
|
// Headers changed. All additional information is now avaliable in the README.txt file.
|
70 |
|
|
//
|
71 |
|
|
// Revision 1.1.1.1 2001/05/18 06:35:10 mohor
|
72 |
|
|
// Initial release
|
73 |
|
|
//
|
74 |
|
|
//
|
75 |
|
|
|
76 |
|
|
// synopsys translate_off
|
77 |
|
|
`include "timescale.v"
|
78 |
|
|
// synopsys translate_on
|
79 |
|
|
`include "dbg_defines.v"
|
80 |
|
|
|
81 |
|
|
module dbg_registers(DataIn, DataOut, Address, RW, Access, Clk, Bp, Reset,
|
82 |
|
|
`ifdef TRACE_ENABLED
|
83 |
|
|
ContinMode,
|
84 |
|
|
TraceEnable, WpTrigger, BpTrigger, LSSTrigger,
|
85 |
|
|
ITrigger, TriggerOper, WpQualif, BpQualif, LSSQualif, IQualif,
|
86 |
|
|
QualifOper, RecordPC, RecordLSEA, RecordLDATA,
|
87 |
|
|
RecordSDATA, RecordReadSPR, RecordWriteSPR, RecordINSTR,
|
88 |
|
|
WpTriggerValid, BpTriggerValid, LSSTriggerValid, ITriggerValid,
|
89 |
|
|
WpQualifValid, BpQualifValid, LSSQualifValid, IQualifValid,
|
90 |
|
|
WpStop, BpStop, LSSStop, IStop, StopOper, WpStopValid, BpStopValid,
|
91 |
|
|
LSSStopValid, IStopValid,
|
92 |
|
|
`endif
|
93 |
|
|
RiscStall, RiscReset
|
94 |
|
|
);
|
95 |
|
|
|
96 |
|
|
parameter Tp = 1;
|
97 |
|
|
|
98 |
|
|
input [31:0] DataIn;
|
99 |
|
|
input [4:0] Address;
|
100 |
|
|
|
101 |
|
|
input RW;
|
102 |
|
|
input Access;
|
103 |
|
|
input Clk;
|
104 |
|
|
input Bp;
|
105 |
|
|
input Reset;
|
106 |
|
|
|
107 |
|
|
output [31:0] DataOut;
|
108 |
|
|
reg [31:0] DataOut;
|
109 |
|
|
|
110 |
|
|
`ifdef TRACE_ENABLED
|
111 |
|
|
output ContinMode;
|
112 |
|
|
output TraceEnable;
|
113 |
|
|
|
114 |
|
|
output [10:0] WpTrigger;
|
115 |
|
|
output BpTrigger;
|
116 |
|
|
output [3:0] LSSTrigger;
|
117 |
|
|
output [1:0] ITrigger;
|
118 |
|
|
output [1:0] TriggerOper;
|
119 |
|
|
|
120 |
|
|
output WpTriggerValid;
|
121 |
|
|
output BpTriggerValid;
|
122 |
|
|
output LSSTriggerValid;
|
123 |
|
|
output ITriggerValid;
|
124 |
|
|
|
125 |
|
|
output [10:0] WpQualif;
|
126 |
|
|
output BpQualif;
|
127 |
|
|
output [3:0] LSSQualif;
|
128 |
|
|
output [1:0] IQualif;
|
129 |
|
|
output [1:0] QualifOper;
|
130 |
|
|
|
131 |
|
|
output WpQualifValid;
|
132 |
|
|
output BpQualifValid;
|
133 |
|
|
output LSSQualifValid;
|
134 |
|
|
output IQualifValid;
|
135 |
|
|
|
136 |
|
|
output [10:0] WpStop;
|
137 |
|
|
output BpStop;
|
138 |
|
|
output [3:0] LSSStop;
|
139 |
|
|
output [1:0] IStop;
|
140 |
|
|
output [1:0] StopOper;
|
141 |
|
|
|
142 |
|
|
output WpStopValid;
|
143 |
|
|
output BpStopValid;
|
144 |
|
|
output LSSStopValid;
|
145 |
|
|
output IStopValid;
|
146 |
|
|
|
147 |
|
|
output RecordPC;
|
148 |
|
|
output RecordLSEA;
|
149 |
|
|
output RecordLDATA;
|
150 |
|
|
output RecordSDATA;
|
151 |
|
|
output RecordReadSPR;
|
152 |
|
|
output RecordWriteSPR;
|
153 |
|
|
output RecordINSTR;
|
154 |
|
|
`endif
|
155 |
|
|
|
156 |
|
|
output RiscStall;
|
157 |
|
|
output RiscReset;
|
158 |
|
|
|
159 |
|
|
wire MODER_Acc = (Address == `MODER_ADR) & Access;
|
160 |
|
|
wire RISCOP_Acc = (Address == `RISCOP_ADR) & Access;
|
161 |
|
|
`ifdef TRACE_ENABLED
|
162 |
|
|
wire TSEL_Acc = (Address == `TSEL_ADR) & Access;
|
163 |
|
|
wire QSEL_Acc = (Address == `QSEL_ADR) & Access;
|
164 |
|
|
wire SSEL_Acc = (Address == `SSEL_ADR) & Access;
|
165 |
|
|
wire RECSEL_Acc = (Address == `RECSEL_ADR) & Access;
|
166 |
|
|
`endif
|
167 |
|
|
|
168 |
|
|
|
169 |
|
|
wire MODER_Wr = MODER_Acc & RW;
|
170 |
|
|
wire RISCOP_Wr = RISCOP_Acc & RW;
|
171 |
|
|
`ifdef TRACE_ENABLED
|
172 |
|
|
wire TSEL_Wr = TSEL_Acc & RW;
|
173 |
|
|
wire QSEL_Wr = QSEL_Acc & RW;
|
174 |
|
|
wire SSEL_Wr = SSEL_Acc & RW;
|
175 |
|
|
wire RECSEL_Wr = RECSEL_Acc & RW;
|
176 |
|
|
`endif
|
177 |
|
|
|
178 |
|
|
|
179 |
|
|
|
180 |
|
|
wire MODER_Rd = MODER_Acc & ~RW;
|
181 |
|
|
wire RISCOP_Rd = RISCOP_Acc & ~RW;
|
182 |
|
|
`ifdef TRACE_ENABLED
|
183 |
|
|
wire TSEL_Rd = TSEL_Acc & ~RW;
|
184 |
|
|
wire QSEL_Rd = QSEL_Acc & ~RW;
|
185 |
|
|
wire SSEL_Rd = SSEL_Acc & ~RW;
|
186 |
|
|
wire RECSEL_Rd = RECSEL_Acc & ~RW;
|
187 |
|
|
`endif
|
188 |
|
|
|
189 |
|
|
|
190 |
|
|
wire [31:0] MODEROut;
|
191 |
|
|
wire [1:1] RISCOPOut;
|
192 |
|
|
|
193 |
|
|
`ifdef TRACE_ENABLED
|
194 |
|
|
wire [31:0] TSELOut;
|
195 |
|
|
wire [31:0] QSELOut;
|
196 |
|
|
wire [31:0] SSELOut;
|
197 |
|
|
wire [6:0] RECSELOut;
|
198 |
|
|
`endif
|
199 |
|
|
|
200 |
|
|
|
201 |
|
|
`ifdef TRACE_ENABLED
|
202 |
|
|
assign MODEROut[15:0] = 16'h0001;
|
203 |
|
|
assign MODEROut[31:18] = 14'h0;
|
204 |
|
|
`else
|
205 |
|
|
assign MODEROut[31:0] = 32'h0000;
|
206 |
|
|
`endif
|
207 |
|
|
|
208 |
|
|
|
209 |
|
|
reg RiscStallBp;
|
210 |
|
|
always @(posedge Clk or posedge Reset)
|
211 |
|
|
begin
|
212 |
|
|
if(Reset)
|
213 |
|
|
RiscStallBp <= 1'b0;
|
214 |
|
|
else
|
215 |
|
|
if(Bp) // Breakpoint sets bit
|
216 |
|
|
RiscStallBp <= 1'b1;
|
217 |
|
|
else
|
218 |
|
|
if(RISCOP_Wr) // Register access can set or clear bit
|
219 |
|
|
RiscStallBp <= DataIn[0];
|
220 |
|
|
end
|
221 |
|
|
|
222 |
|
|
dbg_register #(1) RISCOP (.DataIn(DataIn[1]), .DataOut(RISCOPOut[1]), .Write(RISCOP_Wr), .Clk(Clk), .Reset(Reset), .Default(1'b0));
|
223 |
|
|
|
224 |
|
|
|
225 |
|
|
`ifdef TRACE_ENABLED
|
226 |
|
|
dbg_register #(2) MODER (.DataIn(DataIn[17:16]), .DataOut(MODEROut[17:16]), .Write(MODER_Wr), .Clk(Clk), .Reset(Reset), .Default(`MODER_DEF));
|
227 |
|
|
dbg_register #(32) TSEL (.DataIn(DataIn), .DataOut(TSELOut), .Write(TSEL_Wr), .Clk(Clk), .Reset(Reset), .Default(`TSEL_DEF));
|
228 |
|
|
dbg_register #(32) QSEL (.DataIn(DataIn), .DataOut(QSELOut), .Write(QSEL_Wr), .Clk(Clk), .Reset(Reset), .Default(`QSEL_DEF));
|
229 |
|
|
dbg_register #(32) SSEL (.DataIn(DataIn), .DataOut(SSELOut), .Write(SSEL_Wr), .Clk(Clk), .Reset(Reset), .Default(`SSEL_DEF));
|
230 |
|
|
dbg_register #(7) RECSEL (.DataIn(DataIn[6:0]), .DataOut(RECSELOut), .Write(RECSEL_Wr), .Clk(Clk), .Reset(Reset), .Default(`RECSEL_DEF));
|
231 |
|
|
`endif
|
232 |
|
|
|
233 |
|
|
|
234 |
|
|
|
235 |
|
|
always @ (posedge Clk)
|
236 |
|
|
begin
|
237 |
|
|
if(MODER_Rd) DataOut<= #Tp MODEROut;
|
238 |
|
|
else
|
239 |
|
|
if(RISCOP_Rd) DataOut<= #Tp {30'h0, RISCOPOut[1], RiscStall};
|
240 |
|
|
`ifdef TRACE_ENABLED
|
241 |
|
|
else
|
242 |
|
|
if(TSEL_Rd) DataOut<= #Tp TSELOut;
|
243 |
|
|
else
|
244 |
|
|
if(QSEL_Rd) DataOut<= #Tp QSELOut;
|
245 |
|
|
else
|
246 |
|
|
if(SSEL_Rd) DataOut<= #Tp SSELOut;
|
247 |
|
|
else
|
248 |
|
|
if(RECSEL_Rd) DataOut<= #Tp {25'h0, RECSELOut};
|
249 |
|
|
`endif
|
250 |
|
|
else DataOut<= #Tp 'h0;
|
251 |
|
|
end
|
252 |
|
|
|
253 |
|
|
`ifdef TRACE_ENABLED
|
254 |
|
|
assign TraceEnable = MODEROut[16];
|
255 |
|
|
assign ContinMode = MODEROut[17];
|
256 |
|
|
|
257 |
|
|
assign WpTrigger[10:0] = TSELOut[10:0];
|
258 |
|
|
assign WpTriggerValid = TSELOut[11];
|
259 |
|
|
assign BpTrigger = TSELOut[12];
|
260 |
|
|
assign BpTriggerValid = TSELOut[13];
|
261 |
|
|
assign LSSTrigger[3:0] = TSELOut[19:16];
|
262 |
|
|
assign LSSTriggerValid = TSELOut[20];
|
263 |
|
|
assign ITrigger[1:0] = TSELOut[22:21];
|
264 |
|
|
assign ITriggerValid = TSELOut[23];
|
265 |
|
|
assign TriggerOper[1:0] = TSELOut[31:30];
|
266 |
|
|
|
267 |
|
|
assign WpQualif[10:0] = QSELOut[10:0];
|
268 |
|
|
assign WpQualifValid = QSELOut[11];
|
269 |
|
|
assign BpQualif = QSELOut[12];
|
270 |
|
|
assign BpQualifValid = QSELOut[13];
|
271 |
|
|
assign LSSQualif[3:0] = QSELOut[19:16];
|
272 |
|
|
assign LSSQualifValid = QSELOut[20];
|
273 |
|
|
assign IQualif[1:0] = QSELOut[22:21];
|
274 |
|
|
assign IQualifValid = QSELOut[23];
|
275 |
|
|
assign QualifOper[1:0] = QSELOut[31:30];
|
276 |
|
|
|
277 |
|
|
assign WpStop[10:0] = SSELOut[10:0];
|
278 |
|
|
assign WpStopValid = SSELOut[11];
|
279 |
|
|
assign BpStop = SSELOut[12];
|
280 |
|
|
assign BpStopValid = SSELOut[13];
|
281 |
|
|
assign LSSStop[3:0] = SSELOut[19:16];
|
282 |
|
|
assign LSSStopValid = SSELOut[20];
|
283 |
|
|
assign IStop[1:0] = SSELOut[22:21];
|
284 |
|
|
assign IStopValid = SSELOut[23];
|
285 |
|
|
assign StopOper[1:0] = SSELOut[31:30];
|
286 |
|
|
|
287 |
|
|
|
288 |
|
|
assign RecordPC = RECSELOut[0];
|
289 |
|
|
assign RecordLSEA = RECSELOut[1];
|
290 |
|
|
assign RecordLDATA = RECSELOut[2];
|
291 |
|
|
assign RecordSDATA = RECSELOut[3];
|
292 |
|
|
assign RecordReadSPR = RECSELOut[4];
|
293 |
|
|
assign RecordWriteSPR = RECSELOut[5];
|
294 |
|
|
assign RecordINSTR = RECSELOut[6];
|
295 |
|
|
`endif
|
296 |
|
|
|
297 |
|
|
assign RiscStall = Bp | RiscStallBp; // Bp asynchronously sets the RiscStall, then RiscStallBp (from register) holds it active
|
298 |
|
|
assign RiscReset = RISCOPOut[1];
|
299 |
|
|
|
300 |
|
|
endmodule
|