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

Subversion Repositories or1200_hp

[/] [or1200_hp/] [trunk/] [rtl/] [rtl_cm2/] [verilog/] [or1200_sprs.v] - Blame information for rev 2

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 tobil
//////////////////////////////////////////////////////////////////////
2
////                                                              ////
3
////  OR1200's interface to SPRs                                  ////
4
////                                                              ////
5
////  This file is part of the OpenRISC 1200 project              ////
6
////  http://www.opencores.org/cores/or1k/                        ////
7
////                                                              ////
8
////  Description                                                 ////
9
////  Decoding of SPR addresses and access to SPRs                ////
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.9.4.1  2003/12/17 13:43:38  simons
48
// Exception prefix configuration changed.
49
//
50
// Revision 1.9  2002/09/07 05:42:02  lampret
51
// Added optional SR[CY]. Added define to enable additional (compare) flag modifiers. Defines are OR1200_IMPL_ADDC and OR1200_ADDITIONAL_FLAG_MODIFIERS.
52
//
53
// Revision 1.8  2002/08/28 01:44:25  lampret
54
// Removed some commented RTL. Fixed SR/ESR flag bug.
55
//
56
// Revision 1.7  2002/03/29 15:16:56  lampret
57
// Some of the warnings fixed.
58
//
59
// Revision 1.6  2002/03/11 01:26:57  lampret
60
// Changed generation of SPR address. Now it is ORed from base and offset instead of a sum.
61
//
62
// Revision 1.5  2002/02/01 19:56:54  lampret
63
// Fixed combinational loops.
64
//
65
// Revision 1.4  2002/01/23 07:52:36  lampret
66
// Changed default reset values for SR and ESR to match or1ksim's. Fixed flop model in or1200_dpram_32x32 when OR1200_XILINX_RAM32X1D is defined.
67
//
68
// Revision 1.3  2002/01/19 09:27:49  lampret
69
// SR[TEE] should be zero after reset.
70
//
71
// Revision 1.2  2002/01/18 07:56:00  lampret
72
// No more low/high priority interrupts (PICPR removed). Added tick timer exception. Added exception prefix (SR[EPH]). Fixed single-step bug whenreading NPC.
73
//
74
// Revision 1.1  2002/01/03 08:16:15  lampret
75
// New prefixes for RTL files, prefixed module names. Updated cache controllers and MMUs.
76
//
77
// Revision 1.12  2001/11/23 21:42:31  simons
78
// Program counter divided to PPC and NPC.
79
//
80
// Revision 1.11  2001/11/23 08:38:51  lampret
81
// Changed DSR/DRR behavior and exception detection.
82
//
83
// Revision 1.10  2001/11/12 01:45:41  lampret
84
// Moved flag bit into SR. Changed RF enable from constant enable to dynamic enable for read ports.
85
//
86
// Revision 1.9  2001/10/21 17:57:16  lampret
87
// Removed params from generic_XX.v. Added translate_off/on in sprs.v and id.v. Removed spr_addr from dc.v and ic.v. Fixed CR+LF.
88
//
89
// Revision 1.8  2001/10/14 13:12:10  lampret
90
// MP3 version.
91
//
92
// Revision 1.1.1.1  2001/10/06 10:18:36  igorm
93
// no message
94
//
95
// Revision 1.3  2001/08/13 03:36:20  lampret
96
// Added cfg regs. Moved all defines into one defines.v file. More cleanup.
97
//
98
// Revision 1.2  2001/08/09 13:39:33  lampret
99
// Major clean-up.
100
//
101
// Revision 1.1  2001/07/20 00:46:21  lampret
102
// Development version of RTL. Libraries are missing.
103
//
104
//
105
 
106
// synopsys translate_off
107
`include "timescale.v"
108
// synopsys translate_on
109
`include "or1200_defines.v"
110
 
