Parameters.scala 20.4 KB
Newer Older
L
Lemover 已提交
1 2
/***************************************************************************************
* Copyright (c) 2020-2021 Institute of Computing Technology, Chinese Academy of Sciences
Y
Yinan Xu 已提交
3
* Copyright (c) 2020-2021 Peng Cheng Laboratory
L
Lemover 已提交
4 5 6 7 8 9 10 11 12 13 14 15 16
*
* XiangShan is licensed under Mulan PSL v2.
* You can use this software according to the terms and conditions of the Mulan PSL v2.
* You may obtain a copy of Mulan PSL v2 at:
*          http://license.coscl.org.cn/MulanPSL2
*
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
* EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
* MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
*
* See the Mulan PSL v2 for more details.
***************************************************************************************/

17 18 19 20 21
package xiangshan

import chipsalliance.rocketchip.config.{Field, Parameters}
import chisel3._
import chisel3.util._
X
Xuan Hu 已提交
22 23
import huancun._
import system.SoCParamsKey
X
Xuan Hu 已提交
24 25
import xiangshan.backend.datapath.RdConfig._
import xiangshan.backend.datapath.WbConfig._
26
import xiangshan.backend.dispatch.DispatchParameters
X
Xuan Hu 已提交
27 28 29 30 31
import xiangshan.backend.exu.ExeUnitParams
import xiangshan.backend.fu.FuConfig._
import xiangshan.backend.issue.{IntScheduler, IssueBlockParams, MemScheduler, SchdBlockParams, SchedulerType, VfScheduler}
import xiangshan.backend.regfile.{IntPregParams, PregParams, VfPregParams}
import xiangshan.backend.BackendParams
32
import xiangshan.cache.DCacheParameters
X
Xuan Hu 已提交
33 34
import xiangshan.cache.mmu.{L2TLBParameters, TLBParameters}
import xiangshan.frontend._
35
import xiangshan.frontend.icache.ICacheParameters
X
Xuan Hu 已提交
36

37
import freechips.rocketchip.diplomacy.AddressSet
38
import system.SoCParamsKey
39 40
import huancun._
import huancun.debug._
L
LinJiawei 已提交
41 42
import xiangshan.mem.prefetch.{PrefetcherParams, SMSParams}

43
import scala.math.min
J
Jiawei Lin 已提交
44 45 46

case object XSTileKey extends Field[Seq[XSCoreParameters]]

47 48 49 50 51 52 53
case object XSCoreParamsKey extends Field[XSCoreParameters]

