Parameters.scala 19.9 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,
55 56 57 58 59 60 61 62
  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 已提交
63
  HasVPU: Boolean = true,
Z
zhanglinjuan 已提交
64
  HasCustomCSRCacheOp: Boolean = true,
65
  FetchWidth: Int = 8,
66
  AsidLength: Int = 16,
67 68 69 70 71
  EnableBPU: Boolean = true,
  EnableBPD: Boolean = true,
  EnableRAS: Boolean = true,
  EnableLB: Boolean = false,
  EnableLoop: Boolean = true,
72
  EnableSC: Boolean = true,
73 74
  EnbaleTlbDebug: Boolean = false,
  EnableJal: Boolean = false,
75
  EnableFauFTB: Boolean = true,
76
  UbtbGHRLength: Int = 4,
77
  // HistoryLength: Int = 512,
78
  EnableGHistDiff: Boolean = true,
79
  UbtbSize: Int = 256,
80
  FtbSize: Int = 2048,
81
  RasSize: Int = 32,
82
  CacheLineSize: Int = 512,
83
  FtbWays: Int = 4,
84 85
  TageTableInfos: Seq[Tuple3[Int,Int,Int]] =
  //       Sets  Hist   Tag
L
Lingrui98 已提交
86 87 88 89 90 91 92 93 94 95 96 97
    // 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)),
98 99
  ITTageTableInfos: Seq[Tuple3[Int,Int,Int]] =
  //      Sets  Hist   Tag
L
Lingrui98 已提交
100
    Seq(( 256,    4,    9),
101
        ( 256,    8,    9),
L
Lingrui98 已提交
102
        ( 512,   13,    9),
103
        ( 512,   16,    9),
104
        ( 512,   32,    9)),
105 106
  SCNRows: Int = 512,
  SCNTables: Int = 4,
107
  SCCtrBits: Int = 6,
108
  SCHistLens: Seq[Int] = Seq(0, 4, 10, 16),
109
  numBr: Int = 2,
110 111
  branchPredictor: Function2[BranchPredictionResp, Parameters, Tuple2[Seq[BasePredictor], BranchPredictionResp]] =
    ((resp_in: BranchPredictionResp, p: Parameters) => {
Z
zoujr 已提交
112
      val ftb = Module(new FTB()(p))
L
Lingrui98 已提交
113
      val ubtb =Module(new FauFTB()(p))
114
      // val bim = Module(new BIM()(p))
115
      val tage = Module(new Tage_SC()(p))
L
Lingrui98 已提交
116
      val ras = Module(new RAS()(p))
117
      val ittage = Module(new ITTage()(p))
118
      val preds = Seq(ubtb, tage, ftb, ittage, ras)
Z
zoujr 已提交
119 120 121 122 123 124 125
      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
126
      ubtb.io.in.bits.resp_in(0) := resp_in
L
Lingrui98 已提交
127 128 129 130
      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 已提交
131

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

X
Xuan Hu 已提交
321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336
    ),
      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 已提交
337 338
        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 已提交
339
      ), numEntries = 8, pregBits = pregBits, numWakeupFromWB = 16, numEnq = 2),
X
Xuan Hu 已提交
340
      IssueBlockParams(Seq(
X
Xuan Hu 已提交
341 342
        ExeUnitParams(Seq(StaCfg), Seq(), Seq(Seq(IntRD(10, 0)))),
        ExeUnitParams(Seq(StaCfg), Seq(), Seq(Seq(IntRD(11, 0)))),
X
Xuan Hu 已提交
343
      ), numEntries = 8, pregBits = pregBits, numWakeupFromWB = 16, numEnq = 2),
X
Xuan Hu 已提交
344
      IssueBlockParams(Seq(
X
Xuan Hu 已提交
345 346
        ExeUnitParams(Seq(StdCfg), Seq(), Seq(Seq(IntRD(12, 0), VfRD(12, 0)))),
        ExeUnitParams(Seq(StdCfg), Seq(), Seq(Seq(IntRD(13, 0), VfRD(13, 0)))),
X
Xuan Hu 已提交
347
      ), numEntries = 8, pregBits = pregBits, numWakeupFromWB = 16, numEnq = 2),
X
Xuan Hu 已提交
348
    ),
X
Xuan Hu 已提交
349
      numPregs = intPreg.numEntries max vfPreg.numEntries,
X
Xuan Hu 已提交
350 351 352 353 354 355 356
      numRfReadWrite = None,
      numDeqOutside = 0,
      schdType = schdType,
      rfDataWidth = rfDataWidth,
      numUopIn = dpParams.LsDqDeqWidth,
    )
  }
