Fix lookup succeeding on invalid entry; add test case
also enable VCS FSDB annotation in chiseltest
This commit is contained in:
@@ -258,9 +258,10 @@ class InflightCoalReqTable(
|
|||||||
// If entry with a lower index is empty, it always takes priority
|
// If entry with a lower index is empty, it always takes priority
|
||||||
cascadeMatchIndex(i) := Mux(match_, i.U, cascadeMatchIndex(i + 1))
|
cascadeMatchIndex(i) := Mux(match_, i.U, cascadeMatchIndex(i + 1))
|
||||||
}
|
}
|
||||||
val matchIndex = cascadeMatchIndex(0)
|
val matchIndex = Wire(UInt())
|
||||||
val matchValid = Wire(Bool())
|
matchIndex := cascadeMatchIndex(0)
|
||||||
matchValid := table(matchIndex).bits.respSourceId === io.lookupSourceId
|
val matchValid = table(matchIndex).valid &&
|
||||||
|
(table(matchIndex).bits.respSourceId === io.lookupSourceId)
|
||||||
io.lookup.valid := matchValid
|
io.lookup.valid := matchValid
|
||||||
// TODO: return something actually useful
|
// TODO: return something actually useful
|
||||||
io.lookup.bits := table(matchIndex).bits.respSourceId
|
io.lookup.bits := table(matchIndex).bits.respSourceId
|
||||||
@@ -272,7 +273,6 @@ class InflightCoalReqTable(
|
|||||||
}
|
}
|
||||||
dontTouch(io.lookup)
|
dontTouch(io.lookup)
|
||||||
dontTouch(matchIndex)
|
dontTouch(matchIndex)
|
||||||
dontTouch(matchValid)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class InflightCoalReqTableEntry(val numLanes: Int, val sourceWidth: Int)
|
class InflightCoalReqTableEntry(val numLanes: Int, val sourceWidth: Int)
|
||||||
|
|||||||
@@ -38,19 +38,64 @@ class CoalescingUnitTest extends AnyFlatSpec with ChiselScalatestTester {
|
|||||||
val inflightCoalReqTableEntry =
|
val inflightCoalReqTableEntry =
|
||||||
new InflightCoalReqTableEntry(numLanes, sourceWidth)
|
new InflightCoalReqTableEntry(numLanes, sourceWidth)
|
||||||
|
|
||||||
it should "whatever" in {
|
it should "stop enqueueing when full" in {
|
||||||
test(new InflightCoalReqTable(numLanes, sourceWidth, entries)) { c =>
|
test(new InflightCoalReqTable(numLanes, sourceWidth, entries)) { c =>
|
||||||
// val tableEntry = new InflightCoalReqTableEntry(numLanes, sourceWidth)
|
for (i <- 0 until entries) {
|
||||||
val respSourceId = 0.U
|
c.io.enq.ready.expect(true.B)
|
||||||
|
c.io.enq.valid.poke(true.B)
|
||||||
|
c.io.enq.bits.fromLane.poke(0.U)
|
||||||
|
c.io.enq.bits.respSourceId.poke(i.U)
|
||||||
|
c.io.enq.bits.reqSourceIds.foreach { id => id.poke(0.U) }
|
||||||
|
|
||||||
|
c.clock.step()
|
||||||
|
}
|
||||||
|
|
||||||
|
c.io.enq.ready.expect(false.B)
|
||||||
c.io.enq.valid.poke(true.B)
|
c.io.enq.valid.poke(true.B)
|
||||||
c.io.enq.bits.fromLane.poke(0.U)
|
c.io.enq.bits.fromLane.poke(0.U)
|
||||||
c.io.enq.bits.respSourceId.poke(respSourceId)
|
c.io.enq.bits.respSourceId.poke(0.U)
|
||||||
c.io.enq.bits.reqSourceIds.foreach { id => id.poke(0.U) }
|
c.io.enq.bits.reqSourceIds.foreach { id => id.poke(0.U) }
|
||||||
|
|
||||||
c.clock.step()
|
c.clock.step()
|
||||||
c.io.lookup.ready.poke(true.B)
|
c.io.enq.ready.expect(false.B)
|
||||||
c.io.lookupSourceId.poke(respSourceId)
|
|
||||||
c.io.lookup.valid.expect(true.B)
|
|
||||||
c.io.lookup.bits.expect(respSourceId)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
it should "lookup matching entry" in {
|
||||||
|
test(new InflightCoalReqTable(numLanes, sourceWidth, entries))
|
||||||
|
.withAnnotations(Seq(VcsBackendAnnotation, WriteFsdbAnnotation)) { c =>
|
||||||
|
c.reset.poke(true.B)
|
||||||
|
c.clock.step(10)
|
||||||
|
c.reset.poke(false.B)
|
||||||
|
|
||||||
|
// enqueue one entry to not match at 0th index
|
||||||
|
c.io.enq.ready.expect(true.B)
|
||||||
|
c.io.enq.valid.poke(true.B)
|
||||||
|
c.io.enq.bits.fromLane.poke(0.U)
|
||||||
|
c.io.enq.bits.respSourceId.poke(0.U)
|
||||||
|
c.io.enq.bits.reqSourceIds.foreach { id => id.poke(0.U) }
|
||||||
|
|
||||||
|
c.clock.step()
|
||||||
|
|
||||||
|
val targetSourceId = 1.U
|
||||||
|
c.io.enq.ready.expect(true.B)
|
||||||
|
c.io.enq.valid.poke(true.B)
|
||||||
|
c.io.enq.bits.fromLane.poke(0.U)
|
||||||
|
c.io.enq.bits.respSourceId.poke(targetSourceId)
|
||||||
|
c.io.enq.bits.reqSourceIds.foreach { id => id.poke(0.U) }
|
||||||
|
|
||||||
|
c.clock.step()
|
||||||
|
|
||||||
|
c.io.lookup.ready.poke(true.B)
|
||||||
|
c.io.lookupSourceId.poke(targetSourceId)
|
||||||
|
c.io.lookup.valid.expect(true.B)
|
||||||
|
c.io.lookup.bits.expect(targetSourceId)
|
||||||
|
|
||||||
|
c.clock.step()
|
||||||
|
|
||||||
|
// test if matching entry dequeues after 1 cycle
|
||||||
|
c.io.lookup.ready.poke(true.B)
|
||||||
|
c.io.lookupSourceId.poke(targetSourceId)
|
||||||
|
c.io.lookup.valid.expect(false.B)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user