Skip to content

Commit

Permalink
[soc] Handle vector writing to float registers.
Browse files Browse the repository at this point in the history
  • Loading branch information
qinjun-li authored and sequencer committed Apr 23, 2024
1 parent 762d9b4 commit 149bc2f
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 6 deletions.
2 changes: 2 additions & 0 deletions rocket/src/AbstractT1.scala
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ class VectorResponse(xLen: Int) extends Bundle {
*/
val rd: Valid[UInt] = Valid(UInt(log2Ceil(32).W))

val float: Bool = Bool()

/** Vector Fixed-Point Saturation Flag, propagate to vcsr in CSR.
* This is not maintained in the vector coprocessor since it is not used in the Vector processor.
*/
Expand Down
22 changes: 19 additions & 3 deletions rocket/src/RocketCore.scala
Original file line number Diff line number Diff line change
Expand Up @@ -973,8 +973,12 @@ class Rocket(flushOnFenceI: Boolean, hasBeu: Boolean)(implicit val p: Parameters
.map {
case (fpu, fpHazardTargets) =>
val fpScoreboard = new Scoreboard(32)
fpScoreboard.set((wbDcacheMiss && wbRegDecodeOutput(decoder.wfd) || fpu.sboard_set) && wbValid, wbWaddr)
fpScoreboard.set(((wbDcacheMiss || wbRegDecodeOutput(decoder.vector)) && wbRegDecodeOutput(decoder.wfd) || fpu.sboard_set) && wbValid, wbWaddr)
fpScoreboard.clear(dmemResponseReplay && dmemResponseFpu, dmemResponseWaddr)
t1Response.foreach { response =>
val vectorTryToWriteFP = response.bits.rd.valid && response.bits.float
fpScoreboard.clear(response.fire && vectorTryToWriteFP, response.bits.rd.bits)
}
fpScoreboard.clear(fpu.sboard_clr, fpu.sboard_clra)
checkHazards(fpHazardTargets, fpScoreboard.read)
}
Expand Down Expand Up @@ -1129,13 +1133,25 @@ class Rocket(flushOnFenceI: Boolean, hasBeu: Boolean)(implicit val p: Parameters
}
// todo: vector change csr
t1Response.foreach { vectorResponse =>
val vectorTryToWriteRd = vectorResponse.bits.rd.valid
vectorResponse.ready := !(wbWxd || (dmemResponseReplay && dmemResponseXpu)) || !vectorTryToWriteRd
val vectorTryToWriteRd = vectorResponse.bits.rd.valid && !vectorResponse.bits.float
val vectorTryToWriteFP = vectorResponse.bits.rd.valid && vectorResponse.bits.float
vectorResponse.ready := (!(wbWxd || (dmemResponseReplay && dmemResponseXpu)) || !vectorTryToWriteRd) &&
(!(dmemResponseReplay && dmemResponseFpu) || !vectorTryToWriteFP)
when(vectorResponse.fire && vectorTryToWriteRd) {
longlatencyWdata := vectorResponse.bits.data
longlatencyWaddress := vectorResponse.bits.rd.bits
longLatencyWenable := true.B
}
fpu.foreach { fpu =>
when(!(dmemResponseValid && dmemResponseFpu)) {
fpu.dmem_resp_val := vectorResponse.fire && vectorTryToWriteFP
fpu.dmem_resp_data := vectorResponse.bits.data
// todo: 32 bit only
fpu.dmem_resp_type := 2.U
// todo: connect tag
fpu.dmem_resp_tag := 0.U
}
}
}

dmem.req.valid := exRegValid && exRegDecodeOutput(decoder.mem)
Expand Down
1 change: 1 addition & 0 deletions subsystem/src/LazyT1.scala
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ class LazyT1Imp(outer: LazyT1)(implicit p: Parameters) extends AbstractLazyT1Mod
response.valid := t1.response.valid
response.bits.data := t1.response.bits.data
response.bits.rd := t1.response.bits.rd
response.bits.float := t1.response.bits.float
response.bits.vxsat := t1.response.bits.vxsat
response.bits.mem := t1.response.bits.mem

Expand Down
2 changes: 2 additions & 0 deletions t1/src/Bundles.scala
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ class VResponse(xLen: Int) extends Bundle {
*/
val rd: ValidIO[UInt] = Valid(UInt(log2Ceil(32).W))

val float: Bool = Bool()

/** when [[mem]] is asserted, indicate the instruction need to access memory.
* if the vector instruction need to access memory,
* to maintain the order of memory access:
Expand Down
5 changes: 5 additions & 0 deletions t1/src/T1.scala
Original file line number Diff line number Diff line change
Expand Up @@ -632,6 +632,11 @@ class T1(val parameter: T1Parameter) extends Module with SerializableModule[T1Pa
val firstLaneIndex: UInt = OHToUInt(firstLane)(log2Ceil(parameter.laneNumber) - 1, 0)
response.bits.rd.valid := lastSlotCommit && decodeResultReg(Decoder.targetRd)
response.bits.rd.bits := vd
if (parameter.fpuEnable) {
response.bits.float := decodeResultReg(Decoder.float)
} else {
response.bits.float := false.B
}
when(requestRegDequeue.fire) {
ffoIndexReg.valid := false.B
ffoIndexReg.bits := -1.S(parameter.xLen.W).asUInt
Expand Down
6 changes: 3 additions & 3 deletions t1/src/decoder/Decoder.scala
Original file line number Diff line number Diff line change
Expand Up @@ -278,8 +278,9 @@ object Decoder {
val isFFO = ffo.value(op)
// extend read only
val extendType = Seq(mv, popCount, id)
val isMVtoFP = op.special.isDefined && op.special.get.name == "VWFUNARY0"
val isOtherType: Boolean =
(Seq(isGather, isMerge, isClip, isFFO) ++ extendType.map(_.value(op))).reduce(_ || _)
!isMVtoFP && (Seq(isGather, isMerge, isClip, isFFO) ++ extendType.map(_.value(op))).reduce(_ || _)
// ++ffo
val otherType = Seq(isGather, isMerge, isClip) ++ extendType.map(_.value(op))
val typeIndex = if (otherType.contains(true)) 4 + otherType.indexOf(true) else 0
Expand All @@ -301,8 +302,7 @@ object Decoder {
!(
other.value(op) ||
dontNeedExecuteInLane.value(op) ||
slid.value(op) ||
mv.value(op) || divider.value(op))
slid.value(op) || divider.value(op))
}

object floatConvertUnsigned extends BoolField {
Expand Down

0 comments on commit 149bc2f

Please sign in to comment.