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

Subversion Repositories or1k

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

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

powered by: WebSVN 2.1.0

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