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