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