111
module or1200_sprs_cm2(
112
                clk_i_cml_1,
113
 
114
                // Clk & Rst
115
                clk, rst,
116
 
117
                // Internal CPU interface
118
                flagforw, flag_we, flag, cyforw, cy_we, carry,
119
                addrbase, addrofs, dat_i, alu_op, branch_op,
120
                epcr, eear, esr, except_started,
121
                to_wbmux, epcr_we, eear_we, esr_we, pc_we, sr_we, to_sr, sr,
122
                spr_dat_cfgr, spr_dat_rf, spr_dat_npc, spr_dat_ppc, spr_dat_mac,
123
 
124
                // From/to other RISC units
125
                spr_dat_pic, spr_dat_tt, spr_dat_pm,
126
                spr_dat_dmmu, spr_dat_immu, spr_dat_du,
127
                spr_addr, spr_dat_o, spr_cs, spr_we,
128
 
129
                du_addr, du_dat_du, du_read,
130
                du_write, du_dat_cpu
131
 
132
);
133
 
134
 
135
input clk_i_cml_1;
136
reg  flag_we_cml_1;
137
reg  cy_we_cml_1;
138
reg [ 32 - 1 : 0 ] dat_i_cml_1;
139
reg [ 3 - 1 : 0 ] branch_op_cml_1;
140
reg [ 32 - 1 : 0 ] epcr_cml_1;
141
reg [ 32 - 1 : 0 ] eear_cml_1;
142
reg [ 16 - 1 : 0 ] esr_cml_1;
143
reg  sr_we_cml_1;
144
reg [ 16 - 1 : 0 ] sr_cml_1;
145
reg [ 31 : 0 ] spr_addr_cml_1;
146
reg [ 31 : 0 ] spr_dat_o_cml_1;
147
reg [ 31 : 0 ] spr_cs_cml_1;
148
reg [ 32 - 1 : 0 ] du_dat_du_cml_1;
149
reg  du_read_cml_1;
150
reg  du_write_cml_1;
151
reg  write_spr_cml_1;
152
reg  read_spr_cml_1;
153
reg  npc_sel_cml_1;
154
reg  ppc_sel_cml_1;
155
reg  sr_sel_cml_1;
156
reg [ 4 - 1 : 0 ] sprs_op_cml_1;
157
 
158
 
159
 
160
parameter width = `OR1200_OPERAND_WIDTH;
161
 
162
//
163
// I/O Ports
164
//
165
 
166
//
167
// Internal CPU interface
168
//
169
input                           clk;            // Clock
170
input                           rst;            // Reset
171
input                           flagforw;       // From ALU
172
input                           flag_we;        // From ALU
173
output                          flag;           // SR[F]
174
input                           cyforw;         // From ALU
175
input                           cy_we;          // From ALU
176
output                          carry;          // SR[CY]
177
input   [width-1:0]              addrbase;       // SPR base address
178
input   [15:0]                   addrofs;        // SPR offset
179
input   [width-1:0]              dat_i;          // SPR write data
180
input   [`OR1200_ALUOP_WIDTH-1:0]        alu_op;         // ALU operation
181
input   [`OR1200_BRANCHOP_WIDTH-1:0]     branch_op;      // Branch operation
182
input   [width-1:0]              epcr;           // EPCR0
183
input   [width-1:0]              eear;           // EEAR0
184
input   [`OR1200_SR_WIDTH-1:0]   esr;            // ESR0
185
input                           except_started; // Exception was started
186
output  [width-1:0]              to_wbmux;       // For l.mfspr
187
output                          epcr_we;        // EPCR0 write enable
188
output                          eear_we;        // EEAR0 write enable
189
output                          esr_we;         // ESR0 write enable
190
output                          pc_we;          // PC write enable
191
output                          sr_we;          // Write enable SR
192
output  [`OR1200_SR_WIDTH-1:0]   to_sr;          // Data to SR
193
output  [`OR1200_SR_WIDTH-1:0]   sr;             // SR
194
input   [31:0]                   spr_dat_cfgr;   // Data from CFGR
195
input   [31:0]                   spr_dat_rf;     // Data from RF
196
input   [31:0]                   spr_dat_npc;    // Data from NPC
197
input   [31:0]                   spr_dat_ppc;    // Data from PPC   
198
input   [31:0]                   spr_dat_mac;    // Data from MAC
199
 
