xref: /XiangShan/src/main/scala/xiangshan/backend/ctrlblock/LsInfo.scala (revision c61abc0c251b288ded38101b3c7ca47a9357e2ef)
1package xiangshan.backend.ctrlblock
2
3import chipsalliance.rocketchip.config.Parameters
4import chisel3._
5import chisel3.util._
6import xiangshan.XSBundle
7
8class DebugMdpInfo(implicit p: Parameters) extends XSBundle{
9  val ssid = UInt(SSIDWidth.W)
10  val waitAllStore = Bool()
11}
12
13class DebugLsInfo(implicit p: Parameters) extends XSBundle{
14  val s1 = new Bundle{
15    val isTlbFirstMiss = Bool() // in s1
16    val isBankConflict = Bool() // in s1
17    val isLoadToLoadForward = Bool()
18    val isReplayFast = Bool()
19  }
20  val s2 = new Bundle{
21    val isDcacheFirstMiss = Bool() // in s2 (predicted result is in s1 when using WPU, real result is in s2)
22    val isForwardFail = Bool() // in s2
23    val isReplaySlow = Bool()
24    val isLoadReplayTLBMiss = Bool()
25    val isLoadReplayCacheMiss = Bool()
26  }
27  val replayCnt = UInt(XLEN.W)
28
29  def s1SignalEnable(ena: DebugLsInfo) = {
30    when(ena.s1.isTlbFirstMiss) { s1.isTlbFirstMiss := true.B }
31    when(ena.s1.isBankConflict) { s1.isBankConflict := true.B }
32    when(ena.s1.isLoadToLoadForward) { s1.isLoadToLoadForward := true.B }
33    when(ena.s1.isReplayFast) {
34      s1.isReplayFast := true.B
35      replayCnt := replayCnt + 1.U
36    }
37  }
38
39  def s2SignalEnable(ena: DebugLsInfo) = {
40    when(ena.s2.isDcacheFirstMiss) { s2.isDcacheFirstMiss := true.B }
41    when(ena.s2.isForwardFail) { s2.isForwardFail := true.B }
42    when(ena.s2.isLoadReplayTLBMiss) { s2.isLoadReplayTLBMiss := true.B }
43    when(ena.s2.isLoadReplayCacheMiss) { s2.isLoadReplayCacheMiss := true.B }
44    when(ena.s2.isReplaySlow) {
45      s2.isReplaySlow := true.B
46      replayCnt := replayCnt + 1.U
47    }
48  }
49}
50
51object DebugLsInfo{
52  def init(implicit p: Parameters): DebugLsInfo = {
53    val lsInfo = Wire(new DebugLsInfo)
54    lsInfo.s1.isTlbFirstMiss := false.B
55    lsInfo.s1.isBankConflict := false.B
56    lsInfo.s1.isLoadToLoadForward := false.B
57    lsInfo.s1.isReplayFast := false.B
58    lsInfo.s2.isDcacheFirstMiss := false.B
59    lsInfo.s2.isForwardFail := false.B
60    lsInfo.s2.isReplaySlow := false.B
61    lsInfo.s2.isLoadReplayTLBMiss := false.B
62    lsInfo.s2.isLoadReplayCacheMiss := false.B
63    lsInfo.replayCnt := 0.U
64    lsInfo
65  }
66}
67
68class DebugLsInfoBundle(implicit p: Parameters) extends DebugLsInfo {
69  // unified processing at the end stage of load/store  ==> s2  ==> bug that will write error robIdx data
70  val s1_robIdx = UInt(log2Ceil(RobSize).W)
71  val s2_robIdx = UInt(log2Ceil(RobSize).W)
72}
73
74class DebugLSIO(implicit p: Parameters) extends XSBundle {
75  val debugLsInfo = Vec(backendParams.LduCnt + backendParams.StaCnt, Output(new DebugLsInfoBundle))
76}
77