case class XSCoreParameters
(
  HasPrefetch: Boolean = false,
  HartId: Int = 0,
  XLEN: Int = 64,
54
  VLEN: Int = 128,
F
fdy 已提交
55
  ELEN: Int = 64,
56 57 58 59 60 61 62 63
  HasMExtension: Boolean = true,
  HasCExtension: Boolean = true,
  HasDiv: Boolean = true,
  HasICache: Boolean = true,
  HasDCache: Boolean = true,
  AddrBits: Int = 64,
  VAddrBits: Int = 39,
  HasFPU: Boolean = true,
Z
Ziyue Zhang 已提交
64
  HasVPU: Boolean = true,
Z
zhanglinjuan 已提交
65
  HasCustomCSRCacheOp: Boolean = true,
66
  FetchWidth: Int = 8,
67
  AsidLength: Int = 16,
68 69 70 71 72
  EnableBPU: Boolean = true,
  EnableBPD: Boolean = true,
  EnableRAS: Boolean = true,
  EnableLB: Boolean = false,
  EnableLoop: Boolean = true,
73
  EnableSC: Boolean = true,
74 75
  EnbaleTlbDebug: Boolean = false,
  EnableJal: Boolean = false,
76
  EnableFauFTB: Boolean = true,
77
  UbtbGHRLength: Int = 4,
78
  // HistoryLength: Int = 512,
79
  EnableGHistDiff: Boolean = true,
80
  UbtbSize: Int = 256,
81
  FtbSize: Int = 2048,
82
  RasSize: Int = 32,
83
  CacheLineSize: Int = 512,
84
  FtbWays: Int = 4,
85 86
  TageTableInfos: Seq[Tuple3[Int,Int,Int]] =
  //       Sets  Hist   Tag
L
Lingrui98 已提交
87 88 89 90 91 92 93 94 95 96 97 98
    // Seq(( 2048,    2,    8),
    //     ( 2048,    9,    8),
    //     ( 2048,   13,    8),
    //     ( 2048,   20,    8),
    //     ( 2048,   26,    8),
    //     ( 2048,   44,    8),
    //     ( 2048,   73,    8),
    //     ( 2048,  256,    8)),
    Seq(( 4096,    8,    8),
        ( 4096,   13,    8),
        ( 4096,   32,    8),
        ( 4096,  119,    8)),
99 100
  ITTageTableInfos: Seq[Tuple3[Int,Int,Int]] =
  //      Sets  Hist   Tag
L
Lingrui98 已提交
101
    Seq(( 256,    4,    9),
102
        ( 256,    8,    9),
L
Lingrui98 已提交
103
        ( 512,   13,    9),
104
        ( 512,   16,    9),
105
        ( 512,   32,    9)),
106 107
  SCNRows: Int = 512,
  SCNTables: Int = 4,
108
  SCCtrBits: Int = 6,
109
  SCHistLens: Seq[Int] = Seq(0, 4, 10, 16),
110
  numBr: Int = 2,
111 112
  branchPredictor: Function2[BranchPredictionResp, Parameters, Tuple2[Seq[BasePredictor], BranchPredictionResp]] =
    ((resp_in: BranchPredictionResp, p: Parameters) => {
Z
zoujr 已提交
113
      val ftb = Module(new FTB()(p))
L
Lingrui98 已提交
114
      val ubtb =Module(new FauFTB()(p))
115
      // val bim = Module(new BIM()(p))
116
      val tage = Module(new Tage_SC()(p))
L
Lingrui98 已提交
117
      val ras = Module(new RAS()(p))
118
      val ittage = Module(new ITTage()(p))
119
      val preds = Seq(ubtb, tage, ftb, ittage, ras)
Z
zoujr 已提交
120 121 122 123 124 125 126
      preds.map(_.io := DontCare)

      // ubtb.io.resp_in(0)  := resp_in
      // bim.io.resp_in(0)   := ubtb.io.resp
      // btb.io.resp_in(0)   := bim.io.resp
      // tage.io.resp_in(0)  := btb.io.resp
      // loop.io.resp_in(0)  := tage.io.resp
127
      ubtb.io.in.bits.resp_in(0) := resp_in
L
Lingrui98 已提交
128 129 130 131
      tage.io.in.bits.resp_in(0) := ubtb.io.out
      ftb.io.in.bits.resp_in(0)  := tage.io.out
      ittage.io.in.bits.resp_in(0)  := ftb.io.out
      ras.io.in.bits.resp_in(0) := ittage.io.out
Y
Yinan Xu 已提交
132

L
Lingrui98 已提交
133
      (preds, ras.io.out)
Z
zoujr 已提交
134
    }),
135 136 137 138
  IBufSize: Int = 48,
  DecodeWidth: Int = 6,
  RenameWidth: Int = 6,
  CommitWidth: Int = 6,
139
  MaxUopSize: Int = 65,
L
Lingrui98 已提交
140
  FtqSize: Int = 64,
141
  EnableLoadFastWakeUp: Boolean = true, // NOTE: not supported now, make it false
F
fdy 已提交
142
  IntLogicRegs: Int = 32,
F
fdy 已提交
143
  FpLogicRegs: Int = 33,
144
  VecLogicRegs: Int = 47,
145
  NRPhyRegs: Int = 192,
X
Xuan Hu 已提交
146 147
  IntPhyRegs: Int = 192,
  VfPhyRegs: Int = 192,
148
  LoadQueueSize: Int = 80,
149
  LoadQueueNWriteBanks: Int = 8,
150
  StoreQueueSize: Int = 64,
151
  StoreQueueNWriteBanks: Int = 8,
W
William Wang 已提交
152
  VlsQueueSize: Int = 8,
153
  RobSize: Int = 256,
F
fdy 已提交
154
  RabSize: Int = 256,
155 156 157 158
  dpParams: DispatchParameters = DispatchParameters(
    IntDqSize = 16,
    FpDqSize = 16,
    LsDqSize = 16,
X
Xuan Hu 已提交
159 160 161
    IntDqDeqWidth = 6,
    FpDqDeqWidth = 6,
    LsDqDeqWidth = 6,
162
  ),
X
Xuan Hu 已提交
163
  intPreg: PregParams = IntPregParams(
X
Xuan Hu 已提交
164
    numEntries = 64,
X
Xuan Hu 已提交
165 166
    numRead = 14,
    numWrite = 8,
167
  ),
X
Xuan Hu 已提交
168
  vfPreg: VfPregParams = VfPregParams(
X
Xuan Hu 已提交
169
    numEntries = 64,
X
Xuan Hu 已提交
170 171 172
    numRead = 14,
    numWrite = 8,
  ),
L
LinJiawei 已提交
173
  prefetcher: Option[PrefetcherParams] = Some(SMSParams()),
174 175
  LoadPipelineWidth: Int = 2,
  StorePipelineWidth: Int = 2,
W
William Wang 已提交
176 177 178
  VecMemSrcInWidth: Int = 2,
  VecMemInstWbWidth: Int = 1,
  VecMemDispatchWidth: Int = 1,
179
  StoreBufferSize: Int = 16,
180
  StoreBufferThreshold: Int = 7,
181
  EnsbufferWidth: Int = 2,
182
  UncacheBufferSize: Int = 4,
183
  EnableLoadToLoadForward: Boolean = true,
W
William Wang 已提交
184
  EnableFastForward: Boolean = false,
185
  EnableLdVioCheckAfterReset: Boolean = true,
186 187
  EnableSoftPrefetchAfterReset: Boolean = true,
  EnableCacheErrorAfterReset: Boolean = true,
188
  EnableDCacheWPU: Boolean = false,
189
  EnableAccurateLoadError: Boolean = true,
190
  EnableUncacheWriteOutstanding: Boolean = false,
191
  MMUAsidLen: Int = 16, // max is 16, 0 is not supported now
192
  ReSelectLen: Int = 7, // load replay queue replay select counter len
193 194 195 196
  itlbParameters: TLBParameters = TLBParameters(
    name = "itlb",
    fetchi = true,
    useDmode = false,
197
    normalNWays = 32,
198
    normalReplacer = Some("plru"),
199
    superNWays = 4,
200
    superReplacer = Some("plru")
201 202 203
  ),
  ldtlbParameters: TLBParameters = TLBParameters(
    name = "ldtlb",
204
    normalNSets = 64,
205 206 207
    normalNWays = 1,
    normalAssociative = "sa",
    normalReplacer = Some("setplru"),
208
    superNWays = 16,
209
    normalAsVictim = true,
210
    outReplace = false,
211
    partialStaticPMP = true,
212
    outsideRecvFlush = true,
213
    saveLevel = true
214 215 216
  ),
  sttlbParameters: TLBParameters = TLBParameters(
    name = "sttlb",
217
    normalNSets = 64,
218 219 220
    normalNWays = 1,
    normalAssociative = "sa",
    normalReplacer = Some("setplru"),
221
    superNWays = 16,
222
    normalAsVictim = true,
223
    outReplace = false,
224
    partialStaticPMP = true,
225
    outsideRecvFlush = true,
226
    saveLevel = true
227
  ),
228 229 230 231 232 233 234 235 236 237 238 239 240
  pftlbParameters: TLBParameters = TLBParameters(
    name = "pftlb",
    normalNSets = 64,
    normalNWays = 1,
    normalAssociative = "sa",
    normalReplacer = Some("setplru"),
    superNWays = 16,
    normalAsVictim = true,
    outReplace = false,
    partialStaticPMP = true,
    outsideRecvFlush = true,
    saveLevel = true
  ),
241
  refillBothTlb: Boolean = false,
242 243 244 245 246 247
  btlbParameters: TLBParameters = TLBParameters(
    name = "btlb",
    normalNSets = 1,
    normalNWays = 64,
    superNWays = 4,
  ),
248
  l2tlbParameters: L2TLBParameters = L2TLBParameters(),
249
  NumPerfCounters: Int = 16,
250 251 252 253
  icacheParameters: ICacheParameters = ICacheParameters(
    tagECC = Some("parity"),
    dataECC = Some("parity"),
    replacer = Some("setplru"),
254
    nMissEntries = 2,
255
    nProbeEntries = 2,
256 257
    nPrefetchEntries = 2,
    hasPrefetch = true,
258
  ),
J
Jiawei Lin 已提交
259
  dcacheParametersOpt: Option[DCacheParameters] = Some(DCacheParameters(
260 261 262 263
    tagECC = Some("secded"),
    dataECC = Some("secded"),
    replacer = Some("setplru"),
    nMissEntries = 16,
W
William Wang 已提交
264 265
    nProbeEntries = 8,
    nReleaseEntries = 18
J
Jiawei Lin 已提交
266 267
  )),
  L2CacheParamsOpt: Option[HCCacheParameters] = Some(HCCacheParameters(
268 269 270 271
    name = "l2",
    level = 2,
    ways = 8,
    sets = 1024, // default 512KB L2
L
LinJiawei 已提交
272
    prefetch = Some(huancun.prefetch.PrefetchReceiverParams())
J
Jiawei Lin 已提交
273
  )),
J
Jiawei Lin 已提交
274
  L2NBanks: Int = 1,
275
  usePTWRepeater: Boolean = false,
H
Haoyuan Feng 已提交
276 277
  softTLB: Boolean = false, // dpi-c l1tlb debug only
  softPTW: Boolean = false, // dpi-c l2tlb debug only
278
  softPTWDelay: Int = 1
279
){
280 281
  def vlWidth = log2Up(VLEN) + 1

282 283 284
  val allHistLens = SCHistLens ++ ITTageTableInfos.map(_._2) ++ TageTableInfos.map(_._2) :+ UbtbGHRLength
  val HistoryLength = allHistLens.max + numBr * FtqSize + 9 // 256 for the predictor configs now

X
Xuan Hu 已提交
285 286 287 288 289 290 291
  def intSchdParams = {
    implicit val schdType: SchedulerType = IntScheduler()
    val pregBits = intPreg.addrWidth
    val numRfRead = intPreg.numRead
    val numRfWrite = intPreg.numWrite
    SchdBlockParams(Seq(
      IssueBlockParams(Seq(
X
Xuan Hu 已提交
292 293
        ExeUnitParams(Seq(AluCfg, MulCfg, BkuCfg), Seq(IntWB(port = 0, 0)), Seq(Seq(IntRD(0, 2)), Seq(IntRD(1, 2)))),
        ExeUnitParams(Seq(AluCfg, MulCfg, BkuCfg), Seq(IntWB(port = 1, 0)), Seq(Seq(IntRD(0, 1)), Seq(IntRD(1, 1)))),
X
Xuan Hu 已提交
294 295
      ), numEntries = 8, pregBits = pregBits, numWakeupFromWB = numRfWrite, numEnq = 2),
      IssueBlockParams(Seq(
X
Xuan Hu 已提交
296 297
        ExeUnitParams(Seq(DivCfg), Seq(IntWB(port = 2, 0)), Seq(Seq(IntRD(4, 0)), Seq(IntRD(5, 0)))),
        ExeUnitParams(Seq(DivCfg), Seq(IntWB(port = 3, 0)), Seq(Seq(IntRD(6, 0)), Seq(IntRD(7, 0)))),
X
Xuan Hu 已提交
298 299
      ), numEntries = 8, pregBits = pregBits, numWakeupFromWB = numRfWrite, numEnq = 2),
      IssueBlockParams(Seq(
F
fdy 已提交
300 301
        ExeUnitParams(Seq(BrhCfg, JmpCfg, CsrCfg, FenceCfg), Seq(IntWB(port = 4, 0)), Seq(Seq(IntRD(2, 1)), Seq(IntRD(3, 1)))),
        ExeUnitParams(Seq(BrhCfg), Seq(), Seq(Seq(IntRD(6, 1)), Seq(IntRD(4, 1)))),
X
Xuan Hu 已提交
302 303
      ), numEntries = 8, pregBits = pregBits, numWakeupFromWB = numRfWrite, numEnq = 2),
      IssueBlockParams(Seq(
F
fdy 已提交
304
        ExeUnitParams(Seq(I2fCfg, VSetRiWiCfg, VSetRiWvfCfg), Seq(VecWB(port = 6, Int.MaxValue), IntWB(port = 7, 0)), Seq(Seq(IntRD(6, 0)), Seq(IntRD(7, 0)))),
X
Xuan Hu 已提交
305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321
      ), numEntries = 8, pregBits = pregBits, numWakeupFromWB = numRfWrite, numEnq = 2)
    ),
      numPregs = intPreg.numEntries,
      numRfReadWrite = Some((numRfRead, numRfWrite)),
      numDeqOutside = 0,
      schdType = schdType,
      rfDataWidth = intPreg.dataCfg.dataWidth,
      numUopIn = dpParams.IntDqDeqWidth,
    )
  }
  def vfSchdParams = {
    implicit val schdType: SchedulerType = VfScheduler()
    val pregBits = vfPreg.addrWidth
    val numRfRead = vfPreg.numRead
    val numRfWrite = vfPreg.numWrite
    SchdBlockParams(Seq(
      IssueBlockParams(Seq(
X
Xuan Hu 已提交
322 323
        ExeUnitParams(Seq(FmacCfg), Seq(VecWB(port = 0, 0)), Seq(Seq(VfRD(0, 0)), Seq(VfRD(1, 0)), Seq(VfRD(2, 0)))),
        ExeUnitParams(Seq(FmacCfg), Seq(VecWB(port = 1, 0)), Seq(Seq(VfRD(3, 0)), Seq(VfRD(4, 0)), Seq(VfRD(5, 0)))),
X
Xuan Hu 已提交
324 325
      ), numEntries = 8, pregBits = pregBits, numWakeupFromWB = numRfWrite, numEnq = 4),
      IssueBlockParams(Seq(
F
fdy 已提交
326
        ExeUnitParams(Seq(F2fCfg, F2iCfg, FDivSqrtCfg, VSetRvfWvfCfg), Seq(VecWB(port = 2, 0), IntWB(port = 7, 0)), Seq(Seq(VfRD(6, 0)), Seq(VfRD(7, 0)))),
X
Xuan Hu 已提交
327
      ), numEntries = 8, pregBits = pregBits, numWakeupFromWB = numRfWrite, numEnq = 4),
X
Xuan Hu 已提交
328

X
Xuan Hu 已提交
329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344
    ),
      numPregs = vfPreg.numEntries,
      numRfReadWrite = Some((numRfRead, numRfWrite)),
      numDeqOutside = 0,
      schdType = schdType,
      rfDataWidth = vfPreg.dataCfg.dataWidth,
      numUopIn = dpParams.FpDqDeqWidth,
    )
  }
  def memSchdParams = {
    implicit val schdType: SchedulerType = MemScheduler()
    val pregBits = vfPreg.addrWidth max intPreg.addrWidth
    val rfDataWidth = 64

    SchdBlockParams(Seq(
      IssueBlockParams(Seq(
X
Xuan Hu 已提交
345 346
        ExeUnitParams(Seq(LduCfg), Seq(IntWB(5, 0), VecWB(4, 0)), Seq(Seq(IntRD(8, 0)))),
        ExeUnitParams(Seq(LduCfg), Seq(IntWB(6, 0), VecWB(5, 0)), Seq(Seq(IntRD(9, 0)))),
X
Xuan Hu 已提交
347
      ), numEntries = 8, pregBits = pregBits, numWakeupFromWB = 16, numEnq = 2),
X
Xuan Hu 已提交
348
      IssueBlockParams(Seq(
F
fdy 已提交
349 350
        ExeUnitParams(Seq(StaCfg, MouCfg), Seq(IntWB(5, 1)), Seq(Seq(IntRD(10, 0)))),
        ExeUnitParams(Seq(StaCfg, MouCfg), Seq(IntWB(6, 1)), Seq(Seq(IntRD(11, 0)))),
X
Xuan Hu 已提交
351
      ), numEntries = 8, pregBits = pregBits, numWakeupFromWB = 16, numEnq = 2),
X
Xuan Hu 已提交
352
      IssueBlockParams(Seq(
F
fdy 已提交
353 354
        ExeUnitParams(Seq(StdCfg, MoudCfg), Seq(), Seq(Seq(IntRD(12, 0), VfRD(12, 0)))),
        ExeUnitParams(Seq(StdCfg, MoudCfg), Seq(), Seq(Seq(IntRD(13, 0), VfRD(13, 0)))),
X
Xuan Hu 已提交
355
      ), numEntries = 8, pregBits = pregBits, numWakeupFromWB = 16, numEnq = 2),
X
Xuan Hu 已提交
356
    ),
X
Xuan Hu 已提交
357
      numPregs = intPreg.numEntries max vfPreg.numEntries,
X
Xuan Hu 已提交
358 359 360 361 362 363 364
      numRfReadWrite = None,
      numDeqOutside = 0,
      schdType = schdType,
      rfDataWidth = rfDataWidth,
      numUopIn = dpParams.LsDqDeqWidth,
    )
  }
365

X
Xuan Hu 已提交
366
  def backendParams: BackendParams = backend.BackendParams(Map(
X
Xuan Hu 已提交
367 368 369 370 371 372 373
    IntScheduler() -> intSchdParams,
    VfScheduler() -> vfSchdParams,
    MemScheduler() -> memSchdParams,
  ), Seq(
    intPreg,
    vfPreg,
  ))
374 375 376 377 378 379
}