200
//
201
// To/from other RISC units
202
//
203
input   [31:0]                   spr_dat_pic;    // Data from PIC
204
input   [31:0]                   spr_dat_tt;     // Data from TT
205
input   [31:0]                   spr_dat_pm;     // Data from PM
206
input   [31:0]                   spr_dat_dmmu;   // Data from DMMU
207
input   [31:0]                   spr_dat_immu;   // Data from IMMU
208
input   [31:0]                   spr_dat_du;     // Data from DU
209
output  [31:0]                   spr_addr;       // SPR Address
210
output  [31:0]                   spr_dat_o;      // Data to unit
211
output  [31:0]                   spr_cs;         // Unit select
212
output                          spr_we;         // SPR write enable
213
 
214
//
215
// To/from Debug Unit
216
//
217
input   [width-1:0]              du_addr;        // Address
218
input   [width-1:0]              du_dat_du;      // Data from DU to SPRS
219
input                           du_read;        // Read qualifier
220
input                           du_write;       // Write qualifier
221
output  [width-1:0]              du_dat_cpu;     // Data from SPRS to DU
222
 
223
//
224
// Internal regs & wires
225
//
226
reg     [`OR1200_SR_WIDTH-1:0]           sr;             // SR
227
reg                             write_spr;      // Write SPR
228
reg                             read_spr;       // Read SPR
229
reg     [width-1:0]              to_wbmux;       // For l.mfspr
230
wire                            cfgr_sel;       // Select for cfg regs
231
wire                            rf_sel;         // Select for RF
232
wire                            npc_sel;        // Select for NPC
233
wire                            ppc_sel;        // Select for PPC
234
wire                            sr_sel;         // Select for SR        
235
wire                            epcr_sel;       // Select for EPCR0
236
wire                            eear_sel;       // Select for EEAR0
237
wire                            esr_sel;        // Select for ESR0
238
wire    [31:0]                   sys_data;       // Read data from system SPRs
239
wire                            du_access;      // Debug unit access
240
wire    [`OR1200_ALUOP_WIDTH-1:0]        sprs_op;        // ALU operation
241
reg     [31:0]                   unqualified_cs; // Unqualified chip selects
242
 
243
//
244
// Decide if it is debug unit access
245
//
246
assign du_access = du_read | du_write;
247
 
248
//
249
// Generate sprs opcode
250
//
251
assign sprs_op = du_write ? `OR1200_ALUOP_MTSR : du_read ? `OR1200_ALUOP_MFSR : alu_op;
252
 
