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

Subversion Repositories or1k

[/] [or1k/] [tags/] [rel_26/] [or1200/] [rtl/] [verilog/] [or1200_du.v] - Blame information for rev 617

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

Line No. Rev Author Line
1 504 lampret
//////////////////////////////////////////////////////////////////////
2
////                                                              ////
3
////  OR1200's Debug Unit                                         ////
4
////                                                              ////
5
////  This file is part of the OpenRISC 1200 project              ////
6
////  http://www.opencores.org/cores/or1k/                        ////
7
////                                                              ////
8
////  Description                                                 ////
9
////  Basic OR1200 debug unit.                                    ////
10
////                                                              ////
11
////  To Do:                                                      ////
12
////   - make it smaller and faster                               ////
13
////                                                              ////
14
////  Author(s):                                                  ////
15
////      - Damjan Lampret, lampret@opencores.org                 ////
16
////                                                              ////
17
//////////////////////////////////////////////////////////////////////
18
////                                                              ////
19
//// Copyright (C) 2000 Authors and OPENCORES.ORG                 ////
20
////                                                              ////
21
//// This source file may be used and distributed without         ////
22
//// restriction provided that this copyright statement is not    ////
23
//// removed from the file and that any derivative work contains  ////
24
//// the original copyright notice and the associated disclaimer. ////
25
////                                                              ////
26
//// This source file is free software; you can redistribute it   ////
27
//// and/or modify it under the terms of the GNU Lesser General   ////
28
//// Public License as published by the Free Software Foundation; ////
29
//// either version 2.1 of the License, or (at your option) any   ////
30
//// later version.                                               ////
31
////                                                              ////
32
//// This source is distributed in the hope that it will be       ////
33
//// useful, but WITHOUT ANY WARRANTY; without even the implied   ////
34
//// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR      ////
35
//// PURPOSE.  See the GNU Lesser General Public License for more ////
36
//// details.                                                     ////
37
////                                                              ////
38
//// You should have received a copy of the GNU Lesser General    ////
39
//// Public License along with this source; if not, download it   ////
40
//// from http://www.opencores.org/lgpl.shtml                     ////
41
////                                                              ////
42
//////////////////////////////////////////////////////////////////////
43
//
44
// CVS Revision History
45
//
46
// $Log: not supported by cvs2svn $
47 617 lampret
// Revision 1.3  2002/01/18 07:56:00  lampret
48
// No more low/high priority interrupts (PICPR removed). Added tick timer exception. Added exception prefix (SR[EPH]). Fixed single-step bug whenreading NPC.
49
//
50 589 lampret
// Revision 1.2  2002/01/14 06:18:22  lampret
51
// Fixed mem2reg bug in FAST implementation. Updated debug unit to work with new genpc/if.
52
//
53 562 lampret
// Revision 1.1  2002/01/03 08:16:15  lampret
54
// New prefixes for RTL files, prefixed module names. Updated cache controllers and MMUs.
55
//
56 504 lampret
// Revision 1.12  2001/11/30 18:58:00  simons
57
// Trap insn couses break after exits ex_insn.
58
//
59
// Revision 1.11  2001/11/23 08:38:51  lampret
60
// Changed DSR/DRR behavior and exception detection.
61
//
62
// Revision 1.10  2001/11/20 21:25:44  lampret
63
// Fixed dbg_is_o assignment width.
64
//
65
// Revision 1.9  2001/11/20 18:46:14  simons
66
// Break point bug fixed
67
//
68
// Revision 1.8  2001/11/18 08:36:28  lampret
69
// For GDB changed single stepping and disabled trap exception.
70
//
71
// Revision 1.7  2001/10/21 18:09:53  lampret
72
// Fixed sensitivity list.
73
//
74
// Revision 1.6  2001/10/14 13:12:09  lampret
75
// MP3 version.
76
//
77
//
78
 
79
// synopsys translate_off
80
`include "timescale.v"
81
// synopsys translate_on
82
`include "or1200_defines.v"
83
 
84
//
85
// Debug unit
86
//
87
 