case object DebugOptionsKey extends Field[DebugOptions]

case class DebugOptions
(
380 381
  FPGAPlatform: Boolean = false,
  EnableDifftest: Boolean = false,
382
  AlwaysBasicDiff: Boolean = true,
383
  EnableDebug: Boolean = false,
384
  EnablePerfDebug: Boolean = true,
385 386
  UseDRAMSim: Boolean = false,
  EnableTopDown: Boolean = false
387 388 389 390 391 392
)

trait HasXSParameter {

  implicit val p: Parameters

393 394
  val PAddrBits = p(SoCParamsKey).PAddrBits // PAddrBits is Phyical Memory addr bits

395 396 397 398
  val coreParams = p(XSCoreParamsKey)
  val env = p(DebugOptionsKey)

  val XLEN = coreParams.XLEN
399
  val VLEN = coreParams.VLEN
F
fdy 已提交
400
  val ELEN = coreParams.ELEN
401 402 403 404 405 406 407 408 409 410 411
  val minFLen = 32
  val fLen = 64
  def xLen = XLEN

  val HasMExtension = coreParams.HasMExtension
  val HasCExtension = coreParams.HasCExtension
  val HasDiv = coreParams.HasDiv
  val HasIcache = coreParams.HasICache
  val HasDcache = coreParams.HasDCache
  val AddrBits = coreParams.AddrBits // AddrBits is used in some cases
  val VAddrBits = coreParams.VAddrBits // VAddrBits is Virtual Memory addr bits
412
  val AsidLength = coreParams.AsidLength
413
  val ReSelectLen = coreParams.ReSelectLen
414 415 416 417
  val AddrBytes = AddrBits / 8 // unused
  val DataBits = XLEN
  val DataBytes = DataBits / 8
  val HasFPU = coreParams.HasFPU
Z
Ziyue Zhang 已提交
418
  val HasVPU = coreParams.HasVPU
Z
zhanglinjuan 已提交
419
  val HasCustomCSRCacheOp = coreParams.HasCustomCSRCacheOp
420 421 422 423 424 425 426 427 428 429
  val FetchWidth = coreParams.FetchWidth
  val PredictWidth = FetchWidth * (if (HasCExtension) 2 else 1)
  val EnableBPU = coreParams.EnableBPU
  val EnableBPD = coreParams.EnableBPD // enable backing predictor(like Tage) in BPUStage3
  val EnableRAS = coreParams.EnableRAS
  val EnableLB = coreParams.EnableLB
  val EnableLoop = coreParams.EnableLoop
  val EnableSC = coreParams.EnableSC
  val EnbaleTlbDebug = coreParams.EnbaleTlbDebug
  val HistoryLength = coreParams.HistoryLength
430
  val EnableGHistDiff = coreParams.EnableGHistDiff
431
  val UbtbGHRLength = coreParams.UbtbGHRLength
432
  val UbtbSize = coreParams.UbtbSize
433
  val EnableFauFTB = coreParams.EnableFauFTB
434 435
  val FtbSize = coreParams.FtbSize
  val FtbWays = coreParams.FtbWays
436
  val RasSize = coreParams.RasSize
Z
zoujr 已提交
437

438 439
  def getBPDComponents(resp_in: BranchPredictionResp, p: Parameters) = {
    coreParams.branchPredictor(resp_in, p)
Z
zoujr 已提交
440
  }
441 442
  val numBr = coreParams.numBr
  val TageTableInfos = coreParams.TageTableInfos
L
Lingrui98 已提交
443
  val TageBanks = coreParams.numBr
444 445
  val SCNRows = coreParams.SCNRows
  val SCCtrBits = coreParams.SCCtrBits
L
Lingrui98 已提交
446 447
  val SCHistLens = coreParams.SCHistLens
  val SCNTables = coreParams.SCNTables
448

L
Lingrui98 已提交
449 450
  val SCTableInfos = Seq.fill(SCNTables)((SCNRows, SCCtrBits)) zip SCHistLens map {
    case ((n, cb), h) => (n, cb, h)
451 452 453 454
  }
  val ITTageTableInfos = coreParams.ITTageTableInfos
  type FoldedHistoryInfo = Tuple2[Int, Int]
  val foldedGHistInfos =
455
    (TageTableInfos.map{ case (nRows, h, t) =>
456
      if (h > 0)
457
        Set((h, min(log2Ceil(nRows/numBr), h)), (h, min(h, t)), (h, min(h, t-1)))
458 459
      else
        Set[FoldedHistoryInfo]()
460
    }.reduce(_++_).toSet ++
L
Lingrui98 已提交
461
    SCTableInfos.map{ case (nRows, _, h) =>
462
      if (h > 0)
L
Lingrui98 已提交
463
        Set((h, min(log2Ceil(nRows/TageBanks), h)))
464 465
      else
        Set[FoldedHistoryInfo]()
L
Lingrui98 已提交
466
    }.reduce(_++_).toSet ++
467 468 469 470 471
    ITTageTableInfos.map{ case (nRows, h, t) =>
      if (h > 0)
        Set((h, min(log2Ceil(nRows), h)), (h, min(h, t)), (h, min(h, t-1)))
      else
        Set[FoldedHistoryInfo]()
472 473 474
    }.reduce(_++_) ++
      Set[FoldedHistoryInfo]((UbtbGHRLength, log2Ceil(UbtbSize)))
    ).toList
475

476

Z
zoujr 已提交
477

478 479 480 481 482 483 484
  val CacheLineSize = coreParams.CacheLineSize
  val CacheLineHalfWord = CacheLineSize / 16
  val ExtHistoryLength = HistoryLength + 64
  val IBufSize = coreParams.IBufSize
  val DecodeWidth = coreParams.DecodeWidth
  val RenameWidth = coreParams.RenameWidth
  val CommitWidth = coreParams.CommitWidth
F
fdy 已提交
485
  val MaxUopSize = coreParams.MaxUopSize
486 487
  val FtqSize = coreParams.FtqSize
  val EnableLoadFastWakeUp = coreParams.EnableLoadFastWakeUp
F
fdy 已提交
488 489 490
  val IntLogicRegs = coreParams.IntLogicRegs
  val FpLogicRegs = coreParams.FpLogicRegs
  val VecLogicRegs = coreParams.VecLogicRegs
491 492
  val NRPhyRegs = coreParams.NRPhyRegs
  val PhyRegIdxWidth = log2Up(NRPhyRegs)
X
Xuan Hu 已提交
493 494 495 496
  val IntPhyRegs = coreParams.IntPhyRegs
  val VfPhyRegs = coreParams.VfPhyRegs
  val IntPregIdxWidth = log2Up(IntPhyRegs)
  val VfPregIdxWidth = log2Up(VfPhyRegs)
Y
Yinan Xu 已提交
497
  val RobSize = coreParams.RobSize
F
fdy 已提交
498
  val RabSize = coreParams.RabSize
499
  val IntRefCounterWidth = log2Ceil(RobSize)
500
  val LoadQueueSize = coreParams.LoadQueueSize
501
  val LoadQueueNWriteBanks = coreParams.LoadQueueNWriteBanks
502
  val StoreQueueSize = coreParams.StoreQueueSize
503
  val StoreQueueNWriteBanks = coreParams.StoreQueueNWriteBanks
W
William Wang 已提交
504
  val VlsQueueSize = coreParams.VlsQueueSize
505
  val dpParams = coreParams.dpParams
X
Xuan Hu 已提交
506 507