253
//
254
// Generate SPR address from base address and offset
255
// OR from debug unit address
256
//
257
assign spr_addr = du_access ? du_addr : addrbase | {16'h0000, addrofs};
258
 
259
//
260
// SPR is written by debug unit or by l.mtspr
261
//
262
assign spr_dat_o = du_write ? du_dat_du : dat_i;
263
 
264
//
265
// debug unit data input:
266
//  - write into debug unit SPRs by debug unit itself
267
//  - read of SPRS by debug unit
268
//  - write into debug unit SPRs by l.mtspr
269
//
270
 
271
// SynEDA CoreMultiplier
272
// assignment(s): du_dat_cpu
273
// replace(s): dat_i, du_dat_du, du_read, du_write
274
assign du_dat_cpu = du_write_cml_1 ? du_dat_du_cml_1 : du_read_cml_1 ? to_wbmux : dat_i_cml_1;
275
 
276
//
277
// Write into SPRs when l.mtspr
278
//
279
assign spr_we = du_write | write_spr;
280
 
281
//
282
// Qualify chip selects
283
//
284
assign spr_cs = unqualified_cs & {32{read_spr | write_spr}};
285
 
286
//
287
// Decoding of groups
288
//
289
always @(spr_addr)
290
        case (spr_addr[`OR1200_SPR_GROUP_BITS]) // synopsys parallel_case
291
                `OR1200_SPR_GROUP_WIDTH'd00: unqualified_cs = 32'b00000000_00000000_00000000_00000001;
292
                `OR1200_SPR_GROUP_WIDTH'd01: unqualified_cs = 32'b00000000_00000000_00000000_00000010;
293
                `OR1200_SPR_GROUP_WIDTH'd02: unqualified_cs = 32'b00000000_00000000_00000000_00000100;
294
                `OR1200_SPR_GROUP_WIDTH'd03: unqualified_cs = 32'b00000000_00000000_00000000_00001000;
295
                `OR1200_SPR_GROUP_WIDTH'd04: unqualified_cs = 32'b00000000_00000000_00000000_00010000;
296
                `OR1200_SPR_GROUP_WIDTH'd05: unqualified_cs = 32'b00000000_00000000_00000000_00100000;
297
                `OR1200_SPR_GROUP_WIDTH'd06: unqualified_cs = 32'b00000000_00000000_00000000_01000000;
298
                `OR1200_SPR_GROUP_WIDTH'd07: unqualified_cs = 32'b00000000_00000000_00000000_10000000;
299
                `OR1200_SPR_GROUP_WIDTH'd08: unqualified_cs = 32'b00000000_00000000_00000001_00000000;
300
                `OR1200_SPR_GROUP_WIDTH'd09: unqualified_cs = 32'b00000000_00000000_00000010_00000000;
301
                `OR1200_SPR_GROUP_WIDTH'd10: unqualified_cs = 32'b00000000_00000000_00000100_00000000;
302
                `OR1200_SPR_GROUP_WIDTH'd11: unqualified_cs = 32'b00000000_00000000_00001000_00000000;
303
                `OR1200_SPR_GROUP_WIDTH'd12: unqualified_cs = 32'b00000000_00000000_00010000_00000000;
304
                `OR1200_SPR_GROUP_WIDTH'd13: unqualified_cs = 32'b00000000_00000000_00100000_00000000;
305
                `OR1200_SPR_GROUP_WIDTH'd14: unqualified_cs = 32'b00000000_00000000_01000000_00000000;
306
                `OR1200_SPR_GROUP_WIDTH'd15: unqualified_cs = 32'b00000000_00000000_10000000_00000000;
307
                `OR1200_SPR_GROUP_WIDTH'd16: unqualified_cs = 32'b00000000_00000001_00000000_00000000;
308
                `OR1200_SPR_GROUP_WIDTH'd17: unqualified_cs = 32'b00000000_00000010_00000000_00000000;
309
                `OR1200_SPR_GROUP_WIDTH'd18: unqualified_cs = 32'b00000000_00000100_00000000_00000000;
310
                `OR1200_SPR_GROUP_WIDTH'd19: unqualified_cs = 32'b00000000_00001000_00000000_00000000;
311
                `OR1200_SPR_GROUP_WIDTH'd20: unqualified_cs = 32'b00000000_00010000_00000000_00000000;
312
                `OR1200_SPR_GROUP_WIDTH'd21: unqualified_cs = 32'b00000000_00100000_00000000_00000000;
313
                `OR1200_SPR_GROUP_WIDTH'd22: unqualified_cs = 32'b00000000_01000000_00000000_00000000;
314
                `OR1200_SPR_GROUP_WIDTH'd23: unqualified_cs = 32'b00000000_10000000_00000000_00000000;
315
                `OR1200_SPR_GROUP_WIDTH'd24: unqualified_cs = 32'b00000001_00000000_00000000_00000000;
316
                `OR1200_SPR_GROUP_WIDTH'd25: unqualified_cs = 32'b00000010_00000000_00000000_00000000;
317
                `OR1200_SPR_GROUP_WIDTH'd26: unqualified_cs = 32'b00000100_00000000_00000000_00000000;
318
                `OR1200_SPR_GROUP_WIDTH'd27: unqualified_cs = 32'b00001000_00000000_00000000_00000000;
319
                `OR1200_SPR_GROUP_WIDTH'd28: unqualified_cs = 32'b00010000_00000000_00000000_00000000;
320
                `OR1200_SPR_GROUP_WIDTH'd29: unqualified_cs = 32'b00100000_00000000_00000000_00000000;
321
                `OR1200_SPR_GROUP_WIDTH'd30: unqualified_cs = 32'b01000000_00000000_00000000_00000000;
322
                `OR1200_SPR_GROUP_WIDTH'd31: unqualified_cs = 32'b10000000_00000000_00000000_00000000;
323
        endcase
324
 
325
//
326
// SPRs System Group
327
//
328
 
329
//
330
// What to write into SR
331
//
332
assign to_sr[`OR1200_SR_FO:`OR1200_SR_OV] =
333
                (branch_op_cml_1 == `OR1200_BRANCHOP_RFE) ? esr_cml_1[`OR1200_SR_FO:`OR1200_SR_OV] :
334
                (write_spr_cml_1 && sr_sel_cml_1) ? {1'b1, spr_dat_o_cml_1[`OR1200_SR_FO-1:`OR1200_SR_OV]}:
335
                sr_cml_1[`OR1200_SR_FO:`OR1200_SR_OV];
336
assign to_sr[`OR1200_SR_CY] =
337
                (branch_op_cml_1 == `OR1200_BRANCHOP_RFE) ? esr_cml_1[`OR1200_SR_CY] :
338
                cy_we_cml_1 ? cyforw :
339
                (write_spr_cml_1 && sr_sel_cml_1) ? spr_dat_o_cml_1[`OR1200_SR_CY] :
340
                sr_cml_1[`OR1200_SR_CY];
341
assign to_sr[`OR1200_SR_F] =
342
                (branch_op_cml_1 == `OR1200_BRANCHOP_RFE) ? esr_cml_1[`OR1200_SR_F] :
343
                flag_we_cml_1 ? flagforw :
344
                (write_spr_cml_1 && sr_sel_cml_1) ? spr_dat_o_cml_1[`OR1200_SR_F] :
345
                sr_cml_1[`OR1200_SR_F];
346
 
347
// SynEDA CoreMultiplier
348
// assignment(s): to_sr
349
// replace(s): flag_we, cy_we, branch_op, esr, sr, spr_dat_o, write_spr, sr_sel
350
assign to_sr[`OR1200_SR_CE:`OR1200_SR_SM] =
351
                (branch_op_cml_1 == `OR1200_BRANCHOP_RFE) ? esr_cml_1[`OR1200_SR_CE:`OR1200_SR_SM] :
352
                (write_spr_cml_1 && sr_sel_cml_1) ? spr_dat_o_cml_1[`OR1200_SR_CE:`OR1200_SR_SM]:
353
                sr_cml_1[`OR1200_SR_CE:`OR1200_SR_SM];
354
 
355
//
356
// Selects for system SPRs
357
//
358
 
359
// SynEDA CoreMultiplier
360
// assignment(s): cfgr_sel
361
// replace(s): spr_addr, spr_cs
362
assign cfgr_sel = (spr_cs_cml_1[`OR1200_SPR_GROUP_SYS] && (spr_addr_cml_1[10:4] == `OR1200_SPR_CFGR));
363
 
364
// SynEDA CoreMultiplier
365
// assignment(s): rf_sel
366
// replace(s): spr_addr, spr_cs
367
assign rf_sel = (spr_cs_cml_1[`OR1200_SPR_GROUP_SYS] && (spr_addr_cml_1[10:5] == `OR1200_SPR_RF));
368
assign npc_sel = (spr_cs[`OR1200_SPR_GROUP_SYS] && (spr_addr[10:0] == `OR1200_SPR_NPC));
369
assign ppc_sel = (spr_cs[`OR1200_SPR_GROUP_SYS] && (spr_addr[10:0] == `OR1200_SPR_PPC));
370
assign sr_sel = (spr_cs[`OR1200_SPR_GROUP_SYS] && (spr_addr[10:0] == `OR1200_SPR_SR));
371
 
372
// SynEDA CoreMultiplier
373
// assignment(s): epcr_sel
374
// replace(s): spr_addr, spr_cs
375
assign epcr_sel = (spr_cs_cml_1[`OR1200_SPR_GROUP_SYS] && (spr_addr_cml_1[10:0] == `OR1200_SPR_EPCR));
376
 
377
// SynEDA CoreMultiplier
378
// assignment(s): eear_sel
379
// replace(s): spr_addr, spr_cs
380
assign eear_sel = (spr_cs_cml_1[`OR1200_SPR_GROUP_SYS] && (spr_addr_cml_1[10:0] == `OR1200_SPR_EEAR));
381
 
382
// SynEDA CoreMultiplier
383
// assignment(s): esr_sel
384
// replace(s): spr_addr, spr_cs
385
assign esr_sel = (spr_cs_cml_1[`OR1200_SPR_GROUP_SYS] && (spr_addr_cml_1[10:0] == `OR1200_SPR_ESR));
386
 
387
//
388
// Write enables for system SPRs
389
//
390
assign sr_we = (write_spr && sr_sel) | (branch_op == `OR1200_BRANCHOP_RFE) | flag_we | cy_we;
391
assign pc_we = (write_spr && (npc_sel | ppc_sel));
392
 
393
// SynEDA CoreMultiplier
394
// assignment(s): epcr_we
395
// replace(s): write_spr
396
assign epcr_we = (write_spr_cml_1 && epcr_sel);
397
 
398
// SynEDA CoreMultiplier
399
// assignment(s): eear_we
400
// replace(s): write_spr
401
assign eear_we = (write_spr_cml_1 && eear_sel);
402
 
403
// SynEDA CoreMultiplier
404
// assignment(s): esr_we
405
// replace(s): write_spr
406
assign esr_we = (write_spr_cml_1 && esr_sel);
407
 
408
//
409
// Output from system SPRs
410
//
411
//assign sys_data = (spr_dat_cfgr & {32{read_spr & cfgr_sel}}) |
412
//                (spr_dat_rf & {32{read_spr & rf_sel}}) |
413
//                (spr_dat_npc & {32{read_spr & npc_sel}}) |
414
//                (spr_dat_ppc & {32{read_spr & ppc_sel}}) |
415
//                ({{32-`OR1200_SR_WIDTH{1'b0}},sr} & {32{read_spr & sr_sel}}) |
416
//                (epcr & {32{read_spr & epcr_sel}}) |
417
//                (eear & {32{read_spr & eear_sel}}) |
418
//                ({{32-`OR1200_SR_WIDTH{1'b0}},esr} & {32{read_spr & esr_sel}});
419
 
420
 
421
wire [31:0] read_spr_cfgr_sel_32;
422
wire [31:0] read_spr_rf_sel_32;
423
wire [31:0] read_spr_npc_sel_32;
424
wire [31:0] read_spr_ppc_sel_32;
425
wire [31:0] read_spr_sr_sel_32;
426
wire [31:0] read_spr_epcr_sel_32;
427
wire [31:0] read_spr_eear_sel_32;
428
wire [31:0] read_spr_esr_sel_32;
429
wire [31:0] sr_32;
430
wire [31:0] esr_32;
431
 
432
// SynEDA CoreMultiplier
433
// assignment(s): read_spr_cfgr_sel_32
434
// replace(s): read_spr
435
assign read_spr_cfgr_sel_32 = {32{read_spr_cml_1 & cfgr_sel}};
436
 
437
// SynEDA CoreMultiplier
438
// assignment(s): read_spr_rf_sel_32
439
// replace(s): read_spr
440
assign read_spr_rf_sel_32 = {32{read_spr_cml_1 & rf_sel}};
441
 
442
// SynEDA CoreMultiplier
443
// assignment(s): read_spr_npc_sel_32
444
// replace(s): read_spr, npc_sel
445
assign read_spr_npc_sel_32 = {32{read_spr_cml_1 & npc_sel_cml_1}};
446
 
447
// SynEDA CoreMultiplier
448
// assignment(s): read_spr_ppc_sel_32
449
// replace(s): read_spr, ppc_sel
450
assign read_spr_ppc_sel_32 = {32{read_spr_cml_1 & ppc_sel_cml_1}};
451
 
452
// SynEDA CoreMultiplier
453
// assignment(s): read_spr_sr_sel_32
454
// replace(s): read_spr, sr_sel
455
assign read_spr_sr_sel_32 = {32{read_spr_cml_1 & sr_sel_cml_1}};
456
 
457
// SynEDA CoreMultiplier
458
// assignment(s): read_spr_epcr_sel_32
459
// replace(s): read_spr
460
assign read_spr_epcr_sel_32 = {32{read_spr_cml_1 & epcr_sel}};
461
 
462
// SynEDA CoreMultiplier
463
// assignment(s): read_spr_eear_sel_32
464
// replace(s): read_spr
465
assign read_spr_eear_sel_32 = {32{read_spr_cml_1 & eear_sel}};
466
 
467
// SynEDA CoreMultiplier
468
// assignment(s): read_spr_esr_sel_32
469
// replace(s): read_spr
470
assign read_spr_esr_sel_32 = {32{read_spr_cml_1 & esr_sel}};
471
 
472
// SynEDA CoreMultiplier
473
// assignment(s): sr_32
474
// replace(s): sr
475
assign sr_32 = {{32-`OR1200_SR_WIDTH{1'b0}},sr_cml_1};
476
 
477
// SynEDA CoreMultiplier
478
// assignment(s): esr_32
479
// replace(s): esr
480
assign esr_32 = {{32-`OR1200_SR_WIDTH{1'b0}},esr_cml_1};
481
 
482
 
483
// SynEDA CoreMultiplier
484
// assignment(s): sys_data
485
// replace(s): epcr, eear
486
assign sys_data = (spr_dat_cfgr & read_spr_cfgr_sel_32) |
487
                  (spr_dat_rf & read_spr_rf_sel_32) |
488
                  (spr_dat_npc & read_spr_npc_sel_32) |
489
                  (spr_dat_ppc & read_spr_ppc_sel_32) |
490
                  (sr_32 & read_spr_sr_sel_32) |
491
                  (epcr_cml_1 & read_spr_epcr_sel_32) |
492
                  (eear_cml_1 & read_spr_eear_sel_32) |
493
                  (esr_32 & read_spr_esr_sel_32);
494
 
495
 
496
//
497
// Flag alias
498
//
499
assign flag = sr[`OR1200_SR_F];
500
 
501
//
502
// Carry alias
503
//
504
assign carry = sr[`OR1200_SR_CY];
505
 
506
//
507
// Supervision register
508
//
509
 
510
// SynEDA CoreMultiplier
511
// assignment(s): sr
512
// replace(s): sr_we, sr
513
always @(posedge clk or posedge rst)
514
        if (rst)
515
                sr <= #1 {1'b1, `OR1200_SR_EPH_DEF, {`OR1200_SR_WIDTH-3{1'b0}}, 1'b1};
516
        else begin  sr <= sr_cml_1; if (except_started) begin
517
                sr[`OR1200_SR_SM]  <= #1 1'b1;
518
                sr[`OR1200_SR_TEE] <= #1 1'b0;
519
                sr[`OR1200_SR_IEE] <= #1 1'b0;
520
                sr[`OR1200_SR_DME] <= #1 1'b0;
521
                sr[`OR1200_SR_IME] <= #1 1'b0;
522
        end
523
        else if (sr_we_cml_1)
524
                sr <= #1 to_sr[`OR1200_SR_WIDTH-1:0]; end
525
 
526
//
527
// MTSPR/MFSPR interface
528
//
529
always @(sprs_op or spr_addr or sys_data or spr_dat_mac or spr_dat_pic or spr_dat_pm or
530
        spr_dat_dmmu or spr_dat_immu or spr_dat_du or spr_dat_tt) begin
531
        case (sprs_op)  // synopsys parallel_case
532
                `OR1200_ALUOP_MTSR : begin
533
                        write_spr = 1'b1;
534
                end
535
                `OR1200_ALUOP_MFSR : begin
536
                        write_spr = 1'b0;
537
                end
538
                default : begin
539
                        write_spr = 1'b0;
540
                end
541
        endcase
542
end
543
 
544
always @(sprs_op or spr_addr or sys_data or spr_dat_mac or spr_dat_pic or spr_dat_pm or
545
        spr_dat_dmmu or spr_dat_immu or spr_dat_du or spr_dat_tt) begin
546
        case (sprs_op)  // synopsys parallel_case
547
                `OR1200_ALUOP_MTSR : begin
548
                        read_spr = 1'b0;
549
                end
550
                `OR1200_ALUOP_MFSR : begin
551
                        read_spr = 1'b1;
552
                end
553
                default : begin
554
                        read_spr = 1'b0;
555
                end
556
        endcase
557
end
558
 
559
 
560
// SynEDA CoreMultiplier
561
// assignment(s): to_wbmux
562
// replace(s): spr_addr, sprs_op
563
always @(sprs_op_cml_1 or spr_addr_cml_1 or sys_data or spr_dat_mac or spr_dat_pic or spr_dat_pm or
564
        spr_dat_dmmu or spr_dat_immu or spr_dat_du or spr_dat_tt) begin
565
        case (sprs_op_cml_1)    // synopsys parallel_case
566
                `OR1200_ALUOP_MTSR : begin
567
                        to_wbmux = 32'b0;
568
                end
569
                `OR1200_ALUOP_MFSR : begin
570
                        casex (spr_addr_cml_1[`OR1200_SPR_GROUP_BITS]) // synopsys parallel_case
571
                                `OR1200_SPR_GROUP_TT:
572
                                        to_wbmux = spr_dat_tt;
573
                                `OR1200_SPR_GROUP_PIC:
574
                                        to_wbmux = spr_dat_pic;
575
                                `OR1200_SPR_GROUP_PM:
576
                                        to_wbmux = spr_dat_pm;
577
                                `OR1200_SPR_GROUP_DMMU:
578
                                        to_wbmux = spr_dat_dmmu;
579
                                `OR1200_SPR_GROUP_IMMU:
580
                                        to_wbmux = spr_dat_immu;
581
                                `OR1200_SPR_GROUP_MAC:
582
                                        to_wbmux = spr_dat_mac;
583
                                `OR1200_SPR_GROUP_DU:
584
                                        to_wbmux = spr_dat_du;
585
                                `OR1200_SPR_GROUP_SYS:
586
                                        to_wbmux = sys_data;
587
                                default:
588
                                        to_wbmux = 32'b0;
589
                        endcase
590
                end
591
                default : begin
592
                        to_wbmux = 32'b0;
593
                end
594
        endcase
595
end
596
 
597
 
598
always @ (posedge clk_i_cml_1) begin
599
flag_we_cml_1 <= flag_we;
600
cy_we_cml_1 <= cy_we;
601
dat_i_cml_1 <= dat_i;
602
branch_op_cml_1 <= branch_op;
603
epcr_cml_1 <= epcr;
604
eear_cml_1 <= eear;
605
esr_cml_1 <= esr;
606
sr_we_cml_1 <= sr_we;
607
sr_cml_1 <= sr;
608
spr_addr_cml_1 <= spr_addr;
609
spr_dat_o_cml_1 <= spr_dat_o;
610
spr_cs_cml_1 <= spr_cs;
611
du_dat_du_cml_1 <= du_dat_du;
612
du_read_cml_1 <= du_read;
613
du_write_cml_1 <= du_write;
614
write_spr_cml_1 <= write_spr;
615
read_spr_cml_1 <= read_spr;
616
npc_sel_cml_1 <= npc_sel;
617
ppc_sel_cml_1 <= ppc_sel;
618
sr_sel_cml_1 <= sr_sel;
619
sprs_op_cml_1 <= sprs_op;
620
end
621
endmodule
622
 

powered by: WebSVN 2.1.0

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