Skip to content

Commit

Permalink
vtype: fix walk vtype value after using snapshot and the redirect sig…
Browse files Browse the repository at this point in the history
…anl for vtype
  • Loading branch information
Ziyue-Zhang committed May 24, 2024
1 parent af4f5ef commit 05038a7
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 12 deletions.
1 change: 1 addition & 0 deletions src/main/scala/xiangshan/backend/CtrlBlock.scala
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,7 @@ class CtrlBlockImp(
rob.io.fromDecode.specVtype := decode.io.specVtype

decode.io.redirect := s1_s3_redirect.valid || s2_s4_pendingRedirectValid
decode.io.vtypeRedirect := s1_s3_redirect.valid

decode.io.in.zip(io.frontend.cfVec).foreach { case (decodeIn, frontendCf) =>
decodeIn.valid := frontendCf.valid
Expand Down
3 changes: 2 additions & 1 deletion src/main/scala/xiangshan/backend/decode/DecodeStage.scala
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ class DecodeStage(implicit p: Parameters) extends XSModule
val io = IO(new Bundle() {
val redirect = Input(Bool())
val canAccept = Output(Bool())
val vtypeRedirect = Input(Bool())
// from Ibuffer
val in = Vec(DecodeWidth, Flipped(DecoupledIO(new StaticInst)))
// to Rename
Expand Down Expand Up @@ -106,7 +107,7 @@ class DecodeStage(implicit p: Parameters) extends XSModule
inst.bits := io.in(i).bits.instr
}
vtypeGen.io.canUpdateVType := decoderComp.io.in.fire && decoderComp.io.in.bits.simpleDecodedInst.isVset
vtypeGen.io.redirect := io.redirect
vtypeGen.io.redirect := io.vtypeRedirect
vtypeGen.io.commitVType := io.commitVType
vtypeGen.io.walkVType := io.walkVType
vtypeGen.io.vsetvlVType := io.vsetvlVType
Expand Down
10 changes: 5 additions & 5 deletions src/main/scala/xiangshan/backend/decode/VTypeGen.scala
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,9 @@ class VTypeGen(implicit p: Parameters) extends XSModule{

private val vtypeNew = vsetModule.io.out.vconfig.vtype

when(io.commitVType.vtype.valid) {
when(io.commitVType.hasVsetvl) {
vtypeArchNext := io.vsetvlVType
}.elsewhen(io.commitVType.vtype.valid) {
vtypeArchNext := io.commitVType.vtype.bits
}

Expand All @@ -71,12 +73,10 @@ class VTypeGen(implicit p: Parameters) extends XSModule{
lastSpecVTypeNext.bits := vtypeSpec
vtypeSpecNext := io.vsetvlVType
}.elsewhen(io.walkVType.valid) {
lastSpecVTypeNext.valid := true.B
lastSpecVTypeNext.bits := vtypeSpec
lastSpecVTypeNext.valid := false.B
vtypeSpecNext := io.walkVType.bits
}.elsewhen(io.redirect) {
lastSpecVTypeNext.valid := true.B
lastSpecVTypeNext.bits := vtypeSpec
lastSpecVTypeNext.valid := false.B
vtypeSpecNext := vtypeArch
}.elsewhen(inHasVset && io.canUpdateVType) {
lastSpecVTypeNext.valid := true.B
Expand Down
11 changes: 5 additions & 6 deletions src/main/scala/xiangshan/backend/rob/VTypeBuffer.scala
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,8 @@ class VTypeBuffer(size: Int)(implicit p: Parameters) extends XSModule with HasCi

walkPtr := walkPtrNext

private val useSnapshot = (state === s_idle && stateNext === s_walk) || (state === s_walk && io.snpt.useSnpt && io.redirect.valid)

// update enq ptr
private val enqPtrNext = Mux(
state === s_walk && stateNext === s_idle,
Expand Down Expand Up @@ -217,9 +219,6 @@ class VTypeBuffer(size: Int)(implicit p: Parameters) extends XSModule with HasCi
private val infoVec = Wire(Vec(CommitWidth, VType()))
private val hasVsetvlVec = Wire(Vec(CommitWidth, Bool()))

private val isCommit = state === s_idle || state === s_spcl_walk
private val isWalk = state === s_walk || state === s_spcl_walk

for (i <- 0 until CommitWidth) {
commitValidVec(i) := state === s_idle && i.U < commitSize || state === s_spcl_walk && i.U < spclWalkSize
walkValidVec(i) := state === s_walk && i.U < walkSize || state === s_spcl_walk && i.U < spclWalkSize
Expand Down Expand Up @@ -278,7 +277,7 @@ class VTypeBuffer(size: Int)(implicit p: Parameters) extends XSModule with HasCi
// special walk use commit vtype
decodeResumeVType.valid := commitVTypeValid
decodeResumeVType.bits := newestArchVType
}.elsewhen (state === s_walk && stateLast === s_idle) {
}.elsewhen (useSnapshot) {
// use snapshot vtype
decodeResumeVType.valid := true.B
decodeResumeVType.bits := walkVtypeSnapshots(snptSelect)
Expand All @@ -294,10 +293,10 @@ class VTypeBuffer(size: Int)(implicit p: Parameters) extends XSModule with HasCi
// update vtype in decode when VTypeBuffer resumes from walk state
// note that VTypeBuffer can still send resuming request in the first cycle of s_idle
io.toDecode.isResumeVType := state =/= s_idle || decodeResumeVType.valid
io.toDecode.walkVType.valid := isWalk && decodeResumeVType.valid
io.toDecode.walkVType.valid := decodeResumeVType.valid
io.toDecode.walkVType.bits := Mux(io.toDecode.walkVType.valid, decodeResumeVType.bits, 0.U.asTypeOf(VType()))

io.toDecode.commitVType.vtype.valid := isCommit && commitVTypeValid
io.toDecode.commitVType.vtype.valid := commitVTypeValid
io.toDecode.commitVType.vtype.bits := newestArchVType

// because vsetvl flush pipe, there is only one vset instruction when vsetvl is committed
Expand Down

0 comments on commit 05038a7

Please sign in to comment.