Skip to content

Commit 5f59e1f

Browse files
committed
fix(Linklayer): add Tx shadow buffer to cover lcrdv latency from AsyncBridge
1 parent b529f01 commit 5f59e1f

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

src/main/scala/coupledL2/tl2chi/chi/LinkLayer.scala

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -264,6 +264,9 @@ class Decoupled2LCredit[T <: Bundle](
264264
val out = ChannelIO(gen.cloneType)
265265
val state = Input(new LinkState())
266266
})
267+
// Shadow Buffer (depth=32, flow mode for low latency)
268+
val shadow_buffer = Module(new Queue(gen, 32, flow = true, pipe = false))
269+
shadow_buffer.io.enq <> io.in
267270

268271
val out = Wire(io.out.cloneType)
269272

@@ -279,8 +282,11 @@ class Decoupled2LCredit[T <: Bundle](
279282
val lcreditsMaxAll = lcreditsMax + overlcreditVal
280283
val lcreditPool = RegInit(overlcreditVal.U(log2Up(lcreditsMaxAll+1).W))
281284

282-
val returnLCreditValid = !io.in.valid && state === LinkStates.DEACTIVATE && lcreditPool =/= overlcreditVal.U
283-
val flitv = io.in.fire || returnLCreditValid
285+
val returnLCreditValid = !shadow_buffer.io.deq.valid && state === LinkStates.DEACTIVATE && lcreditPool =/= overlcreditVal.U
286+
val can_issue_flit = shadow_buffer.io.deq.valid && lcreditPool=/=0.U && !disableFlit
287+
shadow_buffer.io.deq.ready := can_issue_flit
288+
289+
val flitv = can_issue_flit || returnLCreditValid
284290

285291
when (acceptLCredit) {
286292
when (!flitv) {
@@ -293,12 +299,10 @@ class Decoupled2LCredit[T <: Bundle](
293299
}
294300
}
295301

296-
io.in.ready := lcreditPool =/= 0.U && !disableFlit
297-
298302
io.out <> out
299303
out.flitpend := RegNext(true.B, init = false.B) // TODO
300304
out.flitv := RegNext(flitv, init = false.B)
301-
out.flit := RegEnable(Mux(io.in.valid, Cat(io.in.bits.getElements.map(_.asUInt)), 0.U /* LCrdReturn */), flitv)
305+
out.flit := RegEnable(Mux(shadow_buffer.io.deq.valid, Cat(shadow_buffer.io.deq.bits.getElements.map(_.asUInt)), 0.U /* LCrdReturn */), flitv)
302306

303307
/**
304308
* performance counters

0 commit comments

Comments
 (0)