88
module or1200_du(
89
        // RISC Internal Interface
90
        clk, rst,
91
        dcpu_cyc_i, dcpu_stb_i, dcpu_we_i,
92
        icpu_cyc_i, icpu_stb_i, ex_freeze, branch_op, ex_insn, du_dsr,
93
        du_stall, du_addr, du_dat_i, du_dat_o, du_read, du_write, du_except,
94
        spr_cs, spr_write, spr_addr, spr_dat_i, spr_dat_o,
95
 
96
        // External Debug Interface
97
        dbg_stall_i, dbg_dat_i, dbg_adr_i, dbg_op_i, dbg_ewt_i,
98
        dbg_lss_o, dbg_is_o, dbg_wp_o, dbg_bp_o, dbg_dat_o
99
);
100
 
101
parameter dw = `OR1200_OPERAND_WIDTH;
102
parameter aw = `OR1200_OPERAND_WIDTH;
103
 
104
//
105
// I/O
106
//
107
 
108
//
109
// RISC Internal Interface
110
//
111
input                           clk;            // Clock
112
input                           rst;            // Reset
113
input                           dcpu_cyc_i;     // LSU status
114
input                           dcpu_stb_i;     // LSU status
115
input                           dcpu_we_i;      // LSU status
116
input   [`OR1200_FETCHOP_WIDTH-1:0]      icpu_cyc_i;     // IFETCH unit status
117
input   [`OR1200_FETCHOP_WIDTH-1:0]      icpu_stb_i;     // IFETCH unit status
118
input                           ex_freeze;      // EX stage freeze
119
input   [`OR1200_BRANCHOP_WIDTH-1:0]     branch_op;      // Branch op
120
input   [dw-1:0]         ex_insn;        // EX insn
121
output  [`OR1200_DU_DSR_WIDTH-1:0]     du_dsr;           // DSR
122
output                          du_stall;       // Debug Unit Stall
123
output  [aw-1:0]         du_addr;        // Debug Unit Address
124
input   [dw-1:0]         du_dat_i;       // Debug Unit Data In
125
output  [dw-1:0]         du_dat_o;       // Debug Unit Data Out
126
output                          du_read;        // Debug Unit Read Enable
127
output                          du_write;       // Debug Unit Write Enable
128
input   [12:0]                   du_except;      // Exception masked by DSR
129
input                           spr_cs;         // SPR Chip Select
130
input                           spr_write;      // SPR Read/Write
131
input   [aw-1:0]         spr_addr;       // SPR Address
132
input   [dw-1:0]         spr_dat_i;      // SPR Data Input
133
output  [dw-1:0]         spr_dat_o;      // SPR Data Output
134
 
135
//
136
// External Debug Interface
137
//
138
input                           dbg_stall_i;    // External Stall Input
139
input   [dw-1:0]         dbg_dat_i;      // External Data Input
140
input   [aw-1:0]         dbg_adr_i;      // External Address Input
141
input   [2:0]                    dbg_op_i;       // External Operation Select Input
142
input                           dbg_ewt_i;      // External Watchpoint Trigger Input
143
output  [3:0]                    dbg_lss_o;      // External Load/Store Unit Status
144
output  [1:0]                    dbg_is_o;       // External Insn Fetch Status
145
output  [10:0]                   dbg_wp_o;       // Watchpoints Outputs
146
output                          dbg_bp_o;       // Breakpoint Output
147
output  [dw-1:0]         dbg_dat_o;      // External Data Output
148
 
149
 
150
//
151
// Some connections go directly from the CPU through DU to Debug I/F
152
//
153
assign dbg_lss_o = dcpu_cyc_i & dcpu_stb_i ? {dcpu_we_i, 3'b000} : 4'b0000;
154
assign dbg_is_o = {1'b0, icpu_cyc_i & icpu_stb_i};
155
assign dbg_wp_o = 11'b000_0000_0000;
156
assign dbg_dat_o = du_dat_i;
157
 
158
//
159
// Some connections go directly from Debug I/F through DU to the CPU
160
//
161
assign du_stall = dbg_stall_i;
162
assign du_addr = dbg_adr_i;
163
assign du_dat_o = dbg_dat_i;
164
assign du_read = (dbg_op_i == `OR1200_DU_OP_READSPR);
165
assign du_write = (dbg_op_i == `OR1200_DU_OP_WRITESPR);
166
 
167
`ifdef OR1200_DU_IMPLEMENTED
168
 
169
//
170
// Debug Mode Register 1 (only ST and BT implemented)
171
//
172
`ifdef OR1200_DU_DMR1
173
reg     [23:22]                 dmr1;           // DMR1 implemented (ST & BT)
174
`else
175
wire    [23:22]                 dmr1;           // DMR1 not implemented
176
`endif
177
 
178
//
179
// Debug Mode Register 2 (not implemented)
180
//
181
`ifdef OR1200_DU_DMR2
182
wire    [31:0]                   dmr2;           // DMR not implemented
183
`endif
184
 
185
//
186
// Debug Stop Register
187
//
188
`ifdef OR1200_DU_DSR
189
reg     [`OR1200_DU_DSR_WIDTH-1:0]       dsr;            // DSR implemented
190
`else
191
wire    [`OR1200_DU_DSR_WIDTH-1:0]       dsr;            // DSR not implemented
192
`endif
193
 
194
//
195
// Debug Reason Register
196
//
197
`ifdef OR1200_DU_DRR
198
reg     [13:0]                   drr;            // DRR implemented
199
`else
200
wire    [13:0]                   drr;            // DRR not implemented
201
`endif
202
 