  def backendParams: BackendParams = coreParams.backendParams
508 509
  def MemIQSizeMax = backendParams.memSchdParams.get.issueBlockParams.map(_.numEntries).max
  def IQSizeMax = backendParams.allSchdParams.map(_.issueBlockParams.map(_.numEntries).max).max
510 511
  val LoadPipelineWidth = coreParams.LoadPipelineWidth
  val StorePipelineWidth = coreParams.StorePipelineWidth
W
William Wang 已提交
512 513 514
  val VecMemSrcInWidth = coreParams.VecMemSrcInWidth
  val VecMemInstWbWidth = coreParams.VecMemInstWbWidth
  val VecMemDispatchWidth = coreParams.VecMemDispatchWidth
515
  val StoreBufferSize = coreParams.StoreBufferSize
516
  val StoreBufferThreshold = coreParams.StoreBufferThreshold
517
  val EnsbufferWidth = coreParams.EnsbufferWidth
518
  val UncacheBufferSize = coreParams.UncacheBufferSize
519
  val EnableLoadToLoadForward = coreParams.EnableLoadToLoadForward
520
  val EnableFastForward = coreParams.EnableFastForward
W
William Wang 已提交
521
  val EnableLdVioCheckAfterReset = coreParams.EnableLdVioCheckAfterReset
522 523
  val EnableSoftPrefetchAfterReset = coreParams.EnableSoftPrefetchAfterReset
  val EnableCacheErrorAfterReset = coreParams.EnableCacheErrorAfterReset
524
  val EnableDCacheWPU = coreParams.EnableDCacheWPU
525
  val EnableAccurateLoadError = coreParams.EnableAccurateLoadError
526
  val EnableUncacheWriteOutstanding = coreParams.EnableUncacheWriteOutstanding
527
  val asidLen = coreParams.MMUAsidLen
528
  val BTLBWidth = coreParams.LoadPipelineWidth + coreParams.StorePipelineWidth
529
  val refillBothTlb = coreParams.refillBothTlb
530 531 532
  val itlbParams = coreParams.itlbParameters
  val ldtlbParams = coreParams.ldtlbParameters
  val sttlbParams = coreParams.sttlbParameters
533
  val pftlbParams = coreParams.pftlbParameters
534
  val btlbParams = coreParams.btlbParameters
535
  val l2tlbParams = coreParams.l2tlbParameters
536 537 538 539 540
  val NumPerfCounters = coreParams.NumPerfCounters

