@@ -120,46 +120,68 @@ class MSHRCtl(implicit p: Parameters) extends TL2CHIL2Module {
120
120
mshrSelector.io.idle := mshrs.map(m => ! m.io.status.valid)
121
121
io.toMainPipe.mshr_alloc_ptr := OHToUInt (selectedMSHROH)
122
122
123
+ /*
124
+ rxrsp for PCredit timing is quite critical and break it here
125
+ */
126
+ val rxrspValid = RegNext (io.resps.rxrsp.valid)
127
+ val rxrspInfo = RegNext (io.resps.rxrsp.respInfo)
128
+ val rxrspMshrId = RegNext ( io.resps.rxrsp.mshrId)
129
+
123
130
/*
124
131
when PCrdGrant, give credit to one entry that:
125
132
1. got RetryAck and not Reissued
126
133
2. match srcID and PCrdType
127
134
3. use Round-Robin arbiter if multi-entry match
128
135
*/
129
136
val isPCrdGrant = io.resps.rxrsp.valid && (io.resps.rxrsp.respInfo.chiOpcode.get === PCrdGrant )
137
+ val isPCrdGrantReg = RegNext (isPCrdGrant)
130
138
val waitPCrdInfo = Wire (Vec (mshrsAll, new PCrdInfo ))
131
- // val pArb = Module(new RRArbiter(UInt(), mshrsAll))
139
+ val timeOutPri = VecInit (Seq .fill(16 )(false .B ))
140
+ val timeOutSel = WireInit (false .B )
141
+ val pCrdPri = VecInit (Seq .fill(16 )(false .B ))
142
+ val pArb = Module (new RRArbiter (UInt (), mshrsAll))
132
143
133
144
val matchPCrdGrant = VecInit (waitPCrdInfo.map(p =>
134
145
isPCrdGrant && p.valid &&
135
146
p.srcID.get === io.resps.rxrsp.respInfo.srcID.get &&
136
147
p.pCrdType.get === io.resps.rxrsp.respInfo.pCrdType.get
137
148
))
138
149
139
- /* pArb.io.in.zipWithIndex.foreach {
140
- case (in, i) =>
141
- in.valid := matchPCrdGrant(i)
150
+ val matchPCrdGrantReg = RegNext (matchPCrdGrant)
151
+ pArb.io.in.zipWithIndex.foreach {
152
+ case (in, i) =>
153
+ in.valid := matchPCrdGrantReg(i)
142
154
in.bits := 0 .U
143
155
}
144
156
pArb.io.out.ready := true .B
145
- val pCrdRR = VecInit(UIntToOH(pArb.io.chosen))
146
- val pCrdPri = VecInit((matchPCrdGrant.asUInt & pCrdRR.asUInt).asBools)
147
- //val pCrdPri = VecInit(PriorityEncoderOH(matchPCrdGrant))
148
- val pCrdIsWait = OHToUInt(pCrdPri)
149
- */
150
157
151
- /*
152
- Random arbiter if multi-entry match
153
- */
154
- val lfsr = LFSR (16 , true .B )
155
- val idx = Random (16 , lfsr)
156
- val idxOH = VecInit (UIntToOH (idx))
158
+ val pCrdOH = VecInit (UIntToOH (pArb.io.chosen).asBools)
159
+ val pCrdFixPri = VecInit (pCrdOH zip matchPCrdGrantReg map {case (a,b) => a && b})
160
+ // val pCrdFixPri = VecInit(PriorityEncoderOH(matchPCrdGrantReg)) //fix priority arbiter
161
+
162
+ // timeout protect
163
+ val counter = RegInit (VecInit (Seq .fill(mshrsAll)(0 .U ((log2Ceil(mshrsAll)+ 1 ).W ))))
164
+
165
+ for (i <- 0 until 16 ) {
166
+ when(matchPCrdGrantReg(i)) {
167
+ when(! timeOutSel && pCrdFixPri(i) || timeOutPri(i)) {
168
+ counter(i):= 0 .U
169
+ }.otherwise {
170
+ counter(i):= counter(i) + 1 .U
171
+ }
172
+ }
173
+ }
174
+ val timeOutOH = PriorityEncoderOH (counter.map(_>= 12 .U ) zip matchPCrdGrantReg map {case (a,b) => a&& b})
175
+ timeOutPri := VecInit (timeOutOH)
176
+
177
+ timeOutSel := timeOutPri.reduce(_|_)
178
+ pCrdPri := Mux (timeOutSel, timeOutPri, pCrdFixPri)
157
179
158
- val doubleReq = Fill ( 2 , matchPCrdGrant.asUInt )
159
- val doubleGnt = ~ (doubleReq - idxOH.asUInt) & doubleReq
160
- val gnt = doubleGnt( 31 , 16 ) | doubleGnt( 15 , 0 )
161
- val pCrdPri = VecInit (gnt.asBools )
162
- val pCrdIsWait = OHToUInt (pCrdPri)
180
+ dontTouch (timeOutPri )
181
+ dontTouch (timeOutSel)
182
+ dontTouch (pCrdOH )
183
+ dontTouch (pCrdFixPri )
184
+ dontTouch (pCrdPri)
163
185
164
186
/* when PCrdGrant come before RetryAck, 16 entry CAM used to:
165
187
1. save {srcID, PCrdType}
@@ -171,7 +193,8 @@ class MSHRCtl(implicit p: Parameters) extends TL2CHIL2Module {
171
193
val pCamValids = Cat (pCam.map(_.valid))
172
194
val enqIdx = PriorityEncoder (~ pCamValids.asUInt)
173
195
174
- when (isPCrdGrant && ! pCrdIsWait.orR){
196
+ // when (isPCrdGrant && !pCrdIsWait.orR){
197
+ when (isPCrdGrant){
175
198
pCam(enqIdx).valid := true .B
176
199
pCam(enqIdx).srcID.get := io.resps.rxrsp.respInfo.srcID.get
177
200
pCam(enqIdx).pCrdType.get := io.resps.rxrsp.respInfo.pCrdType.get
@@ -214,8 +237,10 @@ class MSHRCtl(implicit p: Parameters) extends TL2CHIL2Module {
214
237
m.io.resps.rxdat.valid := m.io.status.valid && io.resps.rxdat.valid && io.resps.rxdat.mshrId === i.U
215
238
m.io.resps.rxdat.bits := io.resps.rxdat.respInfo
216
239
217
- m.io.resps.rxrsp.valid := (m.io.status.valid && io.resps.rxrsp.valid && ! isPCrdGrant && io.resps.rxrsp.mshrId === i.U ) || (isPCrdGrant && pCrdPri(i))
218
- m.io.resps.rxrsp.bits := io.resps.rxrsp.respInfo
240
+ // m.io.resps.rxrsp.valid := (m.io.status.valid && io.resps.rxrsp.valid && !isPCrdGrant && io.resps.rxrsp.mshrId === i.U) || (isPCrdGrant && pCrdPri(i))
241
+ // m.io.resps.rxrsp.bits := io.resps.rxrsp.respInfo
242
+ m.io.resps.rxrsp.valid := (m.io.status.valid && rxrspValid && ! isPCrdGrantReg && rxrspMshrId === i.U ) || (isPCrdGrantReg && pCrdPri(i))
243
+ m.io.resps.rxrsp.bits := rxrspInfo
219
244
220
245
m.io.replResp.valid := io.replResp.valid && io.replResp.bits.mshrId === i.U
221
246
m.io.replResp.bits := io.replResp.bits
@@ -226,7 +251,7 @@ class MSHRCtl(implicit p: Parameters) extends TL2CHIL2Module {
226
251
m.io.aMergeTask.bits := io.aMergeTask.bits.task
227
252
228
253
waitPCrdInfo(i) := m.io.waitPCrdInfo
229
- m.io.pCamPri := (pCamPri === i.U ) && waitPCrdInfo(i).valid
254
+ m.io.pCamPri := 0 . U /* (pCamPri === i.U) && waitPCrdInfo(i).valid*/
230
255
}
231
256
/* Reserve 1 entry for SinkB */
232
257
io.waitPCrdInfo <> waitPCrdInfo
0 commit comments