203
//
204
// Internal wires
205
//
206
wire                            dmr1_sel;       // DMR1 select
207
wire                            dsr_sel;        // DSR select
208
wire                            drr_sel;        // DRR select
209
reg                             dbg_bp_r;
210
`ifdef OR1200_DU_READREGS
211
reg     [31:0]                   spr_dat_o;
212
`endif
213
reg     [13:0]                   except_stop;    // Exceptions that stop because of DSR
214
 
215
//
216
// DU registers address decoder
217
//
218
`ifdef OR1200_DU_DMR1
219
assign dmr1_sel = (spr_cs && (spr_addr[`OR1200_SPR_OFS_BITS] == `OR1200_DU_OFS_DMR1));
220
`endif
221
`ifdef OR1200_DU_DSR
222
assign dsr_sel = (spr_cs && (spr_addr[`OR1200_SPR_OFS_BITS] == `OR1200_DU_OFS_DSR));
223
`endif
224
`ifdef OR1200_DU_DRR
225
assign drr_sel = (spr_cs && (spr_addr[`OR1200_SPR_OFS_BITS] == `OR1200_DU_OFS_DRR));
226
`endif
227
 
228
//
229
// Decode started exception
230
//
231
always @(du_except) begin
232
        except_stop = 14'b0000_0000_0000;
233
        casex (du_except)
234 617 lampret
                13'b1_xxxx_xxxx_xxxx:
235
                        except_stop[`OR1200_DU_DRR_TTE] = 1'b1;
236
                13'b0_1xxx_xxxx_xxxx: begin
237 589 lampret
                        except_stop[`OR1200_DU_DRR_IE] = 1'b1;
238 504 lampret
                end
239 617 lampret
                13'b0_01xx_xxxx_xxxx: begin
240 504 lampret
                        except_stop[`OR1200_DU_DRR_IME] = 1'b1;
241
                end
242 617 lampret
                13'b0_001x_xxxx_xxxx:
243 504 lampret
                        except_stop[`OR1200_DU_DRR_IPFE] = 1'b1;
244 617 lampret
                13'b0_0001_xxxx_xxxx: begin
245 504 lampret
                        except_stop[`OR1200_DU_DRR_BUSEE] = 1'b1;
246
                end
247 617 lampret
                13'b0_0000_1xxx_xxxx:
248 504 lampret
                        except_stop[`OR1200_DU_DRR_IIE] = 1'b1;
249 617 lampret
                13'b0_0000_01xx_xxxx: begin
250 504 lampret
                        except_stop[`OR1200_DU_DRR_AE] = 1'b1;
251
                end
252 617 lampret
                13'b0_0000_001x_xxxx: begin
253 504 lampret
                        except_stop[`OR1200_DU_DRR_DME] = 1'b1;
254
                end
255 617 lampret
                13'b0_0000_0001_xxxx:
256 504 lampret
                        except_stop[`OR1200_DU_DRR_DPFE] = 1'b1;
257 617 lampret
                13'b0_0000_0000_1xxx:
258 504 lampret
                        except_stop[`OR1200_DU_DRR_BUSEE] = 1'b1;
259
                13'b0_0000_0000_01xx: begin
260
                        except_stop[`OR1200_DU_DRR_RE] = 1'b1;
261
                end
262
                13'b0_0000_0000_001x: begin
263
                        except_stop[`OR1200_DU_DRR_TE] = 1'b1;
264
                end
265
                13'b0_0000_0000_0001:
266
                        except_stop[`OR1200_DU_DRR_SCE] = 1'b1;
267
                default:
268
                        except_stop = 14'b0000_0000_0000;
269
        endcase
270
end
271
 
272
//
273
// dbg_bp_o is registered
274
//
275
assign dbg_bp_o = dbg_bp_r;
276
 
277
//
278
// Breakpoint activation register
279
//
280
always @(posedge clk or posedge rst)
281
        if (rst)
282
                dbg_bp_r <= #1 1'b0;
283
        else if (!ex_freeze)
284
                dbg_bp_r <= #1 |except_stop
285
`ifdef OR1200_DU_DMR1_ST
286 617 lampret
                        | ~((ex_insn[31:26] == `OR1200_OR32_NOP) & ex_insn[16]) & dmr1[`OR1200_DU_DMR1_ST]
287 504 lampret
`endif
288
`ifdef OR1200_DU_DMR1_BT
289
                        | (branch_op != `OR1200_BRANCHOP_NOP) & dmr1[`OR1200_DU_DMR1_BT]
290
`endif
291
                        ;
292
        else
293 562 lampret
                dbg_bp_r <= #1 |except_stop;
294 504 lampret
 
295
//
296
// Write to DMR1
297
//
298
`ifdef OR1200_DU_DMR1
299
always @(posedge clk or posedge rst)
300
        if (rst)
301
                dmr1 <= 2'b00;
302
        else if (dmr1_sel && spr_write)
303
                dmr1 <= #1 spr_dat_i[23:22];
304
`else
305
assign dmr1 = 2'b00;
306
`endif
307
 
308
//
309
// DMR2 bits tied to zero
310
//
311
`ifdef OR1200_DU_DMR2
312
assign dmr2 = 32'h0000_0000;
313
`endif
314
 
315
//
316
// Write to DSR
317
//
318
`ifdef OR1200_DU_DSR
319
always @(posedge clk or posedge rst)
320
        if (rst)
321
                dsr <= {`OR1200_DU_DSR_WIDTH{1'b0}};
322
        else if (dsr_sel && spr_write)
323
                dsr <= #1 spr_dat_i[`OR1200_DU_DSR_WIDTH-1:0];
324
`else
325
assign dsr = {`OR1200_DU_DSR_WIDTH{1'b0}};
326
`endif
327
 
328
//
329
// Write to DRR
330
//
331
`ifdef OR1200_DU_DRR
332
always @(posedge clk or posedge rst)
333
        if (rst)
334
                drr <= 14'b0;
335
        else if (drr_sel && spr_write)
336
                drr <= #1 spr_dat_i[13:0];
337
        else
338
                drr <= #1 drr | except_stop;
339
`else
340
assign drr = 14'b0;
341
`endif
342
 
343
//
344
// Read DU registers
345
//
346
`ifdef OR1200_DU_READREGS
347
always @(spr_addr or dsr or drr or dmr1 or dmr2)
348
        case (spr_addr[`OR1200_SPR_OFS_BITS])
349
`ifdef OR1200_DU_DMR1
350
                `OR1200_DU_OFS_DMR1:
351
                        spr_dat_o = {8'b0, dmr1, 22'b0};
352
`endif
353
`ifdef OR1200_DU_DMR2
354
                `OR1200_DU_OFS_DMR2:
355
                        spr_dat_o = dmr2;
356
`endif
357
`ifdef OR1200_DU_DSR
358
                `OR1200_DU_OFS_DSR:
359
                        spr_dat_o = {18'b0, dsr};
360
`endif
361
`ifdef OR1200_DU_DRR
362
                `OR1200_DU_OFS_DRR:
363
                        spr_dat_o = {18'b0, drr};
364
`endif
365
                default:
366
                        spr_dat_o = 32'h0000_0000;
367
        endcase
368
`endif
369
 
370
//
371
// DSR alias
372
//
373
assign du_dsr = dsr;
374
 
375
`else
376
 
377
//
378
// When DU is not implemented, drive all outputs as would when DU is disabled
379
//
380
assign dbg_bp_o = 1'b0;
381
assign du_dsr = {`OR1200_DU_DSR_WIDTH{1'b0}};
382
 
383
//
384
// Read DU registers
385
//
386
`ifdef OR1200_DU_READREGS
387
assign spr_dat_o = 32'h0000_0000;
388
`ifdef OR1200_DU_UNUSED_ZERO
389
`endif
390
`endif
391
 
392
`endif
393
 
394
endmodule

powered by: WebSVN 2.1.0

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