  val instBytes = if (HasCExtension) 2 else 4
  val instOffsetBits = log2Ceil(instBytes)

541
  val icacheParameters = coreParams.icacheParameters
J
Jiawei Lin 已提交
542
  val dcacheParameters = coreParams.dcacheParametersOpt.getOrElse(DCacheParameters())
543

544
  // dcache block cacheline when lr for LRSCCycles - LRSCBackOff cycles
545
  // for constrained LR/SC loop
546 547 548
  val LRSCCycles = 64
  // for lr storm
  val LRSCBackOff = 8
549 550 551 552

  // cache hierarchy configurations
  val l1BusDataWidth = 256

553 554 555 556 557 558 559 560 561 562 563 564 565
  // load violation predict
  val ResetTimeMax2Pow = 20 //1078576
  val ResetTimeMin2Pow = 10 //1024
  // wait table parameters
  val WaitTableSize = 1024
  val MemPredPCWidth = log2Up(WaitTableSize)
  val LWTUse2BitCounter = true
  // store set parameters
  val SSITSize = WaitTableSize
  val LFSTSize = 32
  val SSIDWidth = log2Up(LFSTSize)
  val LFSTWidth = 4
  val StoreSetEnable = true // LWT will be disabled if SS is enabled
566

567 568 569 570 571 572 573 574
  val PCntIncrStep: Int = 6
  val numPCntHc: Int = 25
  val numPCntPtw: Int = 19

  val numCSRPCntFrontend = 8
  val numCSRPCntCtrl     = 8
  val numCSRPCntLsu      = 8
  val numCSRPCntHc       = 5
575
}