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

X
Xuan Hu 已提交
325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340
    ),
      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 已提交
341 342
        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 已提交
343
      ), numEntries = 8, pregBits = pregBits, numWakeupFromWB = 16, numEnq = 2),
X
Xuan Hu 已提交
344
      IssueBlockParams(Seq(
F
fdy 已提交
345 346
        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 已提交
347
      ), numEntries = 8, pregBits = pregBits, numWakeupFromWB = 16, numEnq = 2),
X
Xuan Hu 已提交
348
      IssueBlockParams(Seq(
F
fdy 已提交
349 350
        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 已提交
351
      ), numEntries = 8, pregBits = pregBits, numWakeupFromWB = 16, numEnq = 2),
X
Xuan Hu 已提交
352
    ),
X
Xuan Hu 已提交
353
      numPregs = intPreg.numEntries max vfPreg.numEntries,
X
Xuan Hu 已提交
354 355 356 357 358 359 360
      numRfReadWrite = None,
      numDeqOutside = 0,
      schdType = schdType,
      rfDataWidth = rfDataWidth,
      numUopIn = dpParams.LsDqDeqWidth,
    )
  }
361

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

case object DebugOptionsKey extends Field[DebugOptions]

case class DebugOptions
(
376 377
  FPGAPlatform: Boolean = false,
  EnableDifftest: Boolean = false,
378
  AlwaysBasicDiff: Boolean = true,
379
  EnableDebug: Boolean = false,
380
  EnablePerfDebug: Boolean = true,
381 382
  UseDRAMSim: Boolean = false,
  EnableTopDown: Boolean = false
383 384 385 386 387 388
)

trait HasXSParameter {

  implicit val p: Parameters

389 390
  val PAddrBits = p(SoCParamsKey).PAddrBits // PAddrBits is Phyical Memory addr bits

391 392 393 394
  val coreParams = p(XSCoreParamsKey)
  val env = p(DebugOptionsKey)

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

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

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

471

Z
zoujr 已提交
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
F
fdy 已提交
480
  val MaxUopSize = coreParams.MaxUopSize
481 482
  val FtqSize = coreParams.FtqSize
  val EnableLoadFastWakeUp = coreParams.EnableLoadFastWakeUp
F
fdy 已提交
483 484 485
  val IntLogicRegs = coreParams.IntLogicRegs
  val FpLogicRegs = coreParams.FpLogicRegs
  val VecLogicRegs = coreParams.VecLogicRegs
486 487
  val NRPhyRegs = coreParams.NRPhyRegs
  val PhyRegIdxWidth = log2Up(NRPhyRegs)
X
Xuan Hu 已提交
488 489 490 491
  val IntPhyRegs = coreParams.IntPhyRegs
  val VfPhyRegs = coreParams.VfPhyRegs
  val IntPregIdxWidth = log2Up(IntPhyRegs)
  val VfPregIdxWidth = log2Up(VfPhyRegs)
Y
Yinan Xu 已提交
492
  val RobSize = coreParams.RobSize
493
  val IntRefCounterWidth = log2Ceil(RobSize)
494
  val LoadQueueSize = coreParams.LoadQueueSize
495
  val LoadQueueNWriteBanks = coreParams.LoadQueueNWriteBanks
496
  val StoreQueueSize = coreParams.StoreQueueSize
497
  val StoreQueueNWriteBanks = coreParams.StoreQueueNWriteBanks
W
William Wang 已提交
498
  val VlsQueueSize = coreParams.VlsQueueSize
499
  val dpParams = coreParams.dpParams
X
Xuan Hu 已提交
500 501

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

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

535
  val icacheParameters = coreParams.icacheParameters
J
Jiawei Lin 已提交
536
  val dcacheParameters = coreParams.dcacheParametersOpt.getOrElse(DCacheParameters())
537

538
  // dcache block cacheline when lr for LRSCCycles - LRSCBackOff cycles
539
  // for constrained LR/SC loop
540 541 542
  val LRSCCycles = 64
  // for lr storm
  val LRSCBackOff = 8
543 544 545 546

  // cache hierarchy configurations
  val l1BusDataWidth = 256

547 548 549 550 551 552 553 554 555 556 557 558 559
  // 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
560

561 562 563 564 565 566 567 568
  val PCntIncrStep: Int = 6
  val numPCntHc: Int = 25
  val numPCntPtw: Int = 19

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