Skip to content

Commit 6eae2c4

Browse files
lewislzhgood-circle
authored andcommitted
chore(rob): delete fusion commitType and add debug_fusionNum for topdown
1 parent 001e96f commit 6eae2c4

File tree

6 files changed

+15
-20
lines changed

6 files changed

+15
-20
lines changed

src/main/scala/xiangshan/backend/Bundles.scala

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,7 @@ object Bundles {
208208
val canRobCompress = Bool()
209209
val crossFtqCommit = UInt(2.W) // use to caculate the ftq idx of ftqentry when commit
210210
val crossFtq = Bool() // use to caculate the ftq idx of brh instructions when pass to exu
211+
val fusionNum = UInt(2.W)
211212
val selImm = SelImm()
212213
val imm = UInt(32.W)
213214
val fpu = new FPUCtrlSignals

src/main/scala/xiangshan/backend/CtrlBlock.scala

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -593,15 +593,6 @@ class CtrlBlockImp(
593593

594594
// update the first RenameWidth - 1 instructions
595595
decode.io.fusion(i) := fusionDecoder.io.out(i).valid && rename.io.out(i).fire
596-
// TODO: remove this dirty code for ftq update
597-
val sameFtqPtr = rename.io.in(i).bits.ftqPtr.value === rename.io.in(i + 1).bits.ftqPtr.value
598-
val ftqOffset0 = rename.io.in(i).bits.ftqOffset
599-
val ftqOffset1 = rename.io.in(i + 1).bits.ftqOffset
600-
val ftqOffsetDiff = ftqOffset1 - ftqOffset0
601-
val cond1 = sameFtqPtr && ftqOffsetDiff === 1.U
602-
val cond2 = sameFtqPtr && ftqOffsetDiff === 2.U
603-
val cond3 = !sameFtqPtr && ftqOffset1 === 0.U
604-
val cond4 = !sameFtqPtr && ftqOffset1 === 1.U
605596
when (fusionDecoder.io.out(i).valid) {
606597
fusionDecoder.io.out(i).bits.update(rename.io.in(i).bits)
607598
fusionDecoder.io.out(i).bits.update(dispatch.io.renameIn(i).bits)
@@ -616,7 +607,6 @@ class CtrlBlockImp(
616607
rename.io.isFusionVec(i) := true.B
617608
rename.io.fusionCross2FtqVec(i) := cross2Ftq
618609
}
619-
XSError(fusionDecoder.io.out(i).valid && !cond1 && !cond2 && !cond3 && !cond4, p"new condition $sameFtqPtr $ftqOffset0 $ftqOffset1\n")
620610
}
621611

622612
// memory dependency predict

src/main/scala/xiangshan/backend/rename/Rename.scala

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -376,6 +376,7 @@ class Rename(implicit p: Parameters) extends XSModule with HasCircularQueuePtrHe
376376

377377
uops(i).robIdx := robIdxHead + PopCount(io.in.zip(needRobFlags).zip(io.validVec).take(i).map{ case((in, needRobFlag), valid) => valid && in.bits.lastUop && needRobFlag})
378378
instrSize(i) := instrSizesVec(i) + io.fusionCross2FtqVec(i)
379+
uops(i).fusionNum := PopCount(compressMasksVec(i) & Cat(io.isFusionVec.reverse))
379380
val hasExceptionExceptFlushPipe = Cat(selectFrontend(uops(i).exceptionVec) :+ uops(i).exceptionVec(illegalInstr) :+ uops(i).exceptionVec(virtualInstr)).orR || TriggerAction.isDmode(uops(i).trigger)
380381
when(isMove(i) || hasExceptionExceptFlushPipe) {
381382
uops(i).numUops := 0.U

src/main/scala/xiangshan/backend/rob/Rob.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1257,7 +1257,7 @@ class RobImp(override val wrapper: Rob)(implicit p: Parameters, params: BackendP
12571257
val isCommit = io.commits.isCommit
12581258
val isCommitReg = GatedValidRegNext(io.commits.isCommit)
12591259
val instrCntReg = RegInit(0.U(64.W))
1260-
val fuseCommitCnt = PopCount(io.commits.commitValid.zip(io.commits.info).map { case (v, i) => RegEnable(v && CommitType.isFused(i.commitType), isCommit) })
1260+
val fuseCommitCnt = RegEnable(io.commits.commitValid.zip(io.commits.info).map { case (v, i) => Mux(v, i.debug_fusionNum.getOrElse(0.U), 0.U) }.reduce(_ +& _), isCommit)
12611261
val trueCommitCnt = RegEnable(io.commits.commitValid.zip(instrSizeCommit).map { case (v, instrSize) => Mux(v, instrSize, 0.U) }.reduce(_ +& _), isCommit)
12621262
val retireCounter = Mux(isCommitReg, trueCommitCnt, 0.U)
12631263
val instrCnt = instrCntReg + retireCounter

src/main/scala/xiangshan/backend/rob/RobBundles.scala

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ object RobBundles extends HasCircularQueuePtrHelper {
8383
val debug_ldest = OptionWrapper(backendParams.basicDebugEn, UInt(LogicRegsWidth.W))
8484
val debug_pdest = OptionWrapper(backendParams.basicDebugEn, UInt(PhyRegIdxWidth.W))
8585
val debug_fuType = OptionWrapper(backendParams.debugEn, FuType())
86+
val debug_fusionNum = OptionWrapper(backendParams.debugEn, UInt(2.W))
8687
// debug_end
8788

8889
def isWritebacked: Bool = !uopNum.orR && stdWritebacked
@@ -121,6 +122,7 @@ object RobBundles extends HasCircularQueuePtrHelper {
121122
val debug_pdest = OptionWrapper(backendParams.basicDebugEn, UInt(PhyRegIdxWidth.W))
122123
val debug_otherPdest = OptionWrapper(backendParams.basicDebugEn, Vec(7, UInt(PhyRegIdxWidth.W)))
123124
val debug_fuType = OptionWrapper(backendParams.debugEn, FuType())
125+
val debug_fusionNum = OptionWrapper(backendParams.debugEn, UInt(2.W))
124126
// debug_end
125127
val dirtyFs = Bool()
126128
val dirtyVs = Bool()
@@ -147,6 +149,7 @@ object RobBundles extends HasCircularQueuePtrHelper {
147149
robEntry.debug_ldest.foreach(_ := robEnq.ldest)
148150
robEntry.debug_pdest.foreach(_ := robEnq.pdest)
149151
robEntry.debug_fuType.foreach(_ := robEnq.fuType)
152+
robEntry.debug_fusionNum.foreach(_ := robEnq.fusionNum)
150153
}
151154

152155
def connectCommitEntry(robCommitEntry: RobCommitEntryBundle, robEntry: RobEntryBundle): Unit = {
@@ -179,6 +182,7 @@ object RobBundles extends HasCircularQueuePtrHelper {
179182
robCommitEntry.debug_ldest.foreach(_ := robEntry.debug_ldest.get)
180183
robCommitEntry.debug_pdest.foreach(_ := robEntry.debug_pdest.get)
181184
robCommitEntry.debug_fuType.foreach(_ := robEntry.debug_fuType.get)
185+
robCommitEntry.debug_fusionNum.foreach(_ := robEntry.debug_fusionNum.get)
182186
}
183187
}
184188

src/main/scala/xiangshan/package.scala

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -163,17 +163,16 @@ package object xiangshan {
163163
}
164164

165165
object CommitType {
166-
def NORMAL = "b000".U // int/fp
167-
def BRANCH = "b001".U // branch
168-
def LOAD = "b010".U // load
169-
def STORE = "b011".U // store
170-
171-
def apply() = UInt(3.W)
172-
def isFused(commitType: UInt): Bool = commitType(2)
173-
def isLoadStore(commitType: UInt): Bool = !isFused(commitType) && commitType(1)
166+
def NORMAL = "b00".U // int/fp
167+
def BRANCH = "b01".U // branch
168+
def LOAD = "b10".U // load
169+
def STORE = "b11".U // store
170+
171+
def apply() = UInt(2.W)
172+
def isLoadStore(commitType: UInt): Bool = commitType(1)
174173
def lsInstIsStore(commitType: UInt): Bool = commitType(0)
175174
def isStore(commitType: UInt): Bool = isLoadStore(commitType) && lsInstIsStore(commitType)
176-
def isBranch(commitType: UInt): Bool = commitType(0) && !commitType(1) && !isFused(commitType)
175+
def isBranch(commitType: UInt): Bool = commitType(0) && !commitType(1)
177176
}
178177

179178
object RedirectLevel {

0 commit comments

Comments
 (0)