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