Skip to content

Commit

Permalink
[rtl] Add read token in store unit.
Browse files Browse the repository at this point in the history
  • Loading branch information
qinjun-li committed Dec 19, 2024
1 parent 7c34e2e commit 10ad9f4
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 12 deletions.
4 changes: 4 additions & 0 deletions t1/src/lsu/SimpleAccessUnit.scala
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,10 @@ case class MSHRParam(
// outstanding of MaskExchangeUnit.maskReq
// todo: param from T1Param
val maskRequestQueueSize: Int = 8

// outstanding of StoreUnit.vrfReadDataPorts
// todo: param from T1Param
val storeUnitReadOutStanding: Int = 8
}

/** Miss Status Handler Register this is used to record the outstanding memory access request for each instruction. it
Expand Down
26 changes: 14 additions & 12 deletions t1/src/lsu/StoreUnit.scala
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,9 @@ class StoreUnit(param: MSHRParam) extends StrideBase(param) with LSUPublic {
// todo: need hazardCheck?
val hazardCheck: Bool = RegEnable(vrfReadyToStore && !lsuRequest.valid, false.B, lsuRequest.valid || vrfReadyToStore)
// read stage dequeue ready need all source valid, Or add a queue to coordinate
val vrfReadQueueVec: Seq[QueueIO[UInt]] =
Seq.tabulate(param.laneNumber)(_ => Queue.io(UInt(param.datapathWidth.W), 2, flow = true, pipe = true))
val vrfReadQueueVec: Seq[QueueIO[UInt]] = Seq.tabulate(param.laneNumber)(_ =>
Queue.io(UInt(param.datapathWidth.W), param.storeUnitReadOutStanding, flow = true, pipe = true)
)

// 从vrf里面读数据
val readStageValid: Bool = Seq
Expand All @@ -72,10 +73,6 @@ class StoreUnit(param: MSHRParam) extends StrideBase(param) with LSUPublic {
val segPtr: UInt = RegInit(0.U(3.W))
val readCount: UInt = RegInit(0.U(dataGroupBits.W))
val stageValid = RegInit(false.B)
// queue for read latency
// todo: param.vrfReadLatency => param.vrfReadLatency + shifterLatency
val queue: QueueIO[UInt] =
Queue.io(UInt(param.datapathWidth.W), param.vrfReadLatency, flow = true)

val lastReadPtr: Bool = segPtr === 0.U

Expand Down Expand Up @@ -105,8 +102,14 @@ class StoreUnit(param: MSHRParam) extends StrideBase(param) with LSUPublic {
readCount := nextReadCount
}

val readCounter = RegInit(0.U(log2Ceil(param.storeUnitReadOutStanding + 1).W))
val counterChange: UInt = Mux(readPort.fire, 1.U, -1.S(readCounter.getWidth.W).asUInt)
when(readPort.fire ^ vrfReadQueueVec(laneIndex).deq.fire) {
readCounter := readCounter + counterChange
}

// vrf read request
readPort.valid := stageValid && vrfReadQueueVec(laneIndex).enq.ready
readPort.valid := stageValid && !readCounter.asBools.last
readPort.bits.vs :=
lsuRequestReg.instructionInformation.vs3 +
segPtr * segmentInstructionIndexInterval +
Expand All @@ -116,11 +119,10 @@ class StoreUnit(param: MSHRParam) extends StrideBase(param) with LSUPublic {
readPort.bits.instructionIndex := lsuRequestReg.instructionIndex

// latency queue enq
queue.enq.valid := vrfReadResults(laneIndex).valid
queue.enq.bits := vrfReadResults(laneIndex).bits
AssertProperty(BoolSequence(!queue.enq.valid || queue.enq.ready))
vrfReadQueueVec(laneIndex).enq <> queue.deq
stageValid || RegNext(readPort.fire)
AssertProperty(BoolSequence(!vrfReadQueueVec(laneIndex).enq.valid || vrfReadQueueVec(laneIndex).enq.ready))
vrfReadQueueVec(laneIndex).enq.valid := vrfReadResults(laneIndex).valid
vrfReadQueueVec(laneIndex).enq.bits := vrfReadResults(laneIndex).bits
stageValid || readCounter.orR
}
.reduce(_ || _)

Expand Down

0 comments on commit 10ad9f4

Please sign in to comment.