357

X
Xuan Hu 已提交
358
  def backendParams: BackendParams = backend.BackendParams(Map(
X
Xuan Hu 已提交
359 360 361 362 363 364 365
    IntScheduler() -> intSchdParams,
    VfScheduler() -> vfSchdParams,
    MemScheduler() -> memSchdParams,
  ), Seq(
    intPreg,
    vfPreg,
  ))
366 367 368 369 370 371
}

case object DebugOptionsKey extends Field[DebugOptions]

case class DebugOptions
(
372 373
  FPGAPlatform: Boolean = false,
  EnableDifftest: Boolean = false,
374
  AlwaysBasicDiff: Boolean = true,
375
  EnableDebug: Boolean = false,
376
  EnablePerfDebug: Boolean = true,
377 378
  UseDRAMSim: Boolean = false,
  EnableTopDown: Boolean = false
379 380 381 382 383 384
)

trait HasXSParameter {

  implicit val p: Parameters

385 386
  val PAddrBits = p(SoCParamsKey).PAddrBits // PAddrBits is Phyical Memory addr bits

387 388 389 390
  val coreParams = p(XSCoreParamsKey)
  val env = p(DebugOptionsKey)

  val XLEN = coreParams.XLEN
391
  val VLEN = coreParams.VLEN
392 393 394 395 396 397 398 399 400 401 402
  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
403
  val AsidLength = coreParams.AsidLength
404
  val ReSelectLen = coreParams.ReSelectLen
405 406 407 408
  val AddrBytes = AddrBits / 8 // unused
  val DataBits = XLEN
  val DataBytes = DataBits / 8
  val HasFPU = coreParams.HasFPU
Z
Ziyue Zhang 已提交
409
  val HasVPU = coreParams.HasVPU
Z
zhanglinjuan 已提交
410
  val HasCustomCSRCacheOp = coreParams.HasCustomCSRCacheOp
411 412 413 414 415 416 417 418 419 420
  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
421
  val EnableGHistDiff = coreParams.EnableGHistDiff
422
  val UbtbGHRLength = coreParams.UbtbGHRLength
423
  val UbtbSize = coreParams.UbtbSize
424
  val EnableFauFTB = coreParams.EnableFauFTB
425 426
  val FtbSize = coreParams.FtbSize
  val FtbWays = coreParams.FtbWays
427
  val RasSize = coreParams.RasSize
Z
zoujr 已提交
428

429 430
  def getBPDComponents(resp_in: BranchPredictionResp, p: Parameters) = {
    coreParams.branchPredictor(resp_in, p)
Z
zoujr 已提交
431
  }
432 433
  val numBr = coreParams.numBr
  val TageTableInfos = coreParams.TageTableInfos
L
Lingrui98 已提交
434
  val TageBanks = coreParams.numBr
435 436
  val SCNRows = coreParams.SCNRows
  val SCCtrBits = coreParams.SCCtrBits
L
Lingrui98 已提交
437 438
  val SCHistLens = coreParams.SCHistLens
  val SCNTables = coreParams.SCNTables
439

L
Lingrui98 已提交
440 441
  val SCTableInfos = Seq.fill(SCNTables)((SCNRows, SCCtrBits)) zip SCHistLens map {
    case ((n, cb), h) => (n, cb, h)
442 443 444 445
  }
  val ITTageTableInfos = coreParams.ITTageTableInfos
  type FoldedHistoryInfo = Tuple2[Int, Int]
  val foldedGHistInfos =
446
    (TageTableInfos.map{ case (nRows, h, t) =>
447
      if (h > 0)
448
        Set((h, min(log2Ceil(nRows/numBr), h)), (h, min(h, t)), (h, min(h, t-1)))
449 450
      else
        Set[FoldedHistoryInfo]()
451
    }.reduce(_++_).toSet ++
L
Lingrui98 已提交
452
    SCTableInfos.map{ case (nRows, _, h) =>
453
      if (h > 0)
L
Lingrui98 已提交
454
        Set((h, min(log2Ceil(nRows/TageBanks), h)))
455 456
      else
        Set[FoldedHistoryInfo]()
L
Lingrui98 已提交
457
    }.reduce(_++_).toSet ++
458 459 460 461 462
    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]()
463 464 465
    }.reduce(_++_) ++
      Set[FoldedHistoryInfo]((UbtbGHRLength, log2Ceil(UbtbSize)))
    ).toList
466

467

Z
zoujr 已提交
468

