| 1 |
2 |
tobil |
//////////////////////////////////////////////////////////////////////
|
| 2 |
|
|
//// ////
|
| 3 |
|
|
//// OR1200's Instruction MMU top level ////
|
| 4 |
|
|
//// ////
|
| 5 |
|
|
//// This file is part of the OpenRISC 1200 project ////
|
| 6 |
|
|
//// http://www.opencores.org/cores/or1k/ ////
|
| 7 |
|
|
//// ////
|
| 8 |
|
|
//// Description ////
|
| 9 |
|
|
//// Instantiation of all IMMU blocks. ////
|
| 10 |
|
|
//// ////
|
| 11 |
|
|
//// To Do: ////
|
| 12 |
|
|
//// - cache inhibit ////
|
| 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.14 2004/04/05 08:29:57 lampret
|
| 48 |
|
|
// Merged branch_qmem into main tree.
|
| 49 |
|
|
//
|
| 50 |
|
|
// Revision 1.12.4.2 2003/12/09 11:46:48 simons
|
| 51 |
|
|
// Mbist nameing changed, Artisan ram instance signal names fixed, some synthesis waning fixed.
|
| 52 |
|
|
//
|
| 53 |
|
|
// Revision 1.12.4.1 2003/07/08 15:36:37 lampret
|
| 54 |
|
|
// Added embedded memory QMEM.
|
| 55 |
|
|
//
|
| 56 |
|
|
// Revision 1.12 2003/06/06 02:54:47 lampret
|
| 57 |
|
|
// When OR1200_NO_IMMU and OR1200_NO_IC are not both defined or undefined at the same time, results in a IC bug. Fixed.
|
| 58 |
|
|
//
|
| 59 |
|
|
// Revision 1.11 2002/10/17 20:04:40 lampret
|
| 60 |
|
|
// Added BIST scan. Special VS RAMs need to be used to implement BIST.
|
| 61 |
|
|
//
|
| 62 |
|
|
// Revision 1.10 2002/09/16 03:08:56 lampret
|
| 63 |
|
|
// Disabled cache inhibit atttribute.
|
| 64 |
|
|
//
|
| 65 |
|
|
// Revision 1.9 2002/08/18 19:54:17 lampret
|
| 66 |
|
|
// Added store buffer.
|
| 67 |
|
|
//
|
| 68 |
|
|
// Revision 1.8 2002/08/14 06:23:50 lampret
|
| 69 |
|
|
// Disabled ITLB translation when 1) doing access to ITLB SPRs or 2) crossing page. This modification was tested only with parts of IMMU test - remaining test cases needs to be run.
|
| 70 |
|
|
//
|
| 71 |
|
|
// Revision 1.7 2002/08/12 05:31:30 lampret
|
| 72 |
|
|
// Delayed external access at page crossing.
|
| 73 |
|
|
//
|
| 74 |
|
|
// Revision 1.6 2002/03/29 15:16:56 lampret
|
| 75 |
|
|
// Some of the warnings fixed.
|
| 76 |
|
|
//
|
| 77 |
|
|
// Revision 1.5 2002/02/11 04:33:17 lampret
|
| 78 |
|
|
// Speed optimizations (removed duplicate _cyc_ and _stb_). Fixed D/IMMU cache-inhibit attr.
|
| 79 |
|
|
//
|
| 80 |
|
|
// Revision 1.4 2002/02/01 19:56:54 lampret
|
| 81 |
|
|
// Fixed combinational loops.
|
| 82 |
|
|
//
|
| 83 |
|
|
// Revision 1.3 2002/01/28 01:16:00 lampret
|
| 84 |
|
|
// 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.
|
| 85 |
|
|
//
|
| 86 |
|
|
// Revision 1.2 2002/01/14 06:18:22 lampret
|
| 87 |
|
|
// Fixed mem2reg bug in FAST implementation. Updated debug unit to work with new genpc/if.
|
| 88 |
|
|
//
|
| 89 |
|
|
// Revision 1.1 2002/01/03 08:16:15 lampret
|
| 90 |
|
|
// New prefixes for RTL files, prefixed module names. Updated cache controllers and MMUs.
|
| 91 |
|
|
//
|
| 92 |
|
|
// Revision 1.6 2001/10/21 17:57:16 lampret
|
| 93 |
|
|
// 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.
|
| 94 |
|
|
//
|
| 95 |
|
|
// Revision 1.5 2001/10/14 13:12:09 lampret
|
| 96 |
|
|
// MP3 version.
|
| 97 |
|
|
//
|
| 98 |
|
|
// Revision 1.1.1.1 2001/10/06 10:18:36 igorm
|
| 99 |
|
|
// no message
|
| 100 |
|
|
//
|
| 101 |
|
|
// Revision 1.1 2001/08/17 08:03:35 lampret
|
| 102 |
|
|
// *** empty log message ***
|
| 103 |
|
|
//
|
| 104 |
|
|
// Revision 1.2 2001/07/22 03:31:53 lampret
|
| 105 |
|
|
// Fixed RAM's oen bug. Cache bypass under development.
|
| 106 |
|
|
//
|
| 107 |
|
|
// Revision 1.1 2001/07/20 00:46:03 lampret
|
| 108 |
|
|
// Development version of RTL. Libraries are missing.
|
| 109 |
|
|
//
|
| 110 |
|
|
//
|
| 111 |
|
|
|
| 112 |
|
|
// synopsys translate_off
|
| 113 |
|
|
`include "timescale.v"
|
| 114 |
|
|
// synopsys translate_on
|
| 115 |
|
|
`include "or1200_defines.v"
|
| 116 |
|
|
|
| 117 |
|
|
//
|
| 118 |
|
|
// Insn MMU
|
| 119 |
|
|
//
|
| 120 |
|
|
|
| 121 |
|
|
module or1200_immu_top_cm2(
|
| 122 |
|
|
clk_i_cml_1,
|
| 123 |
|
|
cmls,
|
| 124 |
|
|
|
| 125 |
|
|
// Rst and clk
|
| 126 |
|
|
clk, rst,
|
| 127 |
|
|
|
| 128 |
|
|
// CPU i/f
|
| 129 |
|
|
ic_en, immu_en, supv, icpu_adr_i, icpu_cycstb_i,
|
| 130 |
|
|
icpu_adr_o, icpu_tag_o, icpu_rty_o, icpu_err_o,
|
| 131 |
|
|
|
| 132 |
|
|
// SPR access
|
| 133 |
|
|
spr_cs, spr_write, spr_addr, spr_dat_i, spr_dat_o,
|
| 134 |
|
|
|
| 135 |
|
|
`ifdef OR1200_BIST
|
| 136 |
|
|
// RAM BIST
|
| 137 |
|
|
mbist_si_i, mbist_so_o, mbist_ctrl_i,
|
| 138 |
|
|
`endif
|
| 139 |
|
|
|
| 140 |
|
|
// QMEM i/f
|
| 141 |
|
|
qmemimmu_rty_i, qmemimmu_err_i, qmemimmu_tag_i, qmemimmu_adr_o, qmemimmu_cycstb_o, qmemimmu_ci_o
|
| 142 |
|
|
);
|
| 143 |
|
|
|
| 144 |
|
|
|
| 145 |
|
|
input clk_i_cml_1;
|
| 146 |
|
|
input cmls;
|
| 147 |
|
|
reg immu_en_cml_1;
|
| 148 |
|
|
reg supv_cml_1;
|
| 149 |
|
|
reg [ 32 - 1 : 0 ] icpu_adr_i_cml_1;
|
| 150 |
|
|
reg [ 32 - 1 : 0 ] icpu_adr_o_cml_1;
|
| 151 |
|
|
reg icpu_rty_o_cml_1;
|
| 152 |
|
|
reg spr_cs_cml_1;
|
| 153 |
|
|
reg qmemimmu_err_i_cml_1;
|
| 154 |
|
|
reg itlb_spr_access_cml_1;
|
| 155 |
|
|
reg [ 31 : 13 ] itlb_ppn_cml_1;
|
| 156 |
|
|
reg itlb_uxe_cml_1;
|
| 157 |
|
|
reg itlb_sxe_cml_1;
|
| 158 |
|
|
reg page_cross_cml_1;
|
| 159 |
|
|
reg [ 31 : 13 ] icpu_vpn_r_cml_1;
|
| 160 |
|
|
reg itlb_en_r_cml_1;
|
| 161 |
|
|
reg dis_spr_access_cml_1;
|
| 162 |
|
|
|
| 163 |
|
|
|
| 164 |
|
|
|
| 165 |
|
|
parameter dw = `OR1200_OPERAND_WIDTH;
|
| 166 |
|
|
parameter aw = `OR1200_OPERAND_WIDTH;
|
| 167 |
|
|
|
| 168 |
|
|
//
|
| 169 |
|
|
// I/O
|
| 170 |
|
|
//
|
| 171 |
|
|
|
| 172 |
|
|
//
|
| 173 |
|
|
// Clock and reset
|
| 174 |
|
|
//
|
| 175 |
|
|
input clk;
|
| 176 |
|
|
input rst;
|
| 177 |
|
|
|
| 178 |
|
|
//
|
| 179 |
|
|
// CPU I/F
|
| 180 |
|
|
//
|
| 181 |
|
|
input ic_en;
|
| 182 |
|
|
input immu_en;
|
| 183 |
|
|
input supv;
|
| 184 |
|
|
input [aw-1:0] icpu_adr_i;
|
| 185 |
|
|
input icpu_cycstb_i;
|
| 186 |
|
|
output [aw-1:0] icpu_adr_o;
|
| 187 |
|
|
output [3:0] icpu_tag_o;
|
| 188 |
|
|
output icpu_rty_o;
|
| 189 |
|
|
output icpu_err_o;
|
| 190 |
|
|
|
| 191 |
|
|
//
|
| 192 |
|
|
// SPR access
|
| 193 |
|
|
//
|
| 194 |
|
|
input spr_cs;
|
| 195 |
|
|
input spr_write;
|
| 196 |
|
|
input [aw-1:0] spr_addr;
|
| 197 |
|
|
input [31:0] spr_dat_i;
|
| 198 |
|
|
output [31:0] spr_dat_o;
|
| 199 |
|
|
|
| 200 |
|
|
`ifdef OR1200_BIST
|
| 201 |
|
|
//
|
| 202 |
|
|
// RAM BIST
|
| 203 |
|
|
//
|
| 204 |
|
|
input mbist_si_i;
|
| 205 |
|
|
input [`OR1200_MBIST_CTRL_WIDTH - 1:0] mbist_ctrl_i;
|
| 206 |
|
|
output mbist_so_o;
|
| 207 |
|
|
`endif
|
| 208 |
|
|
|
| 209 |
|
|
//
|
| 210 |
|
|
// IC I/F
|
| 211 |
|
|
//
|
| 212 |
|
|
input qmemimmu_rty_i;
|
| 213 |
|
|
input qmemimmu_err_i;
|
| 214 |
|
|
input [3:0] qmemimmu_tag_i;
|
| 215 |
|
|
output [aw-1:0] qmemimmu_adr_o;
|
| 216 |
|
|
output qmemimmu_cycstb_o;
|
| 217 |
|
|
output qmemimmu_ci_o;
|
| 218 |
|
|
|
| 219 |
|
|
//
|
| 220 |
|
|
// Internal wires and regs
|
| 221 |
|
|
//
|
| 222 |
|
|
wire itlb_spr_access;
|
| 223 |
|
|
wire [31:`OR1200_IMMU_PS] itlb_ppn;
|
| 224 |
|
|
wire itlb_hit;
|
| 225 |
|
|
wire itlb_uxe;
|
| 226 |
|
|
wire itlb_sxe;
|
| 227 |
|
|
wire [31:0] itlb_dat_o;
|
| 228 |
|
|
wire itlb_en;
|
| 229 |
|
|
wire itlb_ci;
|
| 230 |
|
|
wire itlb_done;
|
| 231 |
|
|
wire fault;
|
| 232 |
|
|
wire miss;
|
| 233 |
|
|
wire page_cross;
|
| 234 |
|
|
reg [31:0] icpu_adr_o;
|
| 235 |
|
|
reg [31:`OR1200_IMMU_PS] icpu_vpn_r;
|
| 236 |
|
|
`ifdef OR1200_NO_IMMU
|
| 237 |
|
|
`else
|
| 238 |
|
|
reg itlb_en_r;
|
| 239 |
|
|
reg dis_spr_access;
|
| 240 |
|
|
`endif
|
| 241 |
|
|
|
| 242 |
|
|
//
|
| 243 |
|
|
// Implemented bits inside match and translate registers
|
| 244 |
|
|
//
|
| 245 |
|
|
// itlbwYmrX: vpn 31-10 v 0
|
| 246 |
|
|
// itlbwYtrX: ppn 31-10 uxe 7 sxe 6
|
| 247 |
|
|
//
|
| 248 |
|
|
// itlb memory width:
|
| 249 |
|
|
// 19 bits for ppn
|
| 250 |
|
|
// 13 bits for vpn
|
| 251 |
|
|
// 1 bit for valid
|
| 252 |
|
|
// 2 bits for protection
|
| 253 |
|
|
// 1 bit for cache inhibit
|
| 254 |
|
|
|
| 255 |
|
|
//
|
| 256 |
|
|
// icpu_adr_o
|
| 257 |
|
|
//
|
| 258 |
|
|
`ifdef OR1200_REGISTERED_OUTPUTS
|
| 259 |
|
|
|
| 260 |
|
|
// SynEDA CoreMultiplier
|
| 261 |
|
|
// assignment(s): icpu_adr_o
|
| 262 |
|
|
// replace(s): icpu_adr_i, icpu_adr_o
|
| 263 |
|
|
always @(posedge rst or posedge clk)
|
| 264 |
|
|
if (rst)
|
| 265 |
|
|
icpu_adr_o <= #1 32'h0000_0100;
|
| 266 |
|
|
else begin icpu_adr_o <= icpu_adr_o_cml_1;
|
| 267 |
|
|
icpu_adr_o <= #1 icpu_adr_i_cml_1; end
|
| 268 |
|
|
`else
|
| 269 |
|
|
Unsupported !!!
|
| 270 |
|
|
`endif
|
| 271 |
|
|
|
| 272 |
|
|
//
|
| 273 |
|
|
// Page cross
|
| 274 |
|
|
//
|
| 275 |
|
|
// Asserted when CPU address crosses page boundary. Most of the time it is zero.
|
| 276 |
|
|
//
|
| 277 |
|
|
assign page_cross = icpu_adr_i[31:`OR1200_IMMU_PS] != icpu_vpn_r;
|
| 278 |
|
|
|
| 279 |
|
|
//
|
| 280 |
|
|
// Register icpu_adr_i's VPN for use when IMMU is not enabled but PPN is expected to come
|
| 281 |
|
|
// one clock cycle after offset part.
|
| 282 |
|
|
//
|
| 283 |
|
|
|
| 284 |
|
|
// SynEDA CoreMultiplier
|
| 285 |
|
|
// assignment(s): icpu_vpn_r
|
| 286 |
|
|
// replace(s): icpu_adr_i, icpu_vpn_r
|
| 287 |
|
|
always @(posedge clk or posedge rst)
|
| 288 |
|
|
if (rst)
|
| 289 |
|
|
icpu_vpn_r <= #1 {32-`OR1200_IMMU_PS{1'b0}};
|
| 290 |
|
|
else begin icpu_vpn_r <= icpu_vpn_r_cml_1;
|
| 291 |
|
|
icpu_vpn_r <= #1 icpu_adr_i_cml_1[31:`OR1200_IMMU_PS]; end
|
| 292 |
|
|
|
| 293 |
|
|
`ifdef OR1200_NO_IMMU
|
| 294 |
|
|
|
| 295 |
|
|
//
|
| 296 |
|
|
// Put all outputs in inactive state
|
| 297 |
|
|
//
|
| 298 |
|
|
assign spr_dat_o = 32'h00000000;
|
| 299 |
|
|
assign qmemimmu_adr_o = icpu_adr_i;
|
| 300 |
|
|
assign icpu_tag_o = qmemimmu_tag_i;
|
| 301 |
|
|
assign qmemimmu_cycstb_o = icpu_cycstb_i & ~page_cross;
|
| 302 |
|
|
assign icpu_rty_o = qmemimmu_rty_i;
|
| 303 |
|
|
assign icpu_err_o = qmemimmu_err_i;
|
| 304 |
|
|
assign qmemimmu_ci_o = `OR1200_IMMU_CI;
|
| 305 |
|
|
`ifdef OR1200_BIST
|
| 306 |
|
|
assign mbist_so_o = mbist_si_i;
|
| 307 |
|
|
`endif
|
| 308 |
|
|
`else
|
| 309 |
|
|
|
| 310 |
|
|
//
|
| 311 |
|
|
// ITLB SPR access
|
| 312 |
|
|
//
|
| 313 |
|
|
// 1200 - 12FF itlbmr w0
|
| 314 |
|
|
// 1200 - 123F itlbmr w0 [63:0]
|
| 315 |
|
|
//
|
| 316 |
|
|
// 1300 - 13FF itlbtr w0
|
| 317 |
|
|
// 1300 - 133F itlbtr w0 [63:0]
|
| 318 |
|
|
//
|
| 319 |
|
|
assign itlb_spr_access = spr_cs & ~dis_spr_access;
|
| 320 |
|
|
|
| 321 |
|
|
//
|
| 322 |
|
|
// Disable ITLB SPR access
|
| 323 |
|
|
//
|
| 324 |
|
|
// This flop is used to mask ITLB miss/fault exception
|
| 325 |
|
|
// during first clock cycle of accessing ITLB SPR. In
|
| 326 |
|
|
// subsequent clock cycles it is assumed that ITLB SPR
|
| 327 |
|
|
// access was accomplished and that normal instruction fetching
|
| 328 |
|
|
// can proceed.
|
| 329 |
|
|
//
|
| 330 |
|
|
// spr_cs sets dis_spr_access and icpu_rty_o clears it.
|
| 331 |
|
|
//
|
| 332 |
|
|
|
| 333 |
|
|
// SynEDA CoreMultiplier
|
| 334 |
|
|
// assignment(s): dis_spr_access
|
| 335 |
|
|
// replace(s): icpu_rty_o, spr_cs, dis_spr_access
|
| 336 |
|
|
always @(posedge clk or posedge rst)
|
| 337 |
|
|
if (rst)
|
| 338 |
|
|
dis_spr_access <= #1 1'b0;
|
| 339 |
|
|
else begin dis_spr_access <= dis_spr_access_cml_1; if (!icpu_rty_o_cml_1)
|
| 340 |
|
|
dis_spr_access <= #1 1'b0;
|
| 341 |
|
|
else if (spr_cs_cml_1)
|
| 342 |
|
|
dis_spr_access <= #1 1'b1; end
|
| 343 |
|
|
|
| 344 |
|
|
//
|
| 345 |
|
|
// Tags:
|
| 346 |
|
|
//
|
| 347 |
|
|
// OR1200_DTAG_TE - TLB miss Exception
|
| 348 |
|
|
// OR1200_DTAG_PE - Page fault Exception
|
| 349 |
|
|
//
|
| 350 |
|
|
assign icpu_tag_o = miss ? `OR1200_DTAG_TE : fault ? `OR1200_DTAG_PE : qmemimmu_tag_i;
|
| 351 |
|
|
|
| 352 |
|
|
//
|
| 353 |
|
|
// icpu_rty_o
|
| 354 |
|
|
//
|
| 355 |
|
|
// assign icpu_rty_o = !icpu_err_o & qmemimmu_rty_i;
|
| 356 |
|
|
assign icpu_rty_o = qmemimmu_rty_i | itlb_spr_access & immu_en;
|
| 357 |
|
|
|
| 358 |
|
|
//
|
| 359 |
|
|
// icpu_err_o
|
| 360 |
|
|
//
|
| 361 |
|
|
|
| 362 |
|
|
// SynEDA CoreMultiplier
|
| 363 |
|
|
// assignment(s): icpu_err_o
|
| 364 |
|
|
// replace(s): qmemimmu_err_i
|
| 365 |
|
|
assign icpu_err_o = miss | fault | qmemimmu_err_i_cml_1;
|
| 366 |
|
|
|
| 367 |
|
|
//
|
| 368 |
|
|
// Assert itlb_en_r after one clock cycle and when there is no
|
| 369 |
|
|
// ITLB SPR access
|
| 370 |
|
|
//
|
| 371 |
|
|
|
| 372 |
|
|
// SynEDA CoreMultiplier
|
| 373 |
|
|
// assignment(s): itlb_en_r
|
| 374 |
|
|
// replace(s): itlb_spr_access, itlb_en_r
|
| 375 |
|
|
always @(posedge clk or posedge rst)
|
| 376 |
|
|
if (rst)
|
| 377 |
|
|
itlb_en_r <= #1 1'b0;
|
| 378 |
|
|
else begin itlb_en_r <= itlb_en_r_cml_1;
|
| 379 |
|
|
itlb_en_r <= #1 itlb_en & ~itlb_spr_access_cml_1; end
|
| 380 |
|
|
|
| 381 |
|
|
//
|
| 382 |
|
|
// ITLB lookup successful
|
| 383 |
|
|
//
|
| 384 |
|
|
|
| 385 |
|
|
// SynEDA CoreMultiplier
|
| 386 |
|
|
// assignment(s): itlb_done
|
| 387 |
|
|
// replace(s): page_cross, itlb_en_r
|
| 388 |
|
|
assign itlb_done = itlb_en_r_cml_1 & ~page_cross_cml_1;
|
| 389 |
|
|
|
| 390 |
|
|
//
|
| 391 |
|
|
// Cut transfer if something goes wrong with translation. If IC is disabled,
|
| 392 |
|
|
// use delayed signals.
|
| 393 |
|
|
//
|
| 394 |
|
|
// assign qmemimmu_cycstb_o = (!ic_en & immu_en) ? ~(miss | fault) & icpu_cycstb_i & ~page_cross : (miss | fault) ? 1'b0 : icpu_cycstb_i & ~page_cross; // DL
|
| 395 |
|
|
|
| 396 |
|
|
// SynEDA CoreMultiplier
|
| 397 |
|
|
// assignment(s): qmemimmu_cycstb_o
|
| 398 |
|
|
// replace(s): immu_en, page_cross
|
| 399 |
|
|
assign qmemimmu_cycstb_o = immu_en_cml_1 ? ~(miss | fault) & icpu_cycstb_i & ~page_cross_cml_1 & itlb_done : icpu_cycstb_i & ~page_cross_cml_1;
|
| 400 |
|
|
|
| 401 |
|
|
//
|
| 402 |
|
|
// Cache Inhibit
|
| 403 |
|
|
//
|
| 404 |
|
|
// Cache inhibit is not really needed for instruction memory subsystem.
|
| 405 |
|
|
// If we would doq it, we would doq it like this.
|
| 406 |
|
|
// assign qmemimmu_ci_o = immu_en ? itlb_done & itlb_ci : `OR1200_IMMU_CI;
|
| 407 |
|
|
// However this causes a async combinational loop so we stick to
|
| 408 |
|
|
// no cache inhibit.
|
| 409 |
|
|
assign qmemimmu_ci_o = `OR1200_IMMU_CI;
|
| 410 |
|
|
|
| 411 |
|
|
|
| 412 |
|
|
//
|
| 413 |
|
|
// Physical address is either translated virtual address or
|
| 414 |
|
|
// simply equal when IMMU is disabled
|
| 415 |
|
|
//
|
| 416 |
|
|
|
| 417 |
|
|
// SynEDA CoreMultiplier
|
| 418 |
|
|
// assignment(s): qmemimmu_adr_o
|
| 419 |
|
|
// replace(s): icpu_adr_i, itlb_ppn, icpu_vpn_r
|
| 420 |
|
|
assign qmemimmu_adr_o = itlb_done ? {itlb_ppn_cml_1, icpu_adr_i_cml_1[`OR1200_IMMU_PS-1:0]} : {icpu_vpn_r_cml_1, icpu_adr_i_cml_1[`OR1200_IMMU_PS-1:0]}; // DL: immu_en
|
| 421 |
|
|
|
| 422 |
|
|
//
|
| 423 |
|
|
// Output to SPRS unit
|
| 424 |
|
|
//
|
| 425 |
|
|
|
| 426 |
|
|
// SynEDA CoreMultiplier
|
| 427 |
|
|
// assignment(s): spr_dat_o
|
| 428 |
|
|
// replace(s): spr_cs
|
| 429 |
|
|
assign spr_dat_o = spr_cs_cml_1 ? itlb_dat_o : 32'h00000000;
|
| 430 |
|
|
|
| 431 |
|
|
//
|
| 432 |
|
|
// Page fault exception logic
|
| 433 |
|
|
//
|
| 434 |
|
|
|
| 435 |
|
|
// SynEDA CoreMultiplier
|
| 436 |
|
|
// assignment(s): fault
|
| 437 |
|
|
// replace(s): supv, itlb_uxe, itlb_sxe
|
| 438 |
|
|
assign fault = itlb_done &
|
| 439 |
|
|
( (!supv_cml_1 & !itlb_uxe_cml_1) // Execute in user mode not enabled
|
| 440 |
|
|
|| (supv_cml_1 & !itlb_sxe_cml_1)); // Execute in supv mode not enabled
|
| 441 |
|
|
|
| 442 |
|
|
//
|
| 443 |
|
|
// TLB Miss exception logic
|
| 444 |
|
|
//
|
| 445 |
|
|
assign miss = itlb_done & !itlb_hit;
|
| 446 |
|
|
|
| 447 |
|
|
//
|
| 448 |
|
|
// ITLB Enable
|
| 449 |
|
|
//
|
| 450 |
|
|
|
| 451 |
|
|
// SynEDA CoreMultiplier
|
| 452 |
|
|
// assignment(s): itlb_en
|
| 453 |
|
|
// replace(s): immu_en
|
| 454 |
|
|
assign itlb_en = immu_en_cml_1 & icpu_cycstb_i;
|
| 455 |
|
|
|
| 456 |
|
|
//
|
| 457 |
|
|
// Instantiation of ITLB
|
| 458 |
|
|
//
|
| 459 |
|
|
or1200_immu_tlb_cm2 or1200_immu_tlb(
|
| 460 |
|
|
.clk_i_cml_1(clk_i_cml_1),
|
| 461 |
|
|
.cmls(cmls),
|
| 462 |
|
|
// Rst and clk
|
| 463 |
|
|
.clk(clk),
|
| 464 |
|
|
.rst(rst),
|
| 465 |
|
|
|
| 466 |
|
|
// I/F for translation
|
| 467 |
|
|
.tlb_en(itlb_en),
|
| 468 |
|
|
.vaddr(icpu_adr_i),
|
| 469 |
|
|
.hit(itlb_hit),
|
| 470 |
|
|
.ppn(itlb_ppn),
|
| 471 |
|
|
.uxe(itlb_uxe),
|
| 472 |
|
|
.sxe(itlb_sxe),
|
| 473 |
|
|
.ci(itlb_ci),
|
| 474 |
|
|
|
| 475 |
|
|
`ifdef OR1200_BIST
|
| 476 |
|
|
// RAM BIST
|
| 477 |
|
|
.mbist_si_i(mbist_si_i),
|
| 478 |
|
|
.mbist_so_o(mbist_so_o),
|
| 479 |
|
|
.mbist_ctrl_i(mbist_ctrl_i),
|
| 480 |
|
|
`endif
|
| 481 |
|
|
|
| 482 |
|
|
// SPR access
|
| 483 |
|
|
.spr_cs(itlb_spr_access),
|
| 484 |
|
|
.spr_write(spr_write),
|
| 485 |
|
|
.spr_addr(spr_addr),
|
| 486 |
|
|
.spr_dat_i(spr_dat_i),
|
| 487 |
|
|
.spr_dat_o(itlb_dat_o)
|
| 488 |
|
|
);
|
| 489 |
|
|
|
| 490 |
|
|
`endif
|
| 491 |
|
|
|
| 492 |
|
|
|
| 493 |
|
|
always @ (posedge clk_i_cml_1) begin
|
| 494 |
|
|
immu_en_cml_1 <= immu_en;
|
| 495 |
|
|
supv_cml_1 <= supv;
|
| 496 |
|
|
icpu_adr_i_cml_1 <= icpu_adr_i;
|
| 497 |
|
|
icpu_adr_o_cml_1 <= icpu_adr_o;
|
| 498 |
|
|
icpu_rty_o_cml_1 <= icpu_rty_o;
|
| 499 |
|
|
spr_cs_cml_1 <= spr_cs;
|
| 500 |
|
|
qmemimmu_err_i_cml_1 <= qmemimmu_err_i;
|
| 501 |
|
|
itlb_spr_access_cml_1 <= itlb_spr_access;
|
| 502 |
|
|
itlb_ppn_cml_1 <= itlb_ppn;
|
| 503 |
|
|
itlb_uxe_cml_1 <= itlb_uxe;
|
| 504 |
|
|
itlb_sxe_cml_1 <= itlb_sxe;
|
| 505 |
|
|
page_cross_cml_1 <= page_cross;
|
| 506 |
|
|
icpu_vpn_r_cml_1 <= icpu_vpn_r;
|
| 507 |
|
|
itlb_en_r_cml_1 <= itlb_en_r;
|
| 508 |
|
|
dis_spr_access_cml_1 <= dis_spr_access;
|
| 509 |
|
|
end
|
| 510 |
|
|
endmodule
|
| 511 |
|
|
|