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

Subversion Repositories or1k

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

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

powered by: WebSVN 2.1.0

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