469 470 471 472 473 474 475 476 477 478 479
  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
  val FtqSize = coreParams.FtqSize
  val EnableLoadFastWakeUp = coreParams.EnableLoadFastWakeUp
  val NRPhyRegs = coreParams.NRPhyRegs
  val PhyRegIdxWidth = log2Up(NRPhyRegs)
X
Xuan Hu 已提交
480 481 482 483
  val IntPhyRegs = coreParams.IntPhyRegs
  val VfPhyRegs = coreParams.VfPhyRegs
  val IntPregIdxWidth = log2Up(IntPhyRegs)
  val VfPregIdxWidth = log2Up(VfPhyRegs)
Y
Yinan Xu 已提交
484
  val RobSize = coreParams.RobSize
485
  val IntRefCounterWidth = log2Ceil(RobSize)
486
  val LoadQueueSize = coreParams.LoadQueueSize
487
  val LoadQueueNWriteBanks = coreParams.LoadQueueNWriteBanks
488
  val StoreQueueSize = coreParams.StoreQueueSize
489
  val StoreQueueNWriteBanks = coreParams.StoreQueueNWriteBanks
W
William Wang 已提交
490
  val VlsQueueSize = coreParams.VlsQueueSize
491
  val dpParams = coreParams.dpParams
X
Xuan Hu 已提交
492 493

  def backendParams: BackendParams = coreParams.backendParams
494 495
  def MemIQSizeMax = backendParams.memSchdParams.get.issueBlockParams.map(_.numEntries).max
  def IQSizeMax = backendParams.allSchdParams.map(_.issueBlockParams.map(_.numEntries).max).max
496 497
  val LoadPipelineWidth = coreParams.LoadPipelineWidth
  val StorePipelineWidth = coreParams.StorePipelineWidth
W
William Wang 已提交
498 499 500
  val VecMemSrcInWidth = coreParams.VecMemSrcInWidth
  val VecMemInstWbWidth = coreParams.VecMemInstWbWidth
  val VecMemDispatchWidth = coreParams.VecMemDispatchWidth
501
  val StoreBufferSize = coreParams.StoreBufferSize
502
  val StoreBufferThreshold = coreParams.StoreBufferThreshold
503
  val EnsbufferWidth = coreParams.EnsbufferWidth
504
  val UncacheBufferSize = coreParams.UncacheBufferSize
505
  val EnableLoadToLoadForward = coreParams.EnableLoadToLoadForward
506
  val EnableFastForward = coreParams.EnableFastForward
W
William Wang 已提交
507
  val EnableLdVioCheckAfterReset = coreParams.EnableLdVioCheckAfterReset
508 509
  val EnableSoftPrefetchAfterReset = coreParams.EnableSoftPrefetchAfterReset
  val EnableCacheErrorAfterReset = coreParams.EnableCacheErrorAfterReset
510
  val EnableDCacheWPU = coreParams.EnableDCacheWPU
511
  val EnableAccurateLoadError = coreParams.EnableAccurateLoadError
512
  val EnableUncacheWriteOutstanding = coreParams.EnableUncacheWriteOutstanding
513
  val asidLen = coreParams.MMUAsidLen
514
  val BTLBWidth = coreParams.LoadPipelineWidth + coreParams.StorePipelineWidth
515
  val refillBothTlb = coreParams.refillBothTlb
516 517 518
  val itlbParams = coreParams.itlbParameters
  val ldtlbParams = coreParams.ldtlbParameters
  val sttlbParams = coreParams.sttlbParameters
519
  val pftlbParams = coreParams.pftlbParameters
520
  val btlbParams = coreParams.btlbParameters
521
  val l2tlbParams = coreParams.l2tlbParameters
522 523 524 525 526
  val NumPerfCounters = coreParams.NumPerfCounters

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

527
  val icacheParameters = coreParams.icacheParameters
J
Jiawei Lin 已提交
528
  val dcacheParameters = coreParams.dcacheParametersOpt.getOrElse(DCacheParameters())
529

530
  // dcache block cacheline when lr for LRSCCycles - LRSCBackOff cycles
531
  // for constrained LR/SC loop
532 533 534
  val LRSCCycles = 64
  // for lr storm
  val LRSCBackOff = 8
535 536 537 538

  // cache hierarchy configurations
  val l1BusDataWidth = 256

539 540 541 542 543 544 545 546 547 548 549 550 551
  // 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
552

553 554 555 556 557 558 559 560
  val PCntIncrStep: Int = 6
  val numPCntHc: Int = 25
  val numPCntPtw: Int = 19

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