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 = 2, 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 ), 254 sttlbParameters: TLBParameters = TLBParameters( 255 name = "sttlb", 256 NWays = 48, 257 outReplace = false, 258 partialStaticPMP = true, 259 outsideRecvFlush = true, 260 saveLevel = true 261 ), 262 hytlbParameters: TLBParameters = TLBParameters( 263 name = "hytlb", 264 NWays = 48, 265 outReplace = false, 266 partialStaticPMP = true, 267 outsideRecvFlush = true, 268 saveLevel = true 269 ), 270 pftlbParameters: TLBParameters = TLBParameters( 271 name = "pftlb", 272 NWays = 48, 273 outReplace = false, 274 partialStaticPMP = true, 275 outsideRecvFlush = true, 276 saveLevel = true 277 ), 278 refillBothTlb: Boolean = false, 279 btlbParameters: TLBParameters = TLBParameters( 280 name = "btlb", 281 NWays = 48, 282 ), 283 l2tlbParameters: L2TLBParameters = L2TLBParameters(), 284 NumPerfCounters: Int = 16, 285 icacheParameters: ICacheParameters = ICacheParameters( 286 tagECC = Some("parity"), 287 dataECC = Some("parity"), 288 replacer = Some("setplru"), 289 nMissEntries = 2, 290 nProbeEntries = 2, 291 nPrefetchEntries = 12, 292 nPrefBufferEntries = 32, 293 ), 294 dcacheParametersOpt: Option[DCacheParameters] = Some(DCacheParameters( 295 tagECC = Some("secded"), 296 dataECC = Some("secded"), 297 replacer = Some("setplru"), 298 nMissEntries = 16, 299 nProbeEntries = 8, 300 nReleaseEntries = 18, 301 nMaxPrefetchEntry = 6, 302 )), 303 L2CacheParamsOpt: Option[L2Param] = Some(L2Param( 304 name = "l2", 305 ways = 8, 306 sets = 1024, // default 512KB L2 307 prefetch = Some(coupledL2.prefetch.PrefetchReceiverParams()) 308 )), 309 L2NBanks: Int = 1, 310 usePTWRepeater: Boolean = false, 311 softTLB: Boolean = false, // dpi-c l1tlb debug only 312 softPTW: Boolean = false, // dpi-c l2tlb debug only 313 softPTWDelay: Int = 1 314){ 315 def vlWidth = log2Up(VLEN) + 1 316 317 val allHistLens = SCHistLens ++ ITTageTableInfos.map(_._2) ++ TageTableInfos.map(_._2) :+ UbtbGHRLength 318 val HistoryLength = allHistLens.max + numBr * FtqSize + 9 // 256 for the predictor configs now 319 320 val intSchdParams = { 321 implicit val schdType: SchedulerType = IntScheduler() 322 SchdBlockParams(Seq( 323 IssueBlockParams(Seq( 324 ExeUnitParams("ALU0", Seq(AluCfg, MulCfg, BkuCfg), Seq(IntWB(port = 0, 0)), Seq(Seq(IntRD(0, 0)), Seq(IntRD(1, 0))), true, 2), 325 ExeUnitParams("BJU0", Seq(BrhCfg, JmpCfg), Seq(IntWB(port = 4, 0)), Seq(Seq(IntRD(8, 0)), Seq(IntRD(7, 1))), true, 2), 326 ), numEntries = IssueQueueSize, numEnq = 2, numComp = IssueQueueCompEntrySize), 327 IssueBlockParams(Seq( 328 ExeUnitParams("ALU1", Seq(AluCfg, MulCfg, BkuCfg), Seq(IntWB(port = 1, 0)), Seq(Seq(IntRD(2, 0)), Seq(IntRD(3, 0))), true, 2), 329 ExeUnitParams("BJU1", Seq(BrhCfg, JmpCfg), Seq(IntWB(port = 2, 1)), Seq(Seq(IntRD(9, 0)), Seq(IntRD(5, 1))), true, 2), 330 ), numEntries = IssueQueueSize, numEnq = 2, numComp = IssueQueueCompEntrySize), 331 IssueBlockParams(Seq( 332 ExeUnitParams("ALU2", Seq(AluCfg), Seq(IntWB(port = 2, 0)), Seq(Seq(IntRD(4, 0)), Seq(IntRD(5, 0))), true, 2), 333 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)))), 334 ), numEntries = IssueQueueSize, numEnq = 2, numComp = IssueQueueCompEntrySize), 335 IssueBlockParams(Seq( 336 ExeUnitParams("ALU3", Seq(AluCfg), Seq(IntWB(port = 3, 0)), Seq(Seq(IntRD(6, 0)), Seq(IntRD(7, 0))), true, 2), 337 ExeUnitParams("BJU3", Seq(DivCfg), Seq(IntWB(port = 4, 1)), Seq(Seq(IntRD(11, 0)), Seq(IntRD(1, 1)))), 338 ), numEntries = IssueQueueSize, numEnq = 2, numComp = IssueQueueCompEntrySize), 339 ), 340 numPregs = intPreg.numEntries, 341 numDeqOutside = 0, 342 schdType = schdType, 343 rfDataWidth = intPreg.dataCfg.dataWidth, 344 numUopIn = dpParams.IntDqDeqWidth, 345 ) 346 } 347 val vfSchdParams = { 348 implicit val schdType: SchedulerType = VfScheduler() 349 SchdBlockParams(Seq( 350 IssueBlockParams(Seq( 351 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)))), 352 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)))), 353 ), numEntries = IssueQueueSize, numEnq = 2, numComp = IssueQueueCompEntrySize), 354 IssueBlockParams(Seq( 355 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)))), 356 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)))), 357 ), numEntries = IssueQueueSize, numEnq = 2, numComp = IssueQueueCompEntrySize), 358 ), 359 numPregs = vfPreg.numEntries, 360 numDeqOutside = 0, 361 schdType = schdType, 362 rfDataWidth = vfPreg.dataCfg.dataWidth, 363 numUopIn = dpParams.FpDqDeqWidth, 364 ) 365 } 366 367 val memSchdParams = { 368 implicit val schdType: SchedulerType = MemScheduler() 369 val rfDataWidth = 64 370 371 SchdBlockParams(Seq( 372 IssueBlockParams(Seq( 373 ExeUnitParams("STA0", Seq(StaCfg, MouCfg), Seq(FakeIntWB()), Seq(Seq(IntRD(15, 0)))), 374 ), numEntries = IssueQueueSize, numEnq = 2, numComp = IssueQueueCompEntrySize), 375 IssueBlockParams(Seq( 376 ExeUnitParams("STA1", Seq(StaCfg, MouCfg), Seq(FakeIntWB()), Seq(Seq(IntRD(13, 1)))), 377 ), numEntries = IssueQueueSize, numEnq = 2, numComp = IssueQueueCompEntrySize), 378 IssueBlockParams(Seq( 379 ExeUnitParams("LDU0", Seq(LduCfg), Seq(IntWB(5, 0), VfWB(0, 0)), Seq(Seq(IntRD(12, 0))), true, 2), 380 ), numEntries = IssueQueueSize, numEnq = 2, numComp = IssueQueueCompEntrySize), 381 IssueBlockParams(Seq( 382 ExeUnitParams("LDU1", Seq(LduCfg), Seq(IntWB(6, 0), VfWB(1, 0)), Seq(Seq(IntRD(13, 0))), true, 2), 383 ), numEntries = IssueQueueSize, numEnq = 2, numComp = IssueQueueCompEntrySize), 384 IssueBlockParams(Seq( 385 ExeUnitParams("LDU2", Seq(LduCfg), Seq(IntWB(7, 0), VfWB(2, 0)), Seq(Seq(IntRD(14, 0))), true, 2), 386 ), numEntries = IssueQueueSize, numEnq = 2, numComp = IssueQueueCompEntrySize), 387 IssueBlockParams(Seq( 388 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)))), 389 ), numEntries = IssueQueueSize, numEnq = 2, numComp = IssueQueueCompEntrySize), 390 IssueBlockParams(Seq( 391 ExeUnitParams("STD0", Seq(StdCfg, MoudCfg), Seq(), Seq(Seq(IntRD(12, 1), VfRD(12, Int.MaxValue)))), 392 ), numEntries = IssueQueueSize, numEnq = 2, numComp = IssueQueueCompEntrySize), 393 IssueBlockParams(Seq( 394 ExeUnitParams("STD1", Seq(StdCfg, MoudCfg), Seq(), Seq(Seq(IntRD(14, 1), VfRD(13, Int.MaxValue)))), 395 ), numEntries = IssueQueueSize, numEnq = 2, numComp = IssueQueueCompEntrySize), 396 ), 397 numPregs = intPreg.numEntries max vfPreg.numEntries, 398 numDeqOutside = 0, 399 schdType = schdType, 400 rfDataWidth = rfDataWidth, 401 numUopIn = dpParams.LsDqDeqWidth, 402 ) 403 } 404 405 def PregIdxWidthMax = intPreg.addrWidth max vfPreg.addrWidth 406 407 def iqWakeUpParams = { 408 Seq( 409 WakeUpConfig( 410 Seq("ALU0", "ALU1", "ALU2", "ALU3", "LDU0", "LDU1", "LDU2") -> 411 Seq("ALU0", "BJU0", "ALU1", "BJU1", "ALU2", "BJU2", "ALU3", "BJU3", "LDU0", "LDU1", "LDU2", "STA0", "STA1", "STD0", "STD1") 412 ), 413 ).flatten 414 } 415 416 def fakeIntPreg = FakeIntPregParams(intPreg.numEntries, intPreg.numRead, intPreg.numWrite) 417 418 val backendParams: BackendParams = backend.BackendParams( 419 Map( 420 IntScheduler() -> intSchdParams, 421 VfScheduler() -> vfSchdParams, 422 MemScheduler() -> memSchdParams, 423 ), 424 Seq( 425 intPreg, 426 vfPreg, 427 fakeIntPreg 428 ), 429 iqWakeUpParams, 430 ) 431} 432 433case object DebugOptionsKey extends Field[DebugOptions] 434 435case class DebugOptions 436( 437 FPGAPlatform: Boolean = false, 438 EnableDifftest: Boolean = false, 439 AlwaysBasicDiff: Boolean = true, 440 EnableDebug: Boolean = false, 441 EnablePerfDebug: Boolean = true, 442 UseDRAMSim: Boolean = false, 443 EnableConstantin: Boolean = false, 444 EnableChiselDB: Boolean = false, 445 AlwaysBasicDB: Boolean = true, 446 EnableTopDown: Boolean = false, 447 EnableRollingDB: Boolean = false 448) 449 450trait HasXSParameter { 451 452 implicit val p: Parameters 453 454 val PAddrBits = p(SoCParamsKey).PAddrBits // PAddrBits is Phyical Memory addr bits 455 456 val coreParams = p(XSCoreParamsKey) 457 val env = p(DebugOptionsKey) 458 459 val XLEN = coreParams.XLEN 460 val VLEN = coreParams.VLEN 461 val ELEN = coreParams.ELEN 462 val minFLen = 32 463 val fLen = 64 464 def xLen = XLEN 465 466 val HasMExtension = coreParams.HasMExtension 467 val HasCExtension = coreParams.HasCExtension 468 val HasDiv = coreParams.HasDiv 469 val HasIcache = coreParams.HasICache 470 val HasDcache = coreParams.HasDCache 471 val AddrBits = coreParams.AddrBits // AddrBits is used in some cases 472 val VAddrBits = coreParams.VAddrBits // VAddrBits is Virtual Memory addr bits 473 val AsidLength = coreParams.AsidLength 474 val ReSelectLen = coreParams.ReSelectLen 475 val AddrBytes = AddrBits / 8 // unused 476 val DataBits = XLEN 477 val DataBytes = DataBits / 8 478 val VDataBytes = VLEN / 8 479 val HasFPU = coreParams.HasFPU 480 val HasVPU = coreParams.HasVPU 481 val HasCustomCSRCacheOp = coreParams.HasCustomCSRCacheOp 482 val FetchWidth = coreParams.FetchWidth 483 val PredictWidth = FetchWidth * (if (HasCExtension) 2 else 1) 484 val EnableBPU = coreParams.EnableBPU 485 val EnableBPD = coreParams.EnableBPD // enable backing predictor(like Tage) in BPUStage3 486 val EnableRAS = coreParams.EnableRAS 487 val EnableLB = coreParams.EnableLB 488 val EnableLoop = coreParams.EnableLoop 489 val EnableSC = coreParams.EnableSC 490 val EnbaleTlbDebug = coreParams.EnbaleTlbDebug 491 val HistoryLength = coreParams.HistoryLength 492 val EnableGHistDiff = coreParams.EnableGHistDiff 493 val EnableCommitGHistDiff = coreParams.EnableCommitGHistDiff 494 val EnableClockGate = coreParams.EnableClockGate 495 val UbtbGHRLength = coreParams.UbtbGHRLength 496 val UbtbSize = coreParams.UbtbSize 497 val EnableFauFTB = coreParams.EnableFauFTB 498 val FtbSize = coreParams.FtbSize 499 val FtbWays = coreParams.FtbWays 500 val RasSize = coreParams.RasSize 501 val RasSpecSize = coreParams.RasSpecSize 502 val RasCtrSize = coreParams.RasCtrSize 503 504 def getBPDComponents(resp_in: BranchPredictionResp, p: Parameters) = { 505 coreParams.branchPredictor(resp_in, p) 506 } 507 val numBr = coreParams.numBr 508 val TageTableInfos = coreParams.TageTableInfos 509 val TageBanks = coreParams.numBr 510 val SCNRows = coreParams.SCNRows 511 val SCCtrBits = coreParams.SCCtrBits 512 val SCHistLens = coreParams.SCHistLens 513 val SCNTables = coreParams.SCNTables 514 515 val SCTableInfos = Seq.fill(SCNTables)((SCNRows, SCCtrBits)) zip SCHistLens map { 516 case ((n, cb), h) => (n, cb, h) 517 } 518 val ITTageTableInfos = coreParams.ITTageTableInfos 519 type FoldedHistoryInfo = Tuple2[Int, Int] 520 val foldedGHistInfos = 521 (TageTableInfos.map{ case (nRows, h, t) => 522 if (h > 0) 523 Set((h, min(log2Ceil(nRows/numBr), h)), (h, min(h, t)), (h, min(h, t-1))) 524 else 525 Set[FoldedHistoryInfo]() 526 }.reduce(_++_).toSet ++ 527 SCTableInfos.map{ case (nRows, _, h) => 528 if (h > 0) 529 Set((h, min(log2Ceil(nRows/TageBanks), h))) 530 else 531 Set[FoldedHistoryInfo]() 532 }.reduce(_++_).toSet ++ 533 ITTageTableInfos.map{ case (nRows, h, t) => 534 if (h > 0) 535 Set((h, min(log2Ceil(nRows), h)), (h, min(h, t)), (h, min(h, t-1))) 536 else 537 Set[FoldedHistoryInfo]() 538 }.reduce(_++_) ++ 539 Set[FoldedHistoryInfo]((UbtbGHRLength, log2Ceil(UbtbSize))) 540 ).toList 541 542 543 544 val CacheLineSize = coreParams.CacheLineSize 545 val CacheLineHalfWord = CacheLineSize / 16 546 val ExtHistoryLength = HistoryLength + 64 547 val ICacheECCForceError = coreParams.ICacheECCForceError 548 val IBufSize = coreParams.IBufSize 549 val IBufNBank = coreParams.IBufNBank 550 val backendParams: BackendParams = coreParams.backendParams 551 val DecodeWidth = coreParams.DecodeWidth 552 val RenameWidth = coreParams.RenameWidth 553 val CommitWidth = coreParams.CommitWidth 554 val MaxUopSize = coreParams.MaxUopSize 555 val EnableRenameSnapshot = coreParams.EnableRenameSnapshot 556 val RenameSnapshotNum = coreParams.RenameSnapshotNum 557 val FtqSize = coreParams.FtqSize 558 val EnableLoadFastWakeUp = coreParams.EnableLoadFastWakeUp 559 val IntLogicRegs = coreParams.IntLogicRegs 560 val FpLogicRegs = coreParams.FpLogicRegs 561 val VecLogicRegs = coreParams.VecLogicRegs 562 val VCONFIG_IDX = coreParams.VCONFIG_IDX 563 val IntPhyRegs = coreParams.intPreg.numEntries 564 val VfPhyRegs = coreParams.vfPreg.numEntries 565 val MaxPhyPregs = IntPhyRegs max VfPhyRegs 566 val PhyRegIdxWidth = log2Up(IntPhyRegs) max log2Up(VfPhyRegs) 567 val RobSize = coreParams.RobSize 568 val RabSize = coreParams.RabSize 569 val VTypeBufferSize = coreParams.VTypeBufferSize 570 val IntRefCounterWidth = log2Ceil(RobSize) 571 val LSQEnqWidth = coreParams.dpParams.LsDqDeqWidth 572 val LSQLdEnqWidth = LSQEnqWidth min backendParams.numLoadDp 573 val LSQStEnqWidth = LSQEnqWidth min backendParams.numStoreDp 574 val VirtualLoadQueueSize = coreParams.VirtualLoadQueueSize 575 val LoadQueueRARSize = coreParams.LoadQueueRARSize 576 val LoadQueueRAWSize = coreParams.LoadQueueRAWSize 577 val RollbackGroupSize = coreParams.RollbackGroupSize 578 val LoadQueueReplaySize = coreParams.LoadQueueReplaySize 579 val LoadUncacheBufferSize = coreParams.LoadUncacheBufferSize 580 val LoadQueueNWriteBanks = coreParams.LoadQueueNWriteBanks 581 val StoreQueueSize = coreParams.StoreQueueSize 582 val StoreQueueNWriteBanks = coreParams.StoreQueueNWriteBanks 583 val StoreQueueForwardWithMask = coreParams.StoreQueueForwardWithMask 584 val VlsQueueSize = coreParams.VlsQueueSize 585 val dpParams = coreParams.dpParams 586 587 def MemIQSizeMax = backendParams.memSchdParams.get.issueBlockParams.map(_.numEntries).max 588 def IQSizeMax = backendParams.allSchdParams.map(_.issueBlockParams.map(_.numEntries).max).max 589 590 val NumRedirect = backendParams.numRedirect 591 val BackendRedirectNum = NumRedirect + 2 //2: ldReplay + Exception 592 val FtqRedirectAheadNum = NumRedirect 593 val LoadPipelineWidth = coreParams.LoadPipelineWidth 594 val StorePipelineWidth = coreParams.StorePipelineWidth 595 val VecLoadPipelineWidth = coreParams.VecLoadPipelineWidth 596 val VecStorePipelineWidth = coreParams.VecStorePipelineWidth 597 val VecMemSrcInWidth = coreParams.VecMemSrcInWidth 598 val VecMemInstWbWidth = coreParams.VecMemInstWbWidth 599 val VecMemDispatchWidth = coreParams.VecMemDispatchWidth 600 val StoreBufferSize = coreParams.StoreBufferSize 601 val StoreBufferThreshold = coreParams.StoreBufferThreshold 602 val EnsbufferWidth = coreParams.EnsbufferWidth 603 val VlMergeBufferSize = coreParams.VlMergeBufferSize 604 val VsMergeBufferSize = coreParams.VsMergeBufferSize 605 val UopWritebackWidth = coreParams.UopWritebackWidth 606 val splitBufferSize = coreParams.splitBufferSize 607 val UncacheBufferSize = coreParams.UncacheBufferSize 608 val EnableLoadToLoadForward = coreParams.EnableLoadToLoadForward 609 val EnableFastForward = coreParams.EnableFastForward 610 val EnableLdVioCheckAfterReset = coreParams.EnableLdVioCheckAfterReset 611 val EnableSoftPrefetchAfterReset = coreParams.EnableSoftPrefetchAfterReset 612 val EnableCacheErrorAfterReset = coreParams.EnableCacheErrorAfterReset 613 val EnableAccurateLoadError = coreParams.EnableAccurateLoadError 614 val EnableUncacheWriteOutstanding = coreParams.EnableUncacheWriteOutstanding 615 val EnableStorePrefetchAtIssue = coreParams.EnableStorePrefetchAtIssue 616 val EnableStorePrefetchAtCommit = coreParams.EnableStorePrefetchAtCommit 617 val EnableAtCommitMissTrigger = coreParams.EnableAtCommitMissTrigger 618 val EnableStorePrefetchSMS = coreParams.EnableStorePrefetchSMS 619 val EnableStorePrefetchSPB = coreParams.EnableStorePrefetchSPB 620 val asidLen = coreParams.MMUAsidLen 621 val BTLBWidth = coreParams.LoadPipelineWidth + coreParams.StorePipelineWidth 622 val refillBothTlb = coreParams.refillBothTlb 623 val iwpuParam = coreParams.iwpuParameters 624 val dwpuParam = coreParams.dwpuParameters 625 val itlbParams = coreParams.itlbParameters 626 val ldtlbParams = coreParams.ldtlbParameters 627 val sttlbParams = coreParams.sttlbParameters 628 val hytlbParams = coreParams.hytlbParameters 629 val pftlbParams = coreParams.pftlbParameters 630 val btlbParams = coreParams.btlbParameters 631 val l2tlbParams = coreParams.l2tlbParameters 632 val NumPerfCounters = coreParams.NumPerfCounters 633 634 val instBytes = if (HasCExtension) 2 else 4 635 val instOffsetBits = log2Ceil(instBytes) 636 637 val icacheParameters = coreParams.icacheParameters 638 val dcacheParameters = coreParams.dcacheParametersOpt.getOrElse(DCacheParameters()) 639 640 // dcache block cacheline when lr for LRSCCycles - LRSCBackOff cycles 641 // for constrained LR/SC loop 642 val LRSCCycles = 64 643 // for lr storm 644 val LRSCBackOff = 8 645 646 // cache hierarchy configurations 647 val l1BusDataWidth = 256 648 649 // load violation predict 650 val ResetTimeMax2Pow = 20 //1078576 651 val ResetTimeMin2Pow = 10 //1024 652 // wait table parameters 653 val WaitTableSize = 1024 654 val MemPredPCWidth = log2Up(WaitTableSize) 655 val LWTUse2BitCounter = true 656 // store set parameters 657 val SSITSize = WaitTableSize 658 val LFSTSize = 32 659 val SSIDWidth = log2Up(LFSTSize) 660 val LFSTWidth = 4 661 val StoreSetEnable = true // LWT will be disabled if SS is enabled 662 val LFSTEnable = true 663 664 val PCntIncrStep: Int = 6 665 val numPCntHc: Int = 25 666 val numPCntPtw: Int = 19 667 668 val numCSRPCntFrontend = 8 669 val numCSRPCntCtrl = 8 670 val numCSRPCntLsu = 8 671 val numCSRPCntHc = 5 672 val printEventCoding = true 673 674 // Parameters for Sdtrig extension 675 protected val TriggerNum = 4 676 protected val TriggerChainMaxLength = 2 677} 678