| 1 |
504 |
lampret |
//////////////////////////////////////////////////////////////////////
|
| 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 |
1220 |
simons |
// Revision 1.9 2002/09/07 05:42:02 lampret
|
| 48 |
|
|
// Added optional SR[CY]. Added define to enable additional (compare) flag modifiers. Defines are OR1200_IMPL_ADDC and OR1200_ADDITIONAL_FLAG_MODIFIERS.
|
| 49 |
|
|
//
|
| 50 |
1032 |
lampret |
// Revision 1.8 2002/08/28 01:44:25 lampret
|
| 51 |
|
|
// Removed some commented RTL. Fixed SR/ESR flag bug.
|
| 52 |
|
|
//
|
| 53 |
1011 |
lampret |
// Revision 1.7 2002/03/29 15:16:56 lampret
|
| 54 |
|
|
// Some of the warnings fixed.
|
| 55 |
|
|
//
|
| 56 |
788 |
lampret |
// Revision 1.6 2002/03/11 01:26:57 lampret
|
| 57 |
|
|
// Changed generation of SPR address. Now it is ORed from base and offset instead of a sum.
|
| 58 |
|
|
//
|
| 59 |
736 |
lampret |
// Revision 1.5 2002/02/01 19:56:54 lampret
|
| 60 |
|
|
// Fixed combinational loops.
|
| 61 |
|
|
//
|
| 62 |
636 |
lampret |
// Revision 1.4 2002/01/23 07:52:36 lampret
|
| 63 |
|
|
// 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.
|
| 64 |
|
|
//
|
| 65 |
610 |
lampret |
// Revision 1.3 2002/01/19 09:27:49 lampret
|
| 66 |
|
|
// SR[TEE] should be zero after reset.
|
| 67 |
|
|
//
|
| 68 |
596 |
lampret |
// Revision 1.2 2002/01/18 07:56:00 lampret
|
| 69 |
|
|
// No more low/high priority interrupts (PICPR removed). Added tick timer exception. Added exception prefix (SR[EPH]). Fixed single-step bug whenreading NPC.
|
| 70 |
|
|
//
|
| 71 |
589 |
lampret |
// Revision 1.1 2002/01/03 08:16:15 lampret
|
| 72 |
|
|
// New prefixes for RTL files, prefixed module names. Updated cache controllers and MMUs.
|
| 73 |
|
|
//
|
| 74 |
504 |
lampret |
// Revision 1.12 2001/11/23 21:42:31 simons
|
| 75 |
|
|
// Program counter divided to PPC and NPC.
|
| 76 |
|
|
//
|
| 77 |
|
|
// Revision 1.11 2001/11/23 08:38:51 lampret
|
| 78 |
|
|
// Changed DSR/DRR behavior and exception detection.
|
| 79 |
|
|
//
|
| 80 |
|
|
// Revision 1.10 2001/11/12 01:45:41 lampret
|
| 81 |
|
|
// Moved flag bit into SR. Changed RF enable from constant enable to dynamic enable for read ports.
|
| 82 |
|
|
//
|
| 83 |
|
|
// Revision 1.9 2001/10/21 17:57:16 lampret
|
| 84 |
|
|
// 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.
|
| 85 |
|
|
//
|
| 86 |
|
|
// Revision 1.8 2001/10/14 13:12:10 lampret
|
| 87 |
|
|
// MP3 version.
|
| 88 |
|
|
//
|
| 89 |
|
|
// Revision 1.1.1.1 2001/10/06 10:18:36 igorm
|
| 90 |
|
|
// no message
|
| 91 |
|
|
//
|
| 92 |
|
|
// Revision 1.3 2001/08/13 03:36:20 lampret
|
| 93 |
|
|
// Added cfg regs. Moved all defines into one defines.v file. More cleanup.
|
| 94 |
|
|
//
|
| 95 |
|
|
// Revision 1.2 2001/08/09 13:39:33 lampret
|
| 96 |
|
|
// Major clean-up.
|
| 97 |
|
|
//
|
| 98 |
|
|
// Revision 1.1 2001/07/20 00:46:21 lampret
|
| 99 |
|
|
// Development version of RTL. Libraries are missing.
|
| 100 |
|
|
//
|
| 101 |
|
|
//
|
| 102 |
|
|
|
| 103 |
|
|
// synopsys translate_off
|
| 104 |
|
|
`include "timescale.v"
|
| 105 |
|
|
// synopsys translate_on
|
| 106 |
|
|
`include "or1200_defines.v"
|
| 107 |
|
|
|
| 108 |
|
|
module or1200_sprs(
|
| 109 |
|
|
// Clk & Rst
|
| 110 |
|
|
clk, rst,
|
| 111 |
|
|
|
| 112 |
|
|
// Internal CPU interface
|
| 113 |
1032 |
lampret |
flagforw, flag_we, flag, cyforw, cy_we, carry,
|
| 114 |
|
|
addrbase, addrofs, dat_i, alu_op, branch_op,
|
| 115 |
788 |
lampret |
epcr, eear, esr, except_started,
|
| 116 |
1011 |
lampret |
to_wbmux, epcr_we, eear_we, esr_we, pc_we, sr_we, to_sr, sr,
|
| 117 |
504 |
lampret |
spr_dat_cfgr, spr_dat_rf, spr_dat_npc, spr_dat_ppc, spr_dat_mac,
|
| 118 |
|
|
|
| 119 |
|
|
// From/to other RISC units
|
| 120 |
|
|
spr_dat_pic, spr_dat_tt, spr_dat_pm,
|
| 121 |
|
|
spr_dat_dmmu, spr_dat_immu, spr_dat_du,
|
| 122 |
636 |
lampret |
spr_addr, spr_dat_o, spr_cs, spr_we,
|
| 123 |
504 |
lampret |
|
| 124 |
|
|
du_addr, du_dat_du, du_read,
|
| 125 |
636 |
lampret |
du_write, du_dat_cpu
|
| 126 |
504 |
lampret |
|
| 127 |
|
|
);
|
| 128 |
|
|
|
| 129 |
|
|
parameter width = `OR1200_OPERAND_WIDTH;
|
| 130 |
|
|
|
| 131 |
|
|
//
|
| 132 |
|
|
// I/O Ports
|
| 133 |
|
|
//
|
| 134 |
|
|
|
| 135 |
|
|
//
|
| 136 |
|
|
// Internal CPU interface
|
| 137 |
|
|
//
|
| 138 |
|
|
input clk; // Clock
|
| 139 |
|
|
input rst; // Reset
|
| 140 |
|
|
input flagforw; // From ALU
|
| 141 |
|
|
input flag_we; // From ALU
|
| 142 |
1032 |
lampret |
output flag; // SR[F]
|
| 143 |
|
|
input cyforw; // From ALU
|
| 144 |
|
|
input cy_we; // From ALU
|
| 145 |
|
|
output carry; // SR[CY]
|
| 146 |
504 |
lampret |
input [width-1:0] addrbase; // SPR base address
|
| 147 |
|
|
input [15:0] addrofs; // SPR offset
|
| 148 |
|
|
input [width-1:0] dat_i; // SPR write data
|
| 149 |
|
|
input [`OR1200_ALUOP_WIDTH-1:0] alu_op; // ALU operation
|
| 150 |
|
|
input [`OR1200_BRANCHOP_WIDTH-1:0] branch_op; // Branch operation
|
| 151 |
|
|
input [width-1:0] epcr; // EPCR0
|
| 152 |
|
|
input [width-1:0] eear; // EEAR0
|
| 153 |
|
|
input [`OR1200_SR_WIDTH-1:0] esr; // ESR0
|
| 154 |
|
|
input except_started; // Exception was started
|
| 155 |
|
|
output [width-1:0] to_wbmux; // For l.mfspr
|
| 156 |
|
|
output epcr_we; // EPCR0 write enable
|
| 157 |
|
|
output eear_we; // EEAR0 write enable
|
| 158 |
|
|
output esr_we; // ESR0 write enable
|
| 159 |
|
|
output pc_we; // PC write enable
|
| 160 |
1011 |
lampret |
output sr_we; // Write enable SR
|
| 161 |
|
|
output [`OR1200_SR_WIDTH-1:0] to_sr; // Data to SR
|
| 162 |
|
|
output [`OR1200_SR_WIDTH-1:0] sr; // SR
|
| 163 |
504 |
lampret |
input [31:0] spr_dat_cfgr; // Data from CFGR
|
| 164 |
|
|
input [31:0] spr_dat_rf; // Data from RF
|
| 165 |
|
|
input [31:0] spr_dat_npc; // Data from NPC
|
| 166 |
|
|
input [31:0] spr_dat_ppc; // Data from PPC
|
| 167 |
|
|
input [31:0] spr_dat_mac; // Data from MAC
|
| 168 |
|
|
|
| 169 |
|
|
//
|
| 170 |
|
|
// To/from other RISC units
|
| 171 |
|
|
//
|
| 172 |
|
|
input [31:0] spr_dat_pic; // Data from PIC
|
| 173 |
|
|
input [31:0] spr_dat_tt; // Data from TT
|
| 174 |
|
|
input [31:0] spr_dat_pm; // Data from PM
|
| 175 |
|
|
input [31:0] spr_dat_dmmu; // Data from DMMU
|
| 176 |
|
|
input [31:0] spr_dat_immu; // Data from IMMU
|
| 177 |
|
|
input [31:0] spr_dat_du; // Data from DU
|
| 178 |
|
|
output [31:0] spr_addr; // SPR Address
|
| 179 |
636 |
lampret |
output [31:0] spr_dat_o; // Data to unit
|
| 180 |
504 |
lampret |
output [31:0] spr_cs; // Unit select
|
| 181 |
|
|
output spr_we; // SPR write enable
|
| 182 |
|
|
|
| 183 |
|
|
//
|
| 184 |
|
|
// To/from Debug Unit
|
| 185 |
|
|
//
|
| 186 |
|
|
input [width-1:0] du_addr; // Address
|
| 187 |
|
|
input [width-1:0] du_dat_du; // Data from DU to SPRS
|
| 188 |
|
|
input du_read; // Read qualifier
|
| 189 |
|
|
input du_write; // Write qualifier
|
| 190 |
636 |
lampret |
output [width-1:0] du_dat_cpu; // Data from SPRS to DU
|
| 191 |
504 |
lampret |
|
| 192 |
|
|
//
|
| 193 |
|
|
// Internal regs & wires
|
| 194 |
|
|
//
|
| 195 |
|
|
reg [`OR1200_SR_WIDTH-1:0] sr; // SR
|
| 196 |
|
|
reg write_spr; // Write SPR
|
| 197 |
|
|
reg read_spr; // Read SPR
|
| 198 |
|
|
reg [width-1:0] to_wbmux; // For l.mfspr
|
| 199 |
|
|
wire cfgr_sel; // Select for cfg regs
|
| 200 |
|
|
wire rf_sel; // Select for RF
|
| 201 |
|
|
wire npc_sel; // Select for NPC
|
| 202 |
|
|
wire ppc_sel; // Select for PPC
|
| 203 |
|
|
wire sr_sel; // Select for SR
|
| 204 |
|
|
wire epcr_sel; // Select for EPCR0
|
| 205 |
|
|
wire eear_sel; // Select for EEAR0
|
| 206 |
|
|
wire esr_sel; // Select for ESR0
|
| 207 |
|
|
wire [31:0] sys_data; // Read data from system SPRs
|
| 208 |
|
|
wire du_access; // Debug unit access
|
| 209 |
|
|
wire [`OR1200_ALUOP_WIDTH-1:0] sprs_op; // ALU operation
|
| 210 |
|
|
reg [31:0] unqualified_cs; // Unqualified chip selects
|
| 211 |
|
|
|
| 212 |
|
|
//
|
| 213 |
|
|
// Decide if it is debug unit access
|
| 214 |
|
|
//
|
| 215 |
|
|
assign du_access = du_read | du_write;
|
| 216 |
|
|
|
| 217 |
|
|
//
|
| 218 |
|
|
// Generate sprs opcode
|
| 219 |
|
|
//
|
| 220 |
|
|
assign sprs_op = du_write ? `OR1200_ALUOP_MTSR : du_read ? `OR1200_ALUOP_MFSR : alu_op;
|
| 221 |
|
|
|
| 222 |
|
|
//
|
| 223 |
|
|
// Generate SPR address from base address and offset
|
| 224 |
|
|
// OR from debug unit address
|
| 225 |
|
|
//
|
| 226 |
736 |
lampret |
assign spr_addr = du_access ? du_addr : addrbase | {16'h0000, addrofs};
|
| 227 |
504 |
lampret |
|
| 228 |
|
|
//
|
| 229 |
636 |
lampret |
// SPR is written by debug unit or by l.mtspr
|
| 230 |
504 |
lampret |
//
|
| 231 |
636 |
lampret |
assign spr_dat_o = du_write ? du_dat_du : dat_i;
|
| 232 |
504 |
lampret |
|
| 233 |
|
|
//
|
| 234 |
636 |
lampret |
// debug unit data input:
|
| 235 |
|
|
// - write into debug unit SPRs by debug unit itself
|
| 236 |
|
|
// - read of SPRS by debug unit
|
| 237 |
|
|
// - write into debug unit SPRs by l.mtspr
|
| 238 |
|
|
//
|
| 239 |
|
|
assign du_dat_cpu = du_write ? du_dat_du : du_read ? to_wbmux : dat_i;
|
| 240 |
|
|
|
| 241 |
|
|
//
|
| 242 |
504 |
lampret |
// Write into SPRs when l.mtspr
|
| 243 |
|
|
//
|
| 244 |
|
|
assign spr_we = du_write | write_spr;
|
| 245 |
|
|
|
| 246 |
|
|
//
|
| 247 |
|
|
// Qualify chip selects
|
| 248 |
|
|
//
|
| 249 |
|
|
assign spr_cs = unqualified_cs & {32{read_spr | write_spr}};
|
| 250 |
|
|
|
| 251 |
|
|
//
|
| 252 |
|
|
// Decoding of groups
|
| 253 |
|
|
//
|
| 254 |
|
|
always @(spr_addr)
|
| 255 |
|
|
case (spr_addr[`OR1200_SPR_GROUP_BITS]) // synopsys parallel_case
|
| 256 |
|
|
`OR1200_SPR_GROUP_WIDTH'd00: unqualified_cs = 32'b00000000_00000000_00000000_00000001;
|
| 257 |
|
|
`OR1200_SPR_GROUP_WIDTH'd01: unqualified_cs = 32'b00000000_00000000_00000000_00000010;
|
| 258 |
|
|
`OR1200_SPR_GROUP_WIDTH'd02: unqualified_cs = 32'b00000000_00000000_00000000_00000100;
|
| 259 |
|
|
`OR1200_SPR_GROUP_WIDTH'd03: unqualified_cs = 32'b00000000_00000000_00000000_00001000;
|
| 260 |
|
|
`OR1200_SPR_GROUP_WIDTH'd04: unqualified_cs = 32'b00000000_00000000_00000000_00010000;
|
| 261 |
|
|
`OR1200_SPR_GROUP_WIDTH'd05: unqualified_cs = 32'b00000000_00000000_00000000_00100000;
|
| 262 |
|
|
`OR1200_SPR_GROUP_WIDTH'd06: unqualified_cs = 32'b00000000_00000000_00000000_01000000;
|
| 263 |
|
|
`OR1200_SPR_GROUP_WIDTH'd07: unqualified_cs = 32'b00000000_00000000_00000000_10000000;
|
| 264 |
|
|
`OR1200_SPR_GROUP_WIDTH'd08: unqualified_cs = 32'b00000000_00000000_00000001_00000000;
|
| 265 |
|
|
`OR1200_SPR_GROUP_WIDTH'd09: unqualified_cs = 32'b00000000_00000000_00000010_00000000;
|
| 266 |
|
|
`OR1200_SPR_GROUP_WIDTH'd10: unqualified_cs = 32'b00000000_00000000_00000100_00000000;
|
| 267 |
|
|
`OR1200_SPR_GROUP_WIDTH'd11: unqualified_cs = 32'b00000000_00000000_00001000_00000000;
|
| 268 |
|
|
`OR1200_SPR_GROUP_WIDTH'd12: unqualified_cs = 32'b00000000_00000000_00010000_00000000;
|
| 269 |
|
|
`OR1200_SPR_GROUP_WIDTH'd13: unqualified_cs = 32'b00000000_00000000_00100000_00000000;
|
| 270 |
|
|
`OR1200_SPR_GROUP_WIDTH'd14: unqualified_cs = 32'b00000000_00000000_01000000_00000000;
|
| 271 |
|
|
`OR1200_SPR_GROUP_WIDTH'd15: unqualified_cs = 32'b00000000_00000000_10000000_00000000;
|
| 272 |
|
|
`OR1200_SPR_GROUP_WIDTH'd16: unqualified_cs = 32'b00000000_00000001_00000000_00000000;
|
| 273 |
|
|
`OR1200_SPR_GROUP_WIDTH'd17: unqualified_cs = 32'b00000000_00000010_00000000_00000000;
|
| 274 |
|
|
`OR1200_SPR_GROUP_WIDTH'd18: unqualified_cs = 32'b00000000_00000100_00000000_00000000;
|
| 275 |
|
|
`OR1200_SPR_GROUP_WIDTH'd19: unqualified_cs = 32'b00000000_00001000_00000000_00000000;
|
| 276 |
|
|
`OR1200_SPR_GROUP_WIDTH'd20: unqualified_cs = 32'b00000000_00010000_00000000_00000000;
|
| 277 |
|
|
`OR1200_SPR_GROUP_WIDTH'd21: unqualified_cs = 32'b00000000_00100000_00000000_00000000;
|
| 278 |
|
|
`OR1200_SPR_GROUP_WIDTH'd22: unqualified_cs = 32'b00000000_01000000_00000000_00000000;
|
| 279 |
|
|
`OR1200_SPR_GROUP_WIDTH'd23: unqualified_cs = 32'b00000000_10000000_00000000_00000000;
|
| 280 |
|
|
`OR1200_SPR_GROUP_WIDTH'd24: unqualified_cs = 32'b00000001_00000000_00000000_00000000;
|
| 281 |
|
|
`OR1200_SPR_GROUP_WIDTH'd25: unqualified_cs = 32'b00000010_00000000_00000000_00000000;
|
| 282 |
|
|
`OR1200_SPR_GROUP_WIDTH'd26: unqualified_cs = 32'b00000100_00000000_00000000_00000000;
|
| 283 |
|
|
`OR1200_SPR_GROUP_WIDTH'd27: unqualified_cs = 32'b00001000_00000000_00000000_00000000;
|
| 284 |
|
|
`OR1200_SPR_GROUP_WIDTH'd28: unqualified_cs = 32'b00010000_00000000_00000000_00000000;
|
| 285 |
|
|
`OR1200_SPR_GROUP_WIDTH'd29: unqualified_cs = 32'b00100000_00000000_00000000_00000000;
|
| 286 |
|
|
`OR1200_SPR_GROUP_WIDTH'd30: unqualified_cs = 32'b01000000_00000000_00000000_00000000;
|
| 287 |
|
|
`OR1200_SPR_GROUP_WIDTH'd31: unqualified_cs = 32'b10000000_00000000_00000000_00000000;
|
| 288 |
|
|
endcase
|
| 289 |
|
|
|
| 290 |
|
|
//
|
| 291 |
|
|
// SPRs System Group
|
| 292 |
|
|
//
|
| 293 |
|
|
|
| 294 |
|
|
//
|
| 295 |
|
|
// What to write into SR
|
| 296 |
|
|
//
|
| 297 |
1032 |
lampret |
assign to_sr[`OR1200_SR_FO:`OR1200_SR_OV] =
|
| 298 |
|
|
(branch_op == `OR1200_BRANCHOP_RFE) ? esr[`OR1200_SR_FO:`OR1200_SR_OV] :
|
| 299 |
|
|
(write_spr && sr_sel) ? {1'b1, spr_dat_o[`OR1200_SR_FO-1:`OR1200_SR_OV]}:
|
| 300 |
|
|
sr[`OR1200_SR_FO:`OR1200_SR_OV];
|
| 301 |
|
|
assign to_sr[`OR1200_SR_CY] =
|
| 302 |
|
|
(branch_op == `OR1200_BRANCHOP_RFE) ? esr[`OR1200_SR_CY] :
|
| 303 |
|
|
cy_we ? cyforw :
|
| 304 |
|
|
(write_spr && sr_sel) ? spr_dat_o[`OR1200_SR_CY] :
|
| 305 |
|
|
sr[`OR1200_SR_CY];
|
| 306 |
|
|
assign to_sr[`OR1200_SR_F] =
|
| 307 |
|
|
(branch_op == `OR1200_BRANCHOP_RFE) ? esr[`OR1200_SR_F] :
|
| 308 |
|
|
flag_we ? flagforw :
|
| 309 |
|
|
(write_spr && sr_sel) ? spr_dat_o[`OR1200_SR_F] :
|
| 310 |
|
|
sr[`OR1200_SR_F];
|
| 311 |
|
|
assign to_sr[`OR1200_SR_CE:`OR1200_SR_SM] =
|
| 312 |
|
|
(branch_op == `OR1200_BRANCHOP_RFE) ? esr[`OR1200_SR_CE:`OR1200_SR_SM] :
|
| 313 |
|
|
(write_spr && sr_sel) ? spr_dat_o[`OR1200_SR_CE:`OR1200_SR_SM]:
|
| 314 |
|
|
sr[`OR1200_SR_CE:`OR1200_SR_SM];
|
| 315 |
504 |
lampret |
|
| 316 |
|
|
//
|
| 317 |
|
|
// Selects for system SPRs
|
| 318 |
|
|
//
|
| 319 |
|
|
assign cfgr_sel = (spr_cs[`OR1200_SPR_GROUP_SYS] && (spr_addr[10:4] == `OR1200_SPR_CFGR));
|
| 320 |
|
|
assign rf_sel = (spr_cs[`OR1200_SPR_GROUP_SYS] && (spr_addr[10:5] == `OR1200_SPR_RF));
|
| 321 |
|
|
assign npc_sel = (spr_cs[`OR1200_SPR_GROUP_SYS] && (spr_addr[10:0] == `OR1200_SPR_NPC));
|
| 322 |
|
|
assign ppc_sel = (spr_cs[`OR1200_SPR_GROUP_SYS] && (spr_addr[10:0] == `OR1200_SPR_PPC));
|
| 323 |
|
|
assign sr_sel = (spr_cs[`OR1200_SPR_GROUP_SYS] && (spr_addr[10:0] == `OR1200_SPR_SR));
|
| 324 |
|
|
assign epcr_sel = (spr_cs[`OR1200_SPR_GROUP_SYS] && (spr_addr[10:0] == `OR1200_SPR_EPCR));
|
| 325 |
|
|
assign eear_sel = (spr_cs[`OR1200_SPR_GROUP_SYS] && (spr_addr[10:0] == `OR1200_SPR_EEAR));
|
| 326 |
|
|
assign esr_sel = (spr_cs[`OR1200_SPR_GROUP_SYS] && (spr_addr[10:0] == `OR1200_SPR_ESR));
|
| 327 |
|
|
|
| 328 |
|
|
//
|
| 329 |
|
|
// Write enables for system SPRs
|
| 330 |
|
|
//
|
| 331 |
1032 |
lampret |
assign sr_we = (write_spr && sr_sel) | (branch_op == `OR1200_BRANCHOP_RFE) | flag_we | cy_we;
|
| 332 |
504 |
lampret |
assign pc_we = (write_spr && (npc_sel | ppc_sel));
|
| 333 |
|
|
assign epcr_we = (write_spr && epcr_sel);
|
| 334 |
|
|
assign eear_we = (write_spr && eear_sel);
|
| 335 |
|
|
assign esr_we = (write_spr && esr_sel);
|
| 336 |
|
|
|
| 337 |
|
|
//
|
| 338 |
|
|
// Output from system SPRs
|
| 339 |
|
|
//
|
| 340 |
|
|
assign sys_data = (spr_dat_cfgr & {32{read_spr & cfgr_sel}}) |
|
| 341 |
|
|
(spr_dat_rf & {32{read_spr & rf_sel}}) |
|
| 342 |
|
|
(spr_dat_npc & {32{read_spr & npc_sel}}) |
|
| 343 |
|
|
(spr_dat_ppc & {32{read_spr & ppc_sel}}) |
|
| 344 |
|
|
({{32-`OR1200_SR_WIDTH{1'b0}},sr} & {32{read_spr & sr_sel}}) |
|
| 345 |
|
|
(epcr & {32{read_spr & epcr_sel}}) |
|
| 346 |
|
|
(eear & {32{read_spr & eear_sel}}) |
|
| 347 |
|
|
({{32-`OR1200_SR_WIDTH{1'b0}},esr} & {32{read_spr & esr_sel}});
|
| 348 |
|
|
|
| 349 |
|
|
//
|
| 350 |
|
|
// Flag alias
|
| 351 |
|
|
//
|
| 352 |
|
|
assign flag = sr[`OR1200_SR_F];
|
| 353 |
|
|
|
| 354 |
|
|
//
|
| 355 |
1032 |
lampret |
// Carry alias
|
| 356 |
|
|
//
|
| 357 |
|
|
assign carry = sr[`OR1200_SR_CY];
|
| 358 |
|
|
|
| 359 |
|
|
//
|
| 360 |
504 |
lampret |
// Supervision register
|
| 361 |
|
|
//
|
| 362 |
|
|
always @(posedge clk or posedge rst)
|
| 363 |
|
|
if (rst)
|
| 364 |
1220 |
simons |
sr <= #1 {1'b1, `OR1200_SR_EPH_DEF, {`OR1200_SR_WIDTH-3{1'b0}}, 1'b1};
|
| 365 |
504 |
lampret |
else if (except_started) begin
|
| 366 |
1220 |
simons |
sr[`OR1200_SR_SM] <= #1 1'b1;
|
| 367 |
589 |
lampret |
sr[`OR1200_SR_TEE] <= #1 1'b0;
|
| 368 |
|
|
sr[`OR1200_SR_IEE] <= #1 1'b0;
|
| 369 |
504 |
lampret |
sr[`OR1200_SR_DME] <= #1 1'b0;
|
| 370 |
|
|
sr[`OR1200_SR_IME] <= #1 1'b0;
|
| 371 |
|
|
end
|
| 372 |
589 |
lampret |
else if (sr_we)
|
| 373 |
|
|
sr <= #1 to_sr[`OR1200_SR_WIDTH-1:0];
|
| 374 |
504 |
lampret |
|
| 375 |
|
|
//
|
| 376 |
|
|
// MTSPR/MFSPR interface
|
| 377 |
|
|
//
|
| 378 |
636 |
lampret |
always @(sprs_op or spr_addr or sys_data or spr_dat_mac or spr_dat_pic or spr_dat_pm or
|
| 379 |
504 |
lampret |
spr_dat_dmmu or spr_dat_immu or spr_dat_du or spr_dat_tt) begin
|
| 380 |
788 |
lampret |
case (sprs_op) // synopsys parallel_case
|
| 381 |
504 |
lampret |
`OR1200_ALUOP_MTSR : begin
|
| 382 |
|
|
write_spr = 1'b1;
|
| 383 |
|
|
read_spr = 1'b0;
|
| 384 |
|
|
to_wbmux = 32'b0;
|
| 385 |
|
|
end
|
| 386 |
|
|
`OR1200_ALUOP_MFSR : begin
|
| 387 |
788 |
lampret |
casex (spr_addr[`OR1200_SPR_GROUP_BITS]) // synopsys parallel_case
|
| 388 |
504 |
lampret |
`OR1200_SPR_GROUP_TT:
|
| 389 |
|
|
to_wbmux = spr_dat_tt;
|
| 390 |
|
|
`OR1200_SPR_GROUP_PIC:
|
| 391 |
|
|
to_wbmux = spr_dat_pic;
|
| 392 |
|
|
`OR1200_SPR_GROUP_PM:
|
| 393 |
|
|
to_wbmux = spr_dat_pm;
|
| 394 |
|
|
`OR1200_SPR_GROUP_DMMU:
|
| 395 |
|
|
to_wbmux = spr_dat_dmmu;
|
| 396 |
|
|
`OR1200_SPR_GROUP_IMMU:
|
| 397 |
|
|
to_wbmux = spr_dat_immu;
|
| 398 |
|
|
`OR1200_SPR_GROUP_MAC:
|
| 399 |
|
|
to_wbmux = spr_dat_mac;
|
| 400 |
|
|
`OR1200_SPR_GROUP_DU:
|
| 401 |
|
|
to_wbmux = spr_dat_du;
|
| 402 |
|
|
`OR1200_SPR_GROUP_SYS:
|
| 403 |
|
|
to_wbmux = sys_data;
|
| 404 |
|
|
default:
|
| 405 |
|
|
to_wbmux = 32'b0;
|
| 406 |
|
|
endcase
|
| 407 |
|
|
write_spr = 1'b0;
|
| 408 |
|
|
read_spr = 1'b1;
|
| 409 |
|
|
end
|
| 410 |
|
|
default : begin
|
| 411 |
|
|
write_spr = 1'b0;
|
| 412 |
|
|
read_spr = 1'b0;
|
| 413 |
|
|
to_wbmux = 32'b0;
|
| 414 |
|
|
end
|
| 415 |
|
|
endcase
|
| 416 |
|
|
end
|
| 417 |
|
|
|
| 418 |
|
|
endmodule
|