1/*************************************************************************************** 2* Copyright (c) 2020-2021 Institute of Computing Technology, Chinese Academy of Sciences 3* Copyright (c) 2020-2021 Peng Cheng Laboratory 4* 5* XiangShan is licensed under Mulan PSL v2. 6* You can use this software according to the terms and conditions of the Mulan PSL v2. 7* You may obtain a copy of Mulan PSL v2 at: 8* http://license.coscl.org.cn/MulanPSL2 9* 10* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, 11* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, 12* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE. 13* 14* See the Mulan PSL v2 for more details. 15***************************************************************************************/ 16 17package xiangshan 18 19import org.chipsalliance.cde.config.{Field, Parameters} 20import chisel3._ 21import chisel3.util._ 22import huancun._ 23import system.SoCParamsKey 24import xiangshan.backend.datapath.RdConfig._ 25import xiangshan.backend.datapath.WbConfig._ 26import xiangshan.backend.dispatch.DispatchParameters 27import xiangshan.backend.exu.ExeUnitParams 28import xiangshan.backend.fu.FuConfig._ 29import xiangshan.backend.issue.{IntScheduler, IssueBlockParams, MemScheduler, SchdBlockParams, SchedulerType, VfScheduler} 30import xiangshan.backend.regfile.{IntPregParams, PregParams, VfPregParams, FakeIntPregParams} 31import xiangshan.backend.BackendParams 32import xiangshan.cache.DCacheParameters 33import xiangshan.cache.prefetch._ 34import xiangshan.frontend.{BasePredictor, BranchPredictionResp, FTB, FakePredictor, RAS, Tage, ITTage, Tage_SC, FauFTB} 35import xiangshan.frontend.icache.ICacheParameters 36import xiangshan.cache.mmu.{L2TLBParameters, TLBParameters} 37import xiangshan.frontend._ 38import xiangshan.frontend.icache.ICacheParameters 39 40import freechips.rocketchip.diplomacy.AddressSet 41import system.SoCParamsKey 42import huancun._ 43import huancun.debug._ 44import xiangshan.cache.wpu.WPUParameters 45import coupledL2._ 46import xiangshan.backend.datapath.WakeUpConfig 47import xiangshan.mem.prefetch.{PrefetcherParams, SMSParams} 48 49import scala.math.min 50 51case object XSTileKey extends Field[Seq[XSCoreParameters]] 52 53case object XSCoreParamsKey extends Field[XSCoreParameters] 54 55case class XSCoreParameters 56( 57 HasPrefetch: Boolean = false, 58 HartId: Int = 0, 59 XLEN: Int = 64, 60 VLEN: Int = 128, 61 ELEN: Int = 64, 62 HasMExtension: Boolean = true, 63 HasCExtension: Boolean = true, 64 HasDiv: Boolean = true, 65 HasICache: Boolean = true, 66 HasDCache: Boolean = true, 67 AddrBits: Int = 64, 68 VAddrBits: Int = 39, 69 HasFPU: Boolean = true, 70 HasVPU: Boolean = true, 71 HasCustomCSRCacheOp: Boolean = true, 72 FetchWidth: Int = 8, 73 AsidLength: Int = 16, 74 EnableBPU: Boolean = true, 75 EnableBPD: Boolean = true, 76 EnableRAS: Boolean = true, 77 EnableLB: Boolean = false, 78 EnableLoop: Boolean = true, 79 EnableSC: Boolean = true, 80 EnbaleTlbDebug: Boolean = false, 81 EnableClockGate: Boolean = true, 82 EnableJal: Boolean = false, 83 EnableFauFTB: Boolean = true, 84 UbtbGHRLength: Int = 4, 85 // HistoryLength: Int = 512, 86 EnableGHistDiff: Boolean = true, 87 EnableCommitGHistDiff: Boolean = true, 88 UbtbSize: Int = 256, 89 FtbSize: Int = 2048, 90 RasSize: Int = 16, 91 RasSpecSize: Int = 32, 92 RasCtrSize: Int = 3, 93 CacheLineSize: Int = 512, 94 FtbWays: Int = 4, 95 TageTableInfos: Seq[Tuple3[Int,Int,Int]] = 96 // Sets Hist Tag 97 // Seq(( 2048, 2, 8), 98 // ( 2048, 9, 8), 99 // ( 2048, 13, 8), 100 // ( 2048, 20, 8), 101 // ( 2048, 26, 8), 102 // ( 2048, 44, 8), 103 // ( 2048, 73, 8), 104 // ( 2048, 256, 8)), 105 Seq(( 4096, 8, 8), 106 ( 4096, 13, 8), 107 ( 4096, 32, 8), 108 ( 4096, 119, 8)), 109 ITTageTableInfos: Seq[Tuple3[Int,Int,Int]] = 110 // Sets Hist Tag 111 Seq(( 256, 4, 9), 112 ( 256, 8, 9), 113 ( 512, 13, 9), 114 ( 512, 16, 9), 115 ( 512, 32, 9)), 116 SCNRows: Int = 512, 117 SCNTables: Int = 4, 118 SCCtrBits: Int = 6, 119 SCHistLens: Seq[Int] = Seq(0, 4, 10, 16), 120 numBr: Int = 2, 121 branchPredictor: Function2[BranchPredictionResp, Parameters, Tuple2[Seq[BasePredictor], BranchPredictionResp]] = 122 ((resp_in: BranchPredictionResp, p: Parameters) => { 123 val ftb = Module(new FTB()(p)) 124 val ubtb =Module(new FauFTB()(p)) 125 // val bim = Module(new BIM()(p)) 126 val tage = Module(new Tage_SC()(p)) 127 val ras = Module(new RAS()(p)) 128 val ittage = Module(new ITTage()(p)) 129 val preds = Seq(ubtb, tage, ftb, ittage, ras) 130 preds.map(_.io := DontCare) 131 132 // ubtb.io.resp_in(0) := resp_in 133 // bim.io.resp_in(0) := ubtb.io.resp 134 // btb.io.resp_in(0) := bim.io.resp 135 // tage.io.resp_in(0) := btb.io.resp 136 // loop.io.resp_in(0) := tage.io.resp 137 ubtb.io.in.bits.resp_in(0) := resp_in 138 tage.io.in.bits.resp_in(0) := ubtb.io.out 139 ftb.io.in.bits.resp_in(0) := tage.io.out 140 ittage.io.in.bits.resp_in(0) := ftb.io.out 141 ras.io.in.bits.resp_in(0) := ittage.io.out 142 143 (preds, ras.io.out) 144 }), 145 ICacheECCForceError: Boolean = false, 146 IBufSize: Int = 48, 147 IBufNBank: Int = 6, // IBuffer bank amount, should divide IBufSize 148 DecodeWidth: Int = 6, 149 RenameWidth: Int = 6, 150 CommitWidth: Int = 6, 151 MaxUopSize: Int = 65, 152 EnableRenameSnapshot: Boolean = true, 153 RenameSnapshotNum: Int = 4, 154 FtqSize: Int = 64, 155 EnableLoadFastWakeUp: Boolean = true, // NOTE: not supported now, make it false 156 IntLogicRegs: Int = 32, 157 FpLogicRegs: Int = 32 + 1 + 1, // 1: I2F, 1: stride 158 VecLogicRegs: Int = 32 + 1 + 15, // 15: tmp, 1: vconfig 159 VCONFIG_IDX: Int = 32, 160 NRPhyRegs: Int = 192, 161 VirtualLoadQueueSize: Int = 72, 162 LoadQueueRARSize: Int = 72, 163 LoadQueueRAWSize: Int = 64, // NOTE: make sure that LoadQueueRAWSize is power of 2. 164 RollbackGroupSize: Int = 8, 165 LoadQueueReplaySize: Int = 72, 166 LoadUncacheBufferSize: Int = 20, 167 LoadQueueNWriteBanks: Int = 8, // NOTE: make sure that LoadQueueRARSize/LoadQueueRAWSize is divided by LoadQueueNWriteBanks 168 StoreQueueSize: Int = 64, 169 StoreQueueNWriteBanks: Int = 8, // NOTE: make sure that StoreQueueSize is divided by StoreQueueNWriteBanks 170 StoreQueueForwardWithMask: Boolean = true, 171 VlsQueueSize: Int = 8, 172 RobSize: Int = 160, 173 RabSize: Int = 256, 174 VTypeBufferSize: Int = 64, // used to reorder vtype 175 IssueQueueSize: Int = 24, 176 IssueQueueCompEntrySize: Int = 16, 177 dpParams: DispatchParameters = DispatchParameters( 178 IntDqSize = 16, 179 FpDqSize = 16, 180 LsDqSize = 18, 181 IntDqDeqWidth = 8, 182 FpDqDeqWidth = 6, 183 LsDqDeqWidth = 6, 184 ), 185 intPreg: PregParams = IntPregParams( 186 numEntries = 224, 187 numRead = None, 188 numWrite = None, 189 ), 190 vfPreg: VfPregParams = VfPregParams( 191 numEntries = 192, 192 numRead = None, 193 numWrite = None, 194 ), 195 prefetcher: Option[PrefetcherParams] = Some(SMSParams()), 196 LoadPipelineWidth: Int = 3, 197 StorePipelineWidth: Int = 2, 198 VecLoadPipelineWidth: Int = 3, 199 VecStorePipelineWidth: Int = 2, 200 VecMemSrcInWidth: Int = 2, 201 VecMemInstWbWidth: Int = 1, 202 VecMemDispatchWidth: Int = 1, 203 StoreBufferSize: Int = 16, 204 StoreBufferThreshold: Int = 7, 205 EnsbufferWidth: Int = 2, 206 // ============ VLSU ============ 207 VlMergeBufferSize: Int = 8, 208 VsMergeBufferSize: Int = 8, 209 UopWritebackWidth: Int = 1, 210 SplitBufferSize: Int = 8, 211 // ============================== 212 UncacheBufferSize: Int = 4, 213 EnableLoadToLoadForward: Boolean = false, 214 EnableFastForward: Boolean = true, 215 EnableLdVioCheckAfterReset: Boolean = true, 216 EnableSoftPrefetchAfterReset: Boolean = true, 217 EnableCacheErrorAfterReset: Boolean = true, 218 EnableAccurateLoadError: Boolean = true, 219 EnableUncacheWriteOutstanding: Boolean = false, 220 EnableStorePrefetchAtIssue: Boolean = false, 221 EnableStorePrefetchAtCommit: Boolean = false, 222 EnableAtCommitMissTrigger: Boolean = true, 223 EnableStorePrefetchSMS: Boolean = false, 224 EnableStorePrefetchSPB: Boolean = false, 225 MMUAsidLen: Int = 16, // max is 16, 0 is not supported now 226 ReSelectLen: Int = 7, // load replay queue replay select counter len 227 iwpuParameters: WPUParameters = WPUParameters( 228 enWPU = false, 229 algoName = "mmru", 230 isICache = true, 231 ), 232 dwpuParameters: WPUParameters = WPUParameters( 233 enWPU = false, 234 algoName = "mmru", 235 enCfPred = false, 236 isICache = false, 237 ), 238 itlbParameters: TLBParameters = TLBParameters( 239 name = "itlb", 240 fetchi = true, 241 useDmode = false, 242 NWays = 48, 243 ), 244 itlbPortNum: Int = 2 + ICacheParameters().prefetchPipeNum + 1, 245 ipmpPortNum: Int = 2 + ICacheParameters().prefetchPipeNum + 1, 246 ldtlbParameters: TLBParameters = TLBParameters( 247 name = "ldtlb", 248 NWays = 48, 249 outReplace = false, 250 partialStaticPMP = true, 251 outsideRecvFlush = true, 252 saveLevel = true, 253 lgMaxSize = 4 254 ), 255 sttlbParameters: TLBParameters = TLBParameters( 256 name = "sttlb", 257 NWays = 48, 258 outReplace = false, 259 partialStaticPMP = true, 260 outsideRecvFlush = true, 261 saveLevel = true, 262 lgMaxSize = 4 263 ), 264 hytlbParameters: TLBParameters = TLBParameters( 265 name = "hytlb", 266 NWays = 48, 267 outReplace = false, 268 partialStaticPMP = true, 269 outsideRecvFlush = true, 270 saveLevel = true, 271 lgMaxSize = 4 272 ), 273 pftlbParameters: TLBParameters = TLBParameters( 274 name = "pftlb", 275 NWays = 48, 276 outReplace = false, 277 partialStaticPMP = true, 278 outsideRecvFlush = true, 279 saveLevel = true, 280 lgMaxSize = 4 281 ), 282 refillBothTlb: Boolean = false, 283 btlbParameters: TLBParameters = TLBParameters( 284 name = "btlb", 285 NWays = 48, 286 ), 287 l2tlbParameters: L2TLBParameters = L2TLBParameters(), 288 NumPerfCounters: Int = 16, 289 icacheParameters: ICacheParameters = ICacheParameters( 290 tagECC = Some("parity"), 291 dataECC = Some("parity"), 292 replacer = Some("setplru"), 293 nMissEntries = 2, 294 nProbeEntries = 2, 295 nPrefetchEntries = 12, 296 nPrefBufferEntries = 32, 297 ), 298 dcacheParametersOpt: Option[DCacheParameters] = Some(DCacheParameters( 299 tagECC = Some("secded"), 300 dataECC = Some("secded"), 301 replacer = Some("setplru"), 302 nMissEntries = 16, 303 nProbeEntries = 8, 304 nReleaseEntries = 18, 305 nMaxPrefetchEntry = 6, 306 )), 307 L2CacheParamsOpt: Option[L2Param] = Some(L2Param( 308 name = "l2", 309 ways = 8, 310 sets = 1024, // default 512KB L2 311 prefetch = Some(coupledL2.prefetch.PrefetchReceiverParams()) 312 )), 313 L2NBanks: Int = 1, 314 usePTWRepeater: Boolean = false, 315 softTLB: Boolean = false, // dpi-c l1tlb debug only 316 softPTW: Boolean = false, // dpi-c l2tlb debug only 317 softPTWDelay: Int = 1 318){ 319 def vlWidth = log2Up(VLEN) + 1 320 321 val allHistLens = SCHistLens ++ ITTageTableInfos.map(_._2) ++ TageTableInfos.map(_._2) :+ UbtbGHRLength 322 val HistoryLength = allHistLens.max + numBr * FtqSize + 9 // 256 for the predictor configs now 323 324 val intSchdParams = { 325 implicit val schdType: SchedulerType = IntScheduler() 326 SchdBlockParams(Seq( 327 IssueBlockParams(Seq( 328 ExeUnitParams("ALU0", Seq(AluCfg, MulCfg, BkuCfg), Seq(IntWB(port = 0, 0)), Seq(Seq(IntRD(0, 0)), Seq(IntRD(1, 0))), true, 2), 329 ExeUnitParams("BJU0", Seq(BrhCfg, JmpCfg), Seq(IntWB(port = 4, 0)), Seq(Seq(IntRD(8, 0)), Seq(IntRD(7, 1))), true, 2), 330 ), numEntries = IssueQueueSize, numEnq = 2, numComp = IssueQueueCompEntrySize), 331 IssueBlockParams(Seq( 332 ExeUnitParams("ALU1", Seq(AluCfg, MulCfg, BkuCfg), Seq(IntWB(port = 1, 0)), Seq(Seq(IntRD(2, 0)), Seq(IntRD(3, 0))), true, 2), 333 ExeUnitParams("BJU1", Seq(BrhCfg, JmpCfg), Seq(IntWB(port = 2, 1)), Seq(Seq(IntRD(9, 0)), Seq(IntRD(5, 1))), true, 2), 334 ), numEntries = IssueQueueSize, numEnq = 2, numComp = IssueQueueCompEntrySize), 335 IssueBlockParams(Seq( 336 ExeUnitParams("ALU2", Seq(AluCfg), Seq(IntWB(port = 2, 0)), Seq(Seq(IntRD(4, 0)), Seq(IntRD(5, 0))), true, 2), 337 ExeUnitParams("BJU2", Seq(BrhCfg, JmpCfg, I2fCfg, VSetRiWiCfg, VSetRiWvfCfg, CsrCfg, FenceCfg, I2vCfg), Seq(IntWB(port = 3, 1), VfWB(4, 0)), Seq(Seq(IntRD(10, 0)), Seq(IntRD(3, 1)))), 338 ), numEntries = IssueQueueSize, numEnq = 2, numComp = IssueQueueCompEntrySize), 339 IssueBlockParams(Seq( 340 ExeUnitParams("ALU3", Seq(AluCfg), Seq(IntWB(port = 3, 0)), Seq(Seq(IntRD(6, 0)), Seq(IntRD(7, 0))), true, 2), 341 ExeUnitParams("BJU3", Seq(DivCfg), Seq(IntWB(port = 4, 1)), Seq(Seq(IntRD(11, 0)), Seq(IntRD(1, 1)))), 342 ), numEntries = IssueQueueSize, numEnq = 2, numComp = IssueQueueCompEntrySize), 343 ), 344 numPregs = intPreg.numEntries, 345 numDeqOutside = 0, 346 schdType = schdType, 347 rfDataWidth = intPreg.dataCfg.dataWidth, 348 numUopIn = dpParams.IntDqDeqWidth, 349 ) 350 } 351 val vfSchdParams = { 352 implicit val schdType: SchedulerType = VfScheduler() 353 SchdBlockParams(Seq( 354 IssueBlockParams(Seq( 355 ExeUnitParams("VFEX0", Seq(VfaluCfg, VfmaCfg, VialuCfg, VimacCfg), Seq(VfWB(port = 5, 0), IntWB(port = 0, 1)), Seq(Seq(VfRD(0, 0)), Seq(VfRD(1, 0)), Seq(VfRD(2, 0)), Seq(VfRD(3, 0)), Seq(VfRD(4, 0)))), 356 ExeUnitParams("VFEX1", Seq(VipuCfg, VppuCfg, VfcvtCfg, F2vCfg, VSetRvfWvfCfg), Seq(VfWB(port = 6, 1), IntWB(port = 1, 2)), Seq(Seq(VfRD(5, 1)), Seq(VfRD(6, 1)), Seq(VfRD(7, 1)), Seq(VfRD(8, 1)), Seq(VfRD(9, 1)))), 357 ), numEntries = IssueQueueSize, numEnq = 2, numComp = IssueQueueCompEntrySize), 358 IssueBlockParams(Seq( 359 ExeUnitParams("VFEX2", Seq(VfaluCfg, VfmaCfg, VialuCfg), Seq(VfWB(port = 6, 0), IntWB(port = 1, 1)), Seq(Seq(VfRD(5, 0)), Seq(VfRD(6, 0)), Seq(VfRD(7, 0)), Seq(VfRD(8, 0)), Seq(VfRD(9, 0)))), 360 ExeUnitParams("VFEX3", Seq(VfdivCfg, VidivCfg), Seq(VfWB(port = 5, 1)), Seq(Seq(VfRD(0, 1)), Seq(VfRD(1, 1)), Seq(VfRD(2, 1)), Seq(VfRD(3, 1)), Seq(VfRD(4, 1)))), 361 ), numEntries = IssueQueueSize, numEnq = 2, numComp = IssueQueueCompEntrySize), 362 ), 363 numPregs = vfPreg.numEntries, 364 numDeqOutside = 0, 365 schdType = schdType, 366 rfDataWidth = vfPreg.dataCfg.dataWidth, 367 numUopIn = dpParams.FpDqDeqWidth, 368 ) 369 } 370 371 val memSchdParams = { 372 implicit val schdType: SchedulerType = MemScheduler() 373 val rfDataWidth = 64 374 375 SchdBlockParams(Seq( 376 IssueBlockParams(Seq( 377 ExeUnitParams("STA0", Seq(StaCfg, MouCfg), Seq(FakeIntWB()), Seq(Seq(IntRD(15, 0)))), 378 ), numEntries = IssueQueueSize, numEnq = 2, numComp = IssueQueueCompEntrySize), 379 IssueBlockParams(Seq( 380 ExeUnitParams("STA1", Seq(StaCfg, MouCfg), Seq(FakeIntWB()), Seq(Seq(IntRD(13, 1)))), 381 ), numEntries = IssueQueueSize, numEnq = 2, numComp = IssueQueueCompEntrySize), 382 IssueBlockParams(Seq( 383 ExeUnitParams("LDU0", Seq(LduCfg), Seq(IntWB(5, 0), VfWB(0, 0)), Seq(Seq(IntRD(12, 0))), true, 2), 384 ), numEntries = IssueQueueSize, numEnq = 2, numComp = IssueQueueCompEntrySize), 385 IssueBlockParams(Seq( 386 ExeUnitParams("LDU1", Seq(LduCfg), Seq(IntWB(6, 0), VfWB(1, 0)), Seq(Seq(IntRD(13, 0))), true, 2), 387 ), numEntries = IssueQueueSize, numEnq = 2, numComp = IssueQueueCompEntrySize), 388 IssueBlockParams(Seq( 389 ExeUnitParams("LDU2", Seq(LduCfg), Seq(IntWB(7, 0), VfWB(2, 0)), Seq(Seq(IntRD(14, 0))), true, 2), 390 ), numEntries = IssueQueueSize, numEnq = 2, numComp = IssueQueueCompEntrySize), 391 IssueBlockParams(Seq( 392 ExeUnitParams("VLSU0", Seq(VlduCfg, VstuCfg), Seq(VfWB(3, 0)), Seq(Seq(VfRD(10, 0)), Seq(VfRD(11, 0)), Seq(VfRD(12, 0)), Seq(VfRD(13, 0)), Seq(VfRD(14, 0)))), 393 ), numEntries = IssueQueueSize, numEnq = 2, numComp = IssueQueueCompEntrySize), 394 IssueBlockParams(Seq( 395 ExeUnitParams("STD0", Seq(StdCfg, MoudCfg), Seq(), Seq(Seq(IntRD(12, 1), VfRD(12, Int.MaxValue)))), 396 ), numEntries = IssueQueueSize, numEnq = 2, numComp = IssueQueueCompEntrySize), 397 IssueBlockParams(Seq( 398 ExeUnitParams("STD1", Seq(StdCfg, MoudCfg), Seq(), Seq(Seq(IntRD(14, 1), VfRD(13, Int.MaxValue)))), 399 ), numEntries = IssueQueueSize, numEnq = 2, numComp = IssueQueueCompEntrySize), 400 ), 401 numPregs = intPreg.numEntries max vfPreg.numEntries, 402 numDeqOutside = 0, 403 schdType = schdType, 404 rfDataWidth = rfDataWidth, 405 numUopIn = dpParams.LsDqDeqWidth, 406 ) 407 } 408 409 def PregIdxWidthMax = intPreg.addrWidth max vfPreg.addrWidth 410 411 def iqWakeUpParams = { 412 Seq( 413 WakeUpConfig( 414 Seq("ALU0", "ALU1", "ALU2", "ALU3", "LDU0", "LDU1", "LDU2") -> 415 Seq("ALU0", "BJU0", "ALU1", "BJU1", "ALU2", "BJU2", "ALU3", "BJU3", "LDU0", "LDU1", "LDU2", "STA0", "STA1", "STD0", "STD1") 416 ), 417 ).flatten 418 } 419 420 def fakeIntPreg = FakeIntPregParams(intPreg.numEntries, intPreg.numRead, intPreg.numWrite) 421 422 val backendParams: BackendParams = backend.BackendParams( 423 Map( 424 IntScheduler() -> intSchdParams, 425 VfScheduler() -> vfSchdParams, 426 MemScheduler() -> memSchdParams, 427 ), 428 Seq( 429 intPreg, 430 vfPreg, 431 fakeIntPreg 432 ), 433 iqWakeUpParams, 434 ) 435} 436 437case object DebugOptionsKey extends Field[DebugOptions] 438 439case class DebugOptions 440( 441 FPGAPlatform: Boolean = false, 442 EnableDifftest: Boolean = false, 443 AlwaysBasicDiff: Boolean = true, 444 EnableDebug: Boolean = false, 445 EnablePerfDebug: Boolean = true, 446 UseDRAMSim: Boolean = false, 447 EnableConstantin: Boolean = false, 448 EnableChiselDB: Boolean = false, 449 AlwaysBasicDB: Boolean = true, 450 EnableTopDown: Boolean = false, 451 EnableRollingDB: Boolean = false 452) 453 454trait HasXSParameter { 455 456 implicit val p: Parameters 457 458 val PAddrBits = p(SoCParamsKey).PAddrBits // PAddrBits is Phyical Memory addr bits 459 460 val coreParams = p(XSCoreParamsKey) 461 val env = p(DebugOptionsKey) 462 463 val XLEN = coreParams.XLEN 464 val VLEN = coreParams.VLEN 465 val ELEN = coreParams.ELEN 466 val minFLen = 32 467 val fLen = 64 468 def xLen = XLEN 469 470 val HasMExtension = coreParams.HasMExtension 471 val HasCExtension = coreParams.HasCExtension 472 val HasDiv = coreParams.HasDiv 473 val HasIcache = coreParams.HasICache 474 val HasDcache = coreParams.HasDCache 475 val AddrBits = coreParams.AddrBits // AddrBits is used in some cases 476 val VAddrBits = coreParams.VAddrBits // VAddrBits is Virtual Memory addr bits 477 val AsidLength = coreParams.AsidLength 478 val ReSelectLen = coreParams.ReSelectLen 479 val AddrBytes = AddrBits / 8 // unused 480 val DataBits = XLEN 481 val DataBytes = DataBits / 8 482 val VDataBytes = VLEN / 8 483 val HasFPU = coreParams.HasFPU 484 val HasVPU = coreParams.HasVPU 485 val HasCustomCSRCacheOp = coreParams.HasCustomCSRCacheOp 486 val FetchWidth = coreParams.FetchWidth 487 val PredictWidth = FetchWidth * (if (HasCExtension) 2 else 1) 488 val EnableBPU = coreParams.EnableBPU 489 val EnableBPD = coreParams.EnableBPD // enable backing predictor(like Tage) in BPUStage3 490 val EnableRAS = coreParams.EnableRAS 491 val EnableLB = coreParams.EnableLB 492 val EnableLoop = coreParams.EnableLoop 493 val EnableSC = coreParams.EnableSC 494 val EnbaleTlbDebug = coreParams.EnbaleTlbDebug 495 val HistoryLength = coreParams.HistoryLength 496 val EnableGHistDiff = coreParams.EnableGHistDiff 497 val EnableCommitGHistDiff = coreParams.EnableCommitGHistDiff 498 val EnableClockGate = coreParams.EnableClockGate 499 val UbtbGHRLength = coreParams.UbtbGHRLength 500 val UbtbSize = coreParams.UbtbSize 501 val EnableFauFTB = coreParams.EnableFauFTB 502 val FtbSize = coreParams.FtbSize 503 val FtbWays = coreParams.FtbWays 504 val RasSize = coreParams.RasSize 505 val RasSpecSize = coreParams.RasSpecSize 506 val RasCtrSize = coreParams.RasCtrSize 507 508 def getBPDComponents(resp_in: BranchPredictionResp, p: Parameters) = { 509 coreParams.branchPredictor(resp_in, p) 510 } 511 val numBr = coreParams.numBr 512 val TageTableInfos = coreParams.TageTableInfos 513 val TageBanks = coreParams.numBr 514 val SCNRows = coreParams.SCNRows 515 val SCCtrBits = coreParams.SCCtrBits 516 val SCHistLens = coreParams.SCHistLens 517 val SCNTables = coreParams.SCNTables 518 519 val SCTableInfos = Seq.fill(SCNTables)((SCNRows, SCCtrBits)) zip SCHistLens map { 520 case ((n, cb), h) => (n, cb, h) 521 } 522 val ITTageTableInfos = coreParams.ITTageTableInfos 523 type FoldedHistoryInfo = Tuple2[Int, Int] 524 val foldedGHistInfos = 525 (TageTableInfos.map{ case (nRows, h, t) => 526 if (h > 0) 527 Set((h, min(log2Ceil(nRows/numBr), h)), (h, min(h, t)), (h, min(h, t-1))) 528 else 529 Set[FoldedHistoryInfo]() 530 }.reduce(_++_).toSet ++ 531 SCTableInfos.map{ case (nRows, _, h) => 532 if (h > 0) 533 Set((h, min(log2Ceil(nRows/TageBanks), h))) 534 else 535 Set[FoldedHistoryInfo]() 536 }.reduce(_++_).toSet ++ 537 ITTageTableInfos.map{ case (nRows, h, t) => 538 if (h > 0) 539 Set((h, min(log2Ceil(nRows), h)), (h, min(h, t)), (h, min(h, t-1))) 540 else 541 Set[FoldedHistoryInfo]() 542 }.reduce(_++_) ++ 543 Set[FoldedHistoryInfo]((UbtbGHRLength, log2Ceil(UbtbSize))) 544 ).toList 545 546 547 548 val CacheLineSize = coreParams.CacheLineSize 549 val CacheLineHalfWord = CacheLineSize / 16 550 val ExtHistoryLength = HistoryLength + 64 551 val ICacheECCForceError = coreParams.ICacheECCForceError 552 val IBufSize = coreParams.IBufSize 553 val IBufNBank = coreParams.IBufNBank 554 val backendParams: BackendParams = coreParams.backendParams 555 val DecodeWidth = coreParams.DecodeWidth 556 val RenameWidth = coreParams.RenameWidth 557 val CommitWidth = coreParams.CommitWidth 558 val MaxUopSize = coreParams.MaxUopSize 559 val EnableRenameSnapshot = coreParams.EnableRenameSnapshot 560 val RenameSnapshotNum = coreParams.RenameSnapshotNum 561 val FtqSize = coreParams.FtqSize 562 val EnableLoadFastWakeUp = coreParams.EnableLoadFastWakeUp 563 val IntLogicRegs = coreParams.IntLogicRegs 564 val FpLogicRegs = coreParams.FpLogicRegs 565 val VecLogicRegs = coreParams.VecLogicRegs 566 val VCONFIG_IDX = coreParams.VCONFIG_IDX 567 val IntPhyRegs = coreParams.intPreg.numEntries 568 val VfPhyRegs = coreParams.vfPreg.numEntries 569 val MaxPhyPregs = IntPhyRegs max VfPhyRegs 570 val PhyRegIdxWidth = log2Up(IntPhyRegs) max log2Up(VfPhyRegs) 571 val RobSize = coreParams.RobSize 572 val RabSize = coreParams.RabSize 573 val VTypeBufferSize = coreParams.VTypeBufferSize 574 val IntRefCounterWidth = log2Ceil(RobSize) 575 val LSQEnqWidth = coreParams.dpParams.LsDqDeqWidth 576 val LSQLdEnqWidth = LSQEnqWidth min backendParams.numLoadDp 577 val LSQStEnqWidth = LSQEnqWidth min backendParams.numStoreDp 578 val VirtualLoadQueueSize = coreParams.VirtualLoadQueueSize 579 val LoadQueueRARSize = coreParams.LoadQueueRARSize 580 val LoadQueueRAWSize = coreParams.LoadQueueRAWSize 581 val RollbackGroupSize = coreParams.RollbackGroupSize 582 val LoadQueueReplaySize = coreParams.LoadQueueReplaySize 583 val LoadUncacheBufferSize = coreParams.LoadUncacheBufferSize 584 val LoadQueueNWriteBanks = coreParams.LoadQueueNWriteBanks 585 val StoreQueueSize = coreParams.StoreQueueSize 586 val StoreQueueNWriteBanks = coreParams.StoreQueueNWriteBanks 587 val StoreQueueForwardWithMask = coreParams.StoreQueueForwardWithMask 588 val VlsQueueSize = coreParams.VlsQueueSize 589 val dpParams = coreParams.dpParams 590 591 def MemIQSizeMax = backendParams.memSchdParams.get.issueBlockParams.map(_.numEntries).max 592 def IQSizeMax = backendParams.allSchdParams.map(_.issueBlockParams.map(_.numEntries).max).max 593 594 val NumRedirect = backendParams.numRedirect 595 val BackendRedirectNum = NumRedirect + 2 //2: ldReplay + Exception 596 val FtqRedirectAheadNum = NumRedirect 597 val LoadPipelineWidth = coreParams.LoadPipelineWidth 598 val StorePipelineWidth = coreParams.StorePipelineWidth 599 val VecLoadPipelineWidth = coreParams.VecLoadPipelineWidth 600 val VecStorePipelineWidth = coreParams.VecStorePipelineWidth 601 val VecMemSrcInWidth = coreParams.VecMemSrcInWidth 602 val VecMemInstWbWidth = coreParams.VecMemInstWbWidth 603 val VecMemDispatchWidth = coreParams.VecMemDispatchWidth 604 val StoreBufferSize = coreParams.StoreBufferSize 605 val StoreBufferThreshold = coreParams.StoreBufferThreshold 606 val EnsbufferWidth = coreParams.EnsbufferWidth 607 val VlMergeBufferSize = coreParams.VlMergeBufferSize 608 val VsMergeBufferSize = coreParams.VsMergeBufferSize 609 val UopWritebackWidth = coreParams.UopWritebackWidth 610 val SplitBufferSize = coreParams.SplitBufferSize 611 val UncacheBufferSize = coreParams.UncacheBufferSize 612 val EnableLoadToLoadForward = coreParams.EnableLoadToLoadForward 613 val EnableFastForward = coreParams.EnableFastForward 614 val EnableLdVioCheckAfterReset = coreParams.EnableLdVioCheckAfterReset 615 val EnableSoftPrefetchAfterReset = coreParams.EnableSoftPrefetchAfterReset 616 val EnableCacheErrorAfterReset = coreParams.EnableCacheErrorAfterReset 617 val EnableAccurateLoadError = coreParams.EnableAccurateLoadError 618 val EnableUncacheWriteOutstanding = coreParams.EnableUncacheWriteOutstanding 619 val EnableStorePrefetchAtIssue = coreParams.EnableStorePrefetchAtIssue 620 val EnableStorePrefetchAtCommit = coreParams.EnableStorePrefetchAtCommit 621 val EnableAtCommitMissTrigger = coreParams.EnableAtCommitMissTrigger 622 val EnableStorePrefetchSMS = coreParams.EnableStorePrefetchSMS 623 val EnableStorePrefetchSPB = coreParams.EnableStorePrefetchSPB 624 val asidLen = coreParams.MMUAsidLen 625 val BTLBWidth = coreParams.LoadPipelineWidth + coreParams.StorePipelineWidth 626 val refillBothTlb = coreParams.refillBothTlb 627 val iwpuParam = coreParams.iwpuParameters 628 val dwpuParam = coreParams.dwpuParameters 629 val itlbParams = coreParams.itlbParameters 630 val ldtlbParams = coreParams.ldtlbParameters 631 val sttlbParams = coreParams.sttlbParameters 632 val hytlbParams = coreParams.hytlbParameters 633 val pftlbParams = coreParams.pftlbParameters 634 val btlbParams = coreParams.btlbParameters 635 val l2tlbParams = coreParams.l2tlbParameters 636 val NumPerfCounters = coreParams.NumPerfCounters 637 638 val instBytes = if (HasCExtension) 2 else 4 639 val instOffsetBits = log2Ceil(instBytes) 640 641 val icacheParameters = coreParams.icacheParameters 642 val dcacheParameters = coreParams.dcacheParametersOpt.getOrElse(DCacheParameters()) 643 644 // dcache block cacheline when lr for LRSCCycles - LRSCBackOff cycles 645 // for constrained LR/SC loop 646 val LRSCCycles = 64 647 // for lr storm 648 val LRSCBackOff = 8 649 650 // cache hierarchy configurations 651 val l1BusDataWidth = 256 652 653 // load violation predict 654 val ResetTimeMax2Pow = 20 //1078576 655 val ResetTimeMin2Pow = 10 //1024 656 // wait table parameters 657 val WaitTableSize = 1024 658 val MemPredPCWidth = log2Up(WaitTableSize) 659 val LWTUse2BitCounter = true 660 // store set parameters 661 val SSITSize = WaitTableSize 662 val LFSTSize = 32 663 val SSIDWidth = log2Up(LFSTSize) 664 val LFSTWidth = 4 665 val StoreSetEnable = true // LWT will be disabled if SS is enabled 666 val LFSTEnable = true 667 668 val PCntIncrStep: Int = 6 669 val numPCntHc: Int = 25 670 val numPCntPtw: Int = 19 671 672 val numCSRPCntFrontend = 8 673 val numCSRPCntCtrl = 8 674 val numCSRPCntLsu = 8 675 val numCSRPCntHc = 5 676 val printEventCoding = true 677 678 // Parameters for Sdtrig extension 679 protected val TriggerNum = 4 680 protected val TriggerChainMaxLength = 2 681} 682