Skip to content

Commit

Permalink
[rtl] fix read in mask unit.
Browse files Browse the repository at this point in the history
  • Loading branch information
qinjun-li committed Dec 25, 2024
1 parent a6d240b commit b011183
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 13 deletions.
5 changes: 5 additions & 0 deletions t1/src/Bundles.scala
Original file line number Diff line number Diff line change
Expand Up @@ -794,3 +794,8 @@ class MaskUnitReadVs1(parameter: T1Parameter) extends Bundle {
class LaneTokenBundle extends Bundle {
val maskRequestRelease: Bool = Input(Bool())
}

class MaskUnitReadPipe(parameter: T1Parameter) extends Bundle {
val readSource: UInt = UInt(parameter.laneNumber.W)
val dataOffset: UInt = UInt(log2Ceil(parameter.datapathWidth / 8).W)
}
4 changes: 2 additions & 2 deletions t1/src/mask/BitLevelMaskWrite.scala
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class BitLevelWriteRequest(parameter: T1Parameter) extends Bundle {

class BitLevelMaskWrite(parameter: T1Parameter) extends Module {
// todo
val readVRFLatency: Int = 2
val readVRFLatency: Int = 4

val needWAR: Bool = IO(Input(Bool()))
val vd: UInt = IO(Input(UInt(5.W)))
Expand Down Expand Up @@ -68,7 +68,7 @@ class BitLevelMaskWrite(parameter: T1Parameter) extends Module {
readPort.bits.vs := vd + (reqQueue.deq.bits.groupCounter >> readPort.bits.offset.getWidth).asUInt
readPort.bits.offset := changeUIntSize(reqQueue.deq.bits.groupCounter, readPort.bits.offset.getWidth)

val readValidPipe = Pipe(readPort.fire, false.B, readVRFLatency).valid && readResult(index).valid
val readValidPipe = readResult(index).valid
val readResultValid = !needWAR || readValidPipe

val WARData = (WaitReadQueue.deq.bits.data & WaitReadQueue.deq.bits.bitMask) |
Expand Down
26 changes: 15 additions & 11 deletions t1/src/mask/MaskUnit.scala
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ class MaskUnit(val parameter: T1Parameter)

// todo: param
val readQueueSize: Int = 4
val readVRFLatency: Int = 2
val readVRFLatency: Int = 3
val maskUnitWriteQueueSize: Int = 8

/** duplicate v0 for mask */
Expand Down Expand Up @@ -758,13 +758,15 @@ class MaskUnit(val parameter: T1Parameter)
val pipeDataOffset: Vec[UInt] = Wire(Vec(parameter.laneNumber, UInt(log2Ceil(parameter.datapathWidth / 8).W)))

readCrossBar.output.zipWithIndex.foreach { case (request, index) =>
val readMessageQueue: QueueIO[MaskUnitReadPipe] =
Queue.io(new MaskUnitReadPipe(parameter), readVRFLatency + 4)
val sourceLane = UIntToOH(request.bits.writeIndex)
readChannel(index).valid := request.valid
readChannel(index).valid := request.valid && readMessageQueue.enq.ready
readChannel(index).bits.readSource := 2.U
readChannel(index).bits.vs := request.bits.vs
readChannel(index).bits.offset := request.bits.offset
readChannel(index).bits.instructionIndex := instReg.instructionIndex
request.ready := readChannel(index).ready
request.ready := readChannel(index).ready && readMessageQueue.enq.ready

maskedWrite.readChannel(index).ready := readChannel(index).ready
maskedWrite.readResult(index) := readResult(index)
Expand All @@ -774,15 +776,17 @@ class MaskUnit(val parameter: T1Parameter)
readChannel(index).bits.offset := maskedWrite.readChannel(index).bits.offset
}

// pipe read fire
val pipeRead = Pipe(
readChannel(index).fire && !maskDestinationType,
sourceLane,
readVRFLatency
readMessageQueue.enq.valid := readChannel(index).fire && !maskDestinationType
readMessageQueue.enq.bits.readSource := sourceLane
readMessageQueue.enq.bits.dataOffset := request.bits.dataOffset
readMessageQueue.deq.ready := readResult(index).valid

write1HPipe(index) := Mux(
readMessageQueue.deq.valid && readResult(index).valid,
readMessageQueue.deq.bits.readSource,
0.U(parameter.laneNumber.W)
)
val pipeOffset = Pipe(readChannel(index).fire, request.bits.dataOffset, readVRFLatency)
write1HPipe(index) := Mux(pipeRead.valid, pipeRead.bits, 0.U(parameter.laneNumber.W))
pipeDataOffset(index) := pipeOffset.bits
pipeDataOffset(index) := readMessageQueue.deq.bits.dataOffset
}

// Processing read results
Expand Down

0 comments on commit b011183

Please sign in to comment.