Skip to content

Commit fffb491

Browse files
timing(TL2CHICoupledL2): 2-stage cap P-Credit Queue (OpenXiangShan#449)
1 parent 62195c6 commit fffb491

File tree

1 file changed

+16
-11
lines changed

1 file changed

+16
-11
lines changed

src/main/scala/coupledL2/tl2chi/TL2CHICoupledL2.scala

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,11 @@ class TL2CHICoupledL2(implicit p: Parameters) extends CoupledL2Base {
160160
// PCredit queue
161161
class EmptyBundle extends Bundle
162162

163+
class PCrdGranted extends Bundle {
164+
val pCrdType = UInt(PCRDTYPE_WIDTH.W)
165+
val srcID = UInt(SRCID_WIDTH.W)
166+
}
167+
163168
val (mmioQuerys, mmioGrants) = mmio.io_pCrd.map { case x => (x.query, x.grant) }.unzip
164169
val (slicesQuerys, slicesGrants) = slices.map { case s =>
165170
(s.io_pCrd.map(_.query), s.io_pCrd.map(_.grant))
@@ -169,13 +174,13 @@ class TL2CHICoupledL2(implicit p: Parameters) extends CoupledL2Base {
169174

170175
val mshrEntryCount = mshrPCrdQuerys.length
171176

172-
val pCrdQueue = Module(new Queue(new Bundle {
173-
val pCrdType = UInt(PCRDTYPE_WIDTH.W)
174-
val srcID = UInt(SRCID_WIDTH.W)
175-
}, entries = mshrEntryCount))
177+
val pCrdQueue_s2 = Module(new Queue(new PCrdGranted, entries = mshrEntryCount - 2))
178+
val pCrdQueue_s3 = Module(new Queue(new PCrdGranted, entries = 2))
179+
180+
pCrdQueue_s3.io.enq <> pCrdQueue_s2.io.deq
176181

177182
// PCredit hit by MSHRs
178-
val mshrPCrdHits = mshrPCrdQuerys.map((_, pCrdQueue.io.deq)).map { case (q, h) => {
183+
val mshrPCrdHits = mshrPCrdQuerys.map((_, pCrdQueue_s3.io.deq)).map { case (q, h) => {
179184
q.valid && h.valid && q.bits.pCrdType === h.bits.pCrdType && q.bits.srcID === h.bits.srcID
180185
}}
181186

@@ -191,7 +196,7 @@ class TL2CHICoupledL2(implicit p: Parameters) extends CoupledL2Base {
191196
val mshrPCrdArbOut = {
192197
val arbPort = Wire(Decoupled(new EmptyBundle))
193198
arbPort.ready := true.B
194-
pCrdQueue.io.deq.ready := arbPort.valid
199+
pCrdQueue_s3.io.deq.ready := arbPort.valid
195200
arbPort
196201
}
197202

@@ -204,12 +209,12 @@ class TL2CHICoupledL2(implicit p: Parameters) extends CoupledL2Base {
204209
val pCrdGrantType_s1 = RegNext(rxrsp.bits.pCrdType)
205210
val pCrdGrantSrcID_s1 = RegNext(rxrsp.bits.srcID)
206211

207-
pCrdQueue.io.enq.valid := pCrdGrantValid_s1
208-
pCrdQueue.io.enq.bits.pCrdType := pCrdGrantType_s1
209-
pCrdQueue.io.enq.bits.srcID := pCrdGrantSrcID_s1
212+
pCrdQueue_s2.io.enq.valid := pCrdGrantValid_s1
213+
pCrdQueue_s2.io.enq.bits.pCrdType := pCrdGrantType_s1
214+
pCrdQueue_s2.io.enq.bits.srcID := pCrdGrantSrcID_s1
210215

211216
val grantCnt = RegInit(0.U(64.W))
212-
when (pCrdQueue.io.deq.ready) {
217+
when (pCrdQueue_s3.io.deq.ready) {
213218
grantCnt := grantCnt + 1.U
214219
}
215220
dontTouch(grantCnt)
@@ -266,7 +271,7 @@ class TL2CHICoupledL2(implicit p: Parameters) extends CoupledL2Base {
266271
/**
267272
* performance counters
268273
*/
269-
XSPerfAccumulate("pcrd_count", pCrdQueue.io.enq.fire)
274+
XSPerfAccumulate("pcrd_count", pCrdQueue_s2.io.enq.fire)
270275
}
271276
}
272277

0 commit comments

Comments
 (0)