Remove module dependency for uncoalescer instantiation
for easier unittesting. now builds.
This commit is contained in:
@@ -893,14 +893,14 @@ class CoalescingUnitImp(outer: CoalescingUnit, config: CoalescerConfig)
|
||||
}
|
||||
|
||||
val uncoalescer = Module(
|
||||
new Uncoalescer(config, reqQueues, coalReqT, coalescer.invalidateT)
|
||||
new Uncoalescer(config, nonCoalReqT, coalReqT)
|
||||
)
|
||||
// connect coalesced request that is newly generated and being recorded in
|
||||
// the uncoalescer
|
||||
uncoalescer.io.coalReq <> coalescer.io.coalReq
|
||||
uncoalescer.io.invalidate := coalescer.io.invalidate
|
||||
val reqQueueHeads = reqQueues.io.queue.deq.map(_.bits)
|
||||
uncoalescer.io.window := reqQueues.io
|
||||
uncoalescer.io.windowElts := reqQueues.io.elts
|
||||
// connect coalesced response going into the uncoalescer, ready to be
|
||||
// uncoalesced
|
||||
// Cleanup: custom <>?
|
||||
@@ -940,20 +940,22 @@ class CoalescingUnitImp(outer: CoalescingUnit, config: CoalescerConfig)
|
||||
|
||||
class Uncoalescer(
|
||||
config: CoalescerConfig,
|
||||
queueT: CoalShiftQueue[NonCoalescedRequest],
|
||||
coalReqT: Request,
|
||||
coalInvalidateT: Valid[Vec[UInt]],
|
||||
nonCoalReqT: NonCoalescedRequest,
|
||||
coalReqT: CoalescedRequest,
|
||||
) extends Module {
|
||||
val inflightTable = Module(new InflightCoalReqTable(config))
|
||||
val io = IO(new Bundle {
|
||||
// generated coalesced request, connected to the output of the coalescer.
|
||||
val coalReq = Flipped(DecoupledIO(coalReqT.cloneType))
|
||||
// invalidate signal coming out of coalescer.
|
||||
val invalidate = Input(coalInvalidateT.cloneType)
|
||||
val invalidate = Input(Valid(Vec(config.numLanes, UInt(config.queueDepth.W))))
|
||||
// coalescing window, connected to the contents of the request queues.
|
||||
// Uncoalescer looks at the queue entries that got coalesced into `coalReq`
|
||||
// in order to record which lanes this coalReq originally came from.
|
||||
val window = Input(queueT.io.cloneType)
|
||||
// We only care about window.elts because the coalescer would have made
|
||||
// sure it only looked at the valid entries.
|
||||
// TODO: duplicate type construction
|
||||
val windowElts = Input(Vec(config.numLanes, Vec(config.queueDepth, nonCoalReqT)))
|
||||
val coalResp = Flipped(Decoupled(new CoalescedResponse(config)))
|
||||
val uncoalResps = Output(
|
||||
Vec(
|
||||
@@ -977,7 +979,7 @@ class Uncoalescer(
|
||||
.foreach { case ((laneEntry, laneInv), lane) =>
|
||||
(laneEntry.reqs zip laneInv.asBools).zipWithIndex
|
||||
.foreach { case ((reqEntry, inv), i) =>
|
||||
val req = io.window.elts(lane)(i)
|
||||
val req = io.windowElts(lane)(i)
|
||||
when((io.invalidate.valid && inv)) {
|
||||
printf(
|
||||
s"coalescer: reqQueue($lane)($i) got invalidated (source=%d)\n",
|
||||
|
||||
@@ -735,125 +735,145 @@ class UncoalescerUnitTest extends AnyFlatSpec with ChiselScalatestTester {
|
||||
val coalDataWidth = 128
|
||||
val numInflightCoalRequests = 4
|
||||
|
||||
val config = uncoalescerTestConfig
|
||||
|
||||
val nonCoalReqT = new NonCoalescedRequest(config)
|
||||
val coalReqT = new CoalescedRequest(config)
|
||||
it should "work in general case" in {
|
||||
test(new Uncoalescer(uncoalescerTestConfig))
|
||||
test(new Uncoalescer(config, nonCoalReqT, coalReqT))
|
||||
// vcs helps with simulation time, but sometimes errors with
|
||||
// "mutation occurred during iteration" java error
|
||||
// .withAnnotations(Seq(VcsBackendAnnotation))
|
||||
{ c =>
|
||||
val sourceId = 0.U
|
||||
val four = c.io.newEntry.sizeEnumT.FOUR
|
||||
c.io.coalReqValid.poke(true.B)
|
||||
c.io.newEntry.source.poke(sourceId)
|
||||
c.io.newEntry.lanes(0).reqs(0).valid.poke(true.B)
|
||||
c.io.newEntry.lanes(0).reqs(0).source.poke(1.U)
|
||||
c.io.newEntry.lanes(0).reqs(0).offset.poke(1.U)
|
||||
c.io.newEntry.lanes(0).reqs(0).sizeEnum.poke(four)
|
||||
c.io.newEntry.lanes(0).reqs(1).valid.poke(true.B)
|
||||
c.io.newEntry.lanes(0).reqs(1).source.poke(2.U)
|
||||
c.io.newEntry.lanes(0).reqs(1).offset.poke(1.U) // same offset to different lanes
|
||||
c.io.newEntry.lanes(0).reqs(1).sizeEnum.poke(four)
|
||||
c.io.newEntry.lanes(1).reqs(0).valid.poke(false.B)
|
||||
c.io.newEntry.lanes(2).reqs(0).valid.poke(true.B)
|
||||
c.io.newEntry.lanes(2).reqs(0).source.poke(2.U)
|
||||
c.io.newEntry.lanes(2).reqs(0).offset.poke(2.U)
|
||||
c.io.newEntry.lanes(2).reqs(0).sizeEnum.poke(four)
|
||||
c.io.newEntry.lanes(2).reqs(1).valid.poke(true.B)
|
||||
c.io.newEntry.lanes(2).reqs(1).source.poke(2.U)
|
||||
c.io.newEntry.lanes(2).reqs(1).offset.poke(3.U)
|
||||
c.io.newEntry.lanes(2).reqs(1).sizeEnum.poke(four)
|
||||
c.io.newEntry.lanes(3).reqs(0).valid.poke(false.B)
|
||||
// val four = c.io.newEntry.sizeEnumT.FOUR
|
||||
c.io.coalReq.valid.poke(true.B)
|
||||
c.io.windowElts(0)(0).op.poke(0.U)
|
||||
c.io.windowElts(0)(0).source.poke(1.U)
|
||||
c.io.windowElts(0)(0).address.poke(0x4.U)
|
||||
c.io.windowElts(0)(0).size.poke(2.U)
|
||||
c.io.windowElts(0)(1).op.poke(0.U)
|
||||
c.io.windowElts(0)(1).source.poke(2.U)
|
||||
c.io.windowElts(0)(1).address.poke(0x4.U)
|
||||
c.io.windowElts(0)(1).size.poke(2.U)
|
||||
c.io.windowElts(2)(0).op.poke(0.U)
|
||||
c.io.windowElts(2)(0).source.poke(1.U)
|
||||
c.io.windowElts(2)(0).address.poke(0x4.U)
|
||||
c.io.windowElts(2)(0).size.poke(2.U)
|
||||
c.io.windowElts(2)(1).op.poke(0.U)
|
||||
c.io.windowElts(2)(1).source.poke(2.U)
|
||||
c.io.windowElts(2)(1).address.poke(0x4.U)
|
||||
c.io.windowElts(2)(1).size.poke(2.U)
|
||||
// c.io.newEntry.source.poke(sourceId)
|
||||
// c.io.newEntry.lanes(0).reqs(0).valid.poke(true.B)
|
||||
// c.io.newEntry.lanes(0).reqs(0).source.poke(1.U)
|
||||
// c.io.newEntry.lanes(0).reqs(0).offset.poke(1.U)
|
||||
// c.io.newEntry.lanes(0).reqs(0).sizeEnum.poke(four)
|
||||
// c.io.newEntry.lanes(0).reqs(1).valid.poke(true.B)
|
||||
// c.io.newEntry.lanes(0).reqs(1).source.poke(2.U)
|
||||
// c.io.newEntry.lanes(0).reqs(1).offset.poke(1.U) // same offset to different lanes
|
||||
// c.io.newEntry.lanes(0).reqs(1).sizeEnum.poke(four)
|
||||
// c.io.newEntry.lanes(1).reqs(0).valid.poke(false.B)
|
||||
// c.io.newEntry.lanes(2).reqs(0).valid.poke(true.B)
|
||||
// c.io.newEntry.lanes(2).reqs(0).source.poke(2.U)
|
||||
// c.io.newEntry.lanes(2).reqs(0).offset.poke(2.U)
|
||||
// c.io.newEntry.lanes(2).reqs(0).sizeEnum.poke(four)
|
||||
// c.io.newEntry.lanes(2).reqs(1).valid.poke(true.B)
|
||||
// c.io.newEntry.lanes(2).reqs(1).source.poke(2.U)
|
||||
// c.io.newEntry.lanes(2).reqs(1).offset.poke(3.U)
|
||||
// c.io.newEntry.lanes(2).reqs(1).sizeEnum.poke(four)
|
||||
// c.io.newEntry.lanes(3).reqs(0).valid.poke(false.B)
|
||||
|
||||
c.clock.step()
|
||||
// c.clock.step()
|
||||
|
||||
c.io.coalReqValid.poke(false.B)
|
||||
// c.io.coalReqValid.poke(false.B)
|
||||
|
||||
c.clock.step()
|
||||
// c.clock.step()
|
||||
|
||||
c.io.coalResp.valid.poke(true.B)
|
||||
c.io.coalResp.bits.source.poke(sourceId)
|
||||
val lit = (BigInt(0x0123456789abcdefL) << 64) | BigInt(0x5ca1ab1edeadbeefL)
|
||||
// val lit = BigInt(0x0123456789abcdefL)
|
||||
c.io.coalResp.bits.data.poke(lit.U)
|
||||
// c.io.coalResp.valid.poke(true.B)
|
||||
// c.io.coalResp.bits.source.poke(sourceId)
|
||||
// val lit = (BigInt(0x0123456789abcdefL) << 64) | BigInt(0x5ca1ab1edeadbeefL)
|
||||
// // val lit = BigInt(0x0123456789abcdefL)
|
||||
// c.io.coalResp.bits.data.poke(lit.U)
|
||||
|
||||
// table lookup is combinational at the same cycle
|
||||
c.io.uncoalResps(0)(0).valid.expect(true.B)
|
||||
c.io.uncoalResps(1)(0).valid.expect(false.B)
|
||||
c.io.uncoalResps(2)(0).valid.expect(true.B)
|
||||
c.io.uncoalResps(3)(0).valid.expect(false.B)
|
||||
// // table lookup is combinational at the same cycle
|
||||
// c.io.uncoalResps(0)(0).valid.expect(true.B)
|
||||
// c.io.uncoalResps(1)(0).valid.expect(false.B)
|
||||
// c.io.uncoalResps(2)(0).valid.expect(true.B)
|
||||
// c.io.uncoalResps(3)(0).valid.expect(false.B)
|
||||
|
||||
// offset is counting from LSB
|
||||
c.io.uncoalResps(0)(0).bits.data.expect(0x5ca1ab1eL.U)
|
||||
c.io.uncoalResps(0)(0).bits.source.expect(1.U)
|
||||
c.io.uncoalResps(0)(1).bits.data.expect(0x5ca1ab1eL.U)
|
||||
c.io.uncoalResps(0)(1).bits.source.expect(2.U)
|
||||
c.io.uncoalResps(2)(0).bits.data.expect(0x89abcdefL.U)
|
||||
c.io.uncoalResps(2)(0).bits.source.expect(2.U)
|
||||
c.io.uncoalResps(2)(1).bits.data.expect(0x01234567L.U)
|
||||
c.io.uncoalResps(2)(1).bits.source.expect(2.U)
|
||||
// // offset is counting from LSB
|
||||
// c.io.uncoalResps(0)(0).bits.data.expect(0x5ca1ab1eL.U)
|
||||
// c.io.uncoalResps(0)(0).bits.source.expect(1.U)
|
||||
// c.io.uncoalResps(0)(1).bits.data.expect(0x5ca1ab1eL.U)
|
||||
// c.io.uncoalResps(0)(1).bits.source.expect(2.U)
|
||||
// c.io.uncoalResps(2)(0).bits.data.expect(0x89abcdefL.U)
|
||||
// c.io.uncoalResps(2)(0).bits.source.expect(2.U)
|
||||
// c.io.uncoalResps(2)(1).bits.data.expect(0x01234567L.U)
|
||||
// c.io.uncoalResps(2)(1).bits.source.expect(2.U)
|
||||
}
|
||||
}
|
||||
|
||||
it should "uncoalesce when coalesced to the same word offset" in {
|
||||
test(new Uncoalescer(uncoalescerTestConfig))
|
||||
// .withAnnotations(Seq(VcsBackendAnnotation))
|
||||
{ c =>
|
||||
val sourceId = 0.U
|
||||
val four = c.io.newEntry.sizeEnumT.FOUR
|
||||
c.io.coalReqValid.poke(true.B)
|
||||
c.io.newEntry.source.poke(sourceId)
|
||||
c.io.newEntry.lanes(0).reqs(0).valid.poke(true.B)
|
||||
c.io.newEntry.lanes(0).reqs(0).source.poke(0.U)
|
||||
c.io.newEntry.lanes(0).reqs(0).offset.poke(1.U)
|
||||
c.io.newEntry.lanes(0).reqs(0).sizeEnum.poke(four)
|
||||
c.io.newEntry.lanes(0).reqs(1).valid.poke(false.B)
|
||||
c.io.newEntry.lanes(1).reqs(0).valid.poke(true.B)
|
||||
c.io.newEntry.lanes(1).reqs(0).source.poke(1.U)
|
||||
c.io.newEntry.lanes(1).reqs(0).offset.poke(1.U)
|
||||
c.io.newEntry.lanes(1).reqs(0).sizeEnum.poke(four)
|
||||
c.io.newEntry.lanes(1).reqs(1).valid.poke(false.B)
|
||||
c.io.newEntry.lanes(2).reqs(0).valid.poke(true.B)
|
||||
c.io.newEntry.lanes(2).reqs(0).source.poke(2.U)
|
||||
c.io.newEntry.lanes(2).reqs(0).offset.poke(1.U)
|
||||
c.io.newEntry.lanes(2).reqs(0).sizeEnum.poke(four)
|
||||
c.io.newEntry.lanes(2).reqs(1).valid.poke(false.B)
|
||||
c.io.newEntry.lanes(3).reqs(0).valid.poke(true.B)
|
||||
c.io.newEntry.lanes(3).reqs(0).source.poke(3.U)
|
||||
c.io.newEntry.lanes(3).reqs(0).offset.poke(1.U)
|
||||
c.io.newEntry.lanes(3).reqs(0).sizeEnum.poke(four)
|
||||
c.io.newEntry.lanes(3).reqs(1).valid.poke(false.B)
|
||||
// it should "uncoalesce when coalesced to the same word offset" in {
|
||||
// test(new Uncoalescer(uncoalescerTestConfig))
|
||||
// // .withAnnotations(Seq(VcsBackendAnnotation))
|
||||
// { c =>
|
||||
// val sourceId = 0.U
|
||||
// val four = c.io.newEntry.sizeEnumT.FOUR
|
||||
// c.io.coalReqValid.poke(true.B)
|
||||
// c.io.newEntry.source.poke(sourceId)
|
||||
// c.io.newEntry.lanes(0).reqs(0).valid.poke(true.B)
|
||||
// c.io.newEntry.lanes(0).reqs(0).source.poke(0.U)
|
||||
// c.io.newEntry.lanes(0).reqs(0).offset.poke(1.U)
|
||||
// c.io.newEntry.lanes(0).reqs(0).sizeEnum.poke(four)
|
||||
// c.io.newEntry.lanes(0).reqs(1).valid.poke(false.B)
|
||||
// c.io.newEntry.lanes(1).reqs(0).valid.poke(true.B)
|
||||
// c.io.newEntry.lanes(1).reqs(0).source.poke(1.U)
|
||||
// c.io.newEntry.lanes(1).reqs(0).offset.poke(1.U)
|
||||
// c.io.newEntry.lanes(1).reqs(0).sizeEnum.poke(four)
|
||||
// c.io.newEntry.lanes(1).reqs(1).valid.poke(false.B)
|
||||
// c.io.newEntry.lanes(2).reqs(0).valid.poke(true.B)
|
||||
// c.io.newEntry.lanes(2).reqs(0).source.poke(2.U)
|
||||
// c.io.newEntry.lanes(2).reqs(0).offset.poke(1.U)
|
||||
// c.io.newEntry.lanes(2).reqs(0).sizeEnum.poke(four)
|
||||
// c.io.newEntry.lanes(2).reqs(1).valid.poke(false.B)
|
||||
// c.io.newEntry.lanes(3).reqs(0).valid.poke(true.B)
|
||||
// c.io.newEntry.lanes(3).reqs(0).source.poke(3.U)
|
||||
// c.io.newEntry.lanes(3).reqs(0).offset.poke(1.U)
|
||||
// c.io.newEntry.lanes(3).reqs(0).sizeEnum.poke(four)
|
||||
// c.io.newEntry.lanes(3).reqs(1).valid.poke(false.B)
|
||||
|
||||
c.clock.step()
|
||||
// c.clock.step()
|
||||
|
||||
c.io.coalReqValid.poke(false.B)
|
||||
// c.io.coalReqValid.poke(false.B)
|
||||
|
||||
c.clock.step()
|
||||
// c.clock.step()
|
||||
|
||||
c.io.coalResp.valid.poke(true.B)
|
||||
c.io.coalResp.bits.source.poke(sourceId)
|
||||
val lit = (BigInt(0x0123456789abcdefL) << 64) | BigInt(0x5ca1ab1edeadbeefL)
|
||||
c.io.coalResp.bits.data.poke(lit.U)
|
||||
// c.io.coalResp.valid.poke(true.B)
|
||||
// c.io.coalResp.bits.source.poke(sourceId)
|
||||
// val lit = (BigInt(0x0123456789abcdefL) << 64) | BigInt(0x5ca1ab1edeadbeefL)
|
||||
// c.io.coalResp.bits.data.poke(lit.U)
|
||||
|
||||
// table lookup is combinational at the same cycle
|
||||
// offset is counting from LSB
|
||||
c.io.uncoalResps(0)(0).valid.expect(true.B)
|
||||
c.io.uncoalResps(0)(0).bits.data.expect(0x5ca1ab1eL.U)
|
||||
c.io.uncoalResps(0)(0).bits.source.expect(0.U)
|
||||
c.io.uncoalResps(0)(1).valid.expect(false.B)
|
||||
c.io.uncoalResps(1)(0).valid.expect(true.B)
|
||||
c.io.uncoalResps(1)(0).bits.data.expect(0x5ca1ab1eL.U)
|
||||
c.io.uncoalResps(1)(0).bits.source.expect(1.U)
|
||||
c.io.uncoalResps(1)(1).valid.expect(false.B)
|
||||
c.io.uncoalResps(2)(0).valid.expect(true.B)
|
||||
c.io.uncoalResps(2)(0).bits.data.expect(0x5ca1ab1eL.U)
|
||||
c.io.uncoalResps(2)(0).bits.source.expect(2.U)
|
||||
c.io.uncoalResps(2)(1).valid.expect(false.B)
|
||||
c.io.uncoalResps(3)(0).valid.expect(true.B)
|
||||
c.io.uncoalResps(3)(0).bits.data.expect(0x5ca1ab1eL.U)
|
||||
c.io.uncoalResps(3)(0).bits.source.expect(3.U)
|
||||
c.io.uncoalResps(3)(1).valid.expect(false.B)
|
||||
}
|
||||
}
|
||||
// // table lookup is combinational at the same cycle
|
||||
// // offset is counting from LSB
|
||||
// c.io.uncoalResps(0)(0).valid.expect(true.B)
|
||||
// c.io.uncoalResps(0)(0).bits.data.expect(0x5ca1ab1eL.U)
|
||||
// c.io.uncoalResps(0)(0).bits.source.expect(0.U)
|
||||
// c.io.uncoalResps(0)(1).valid.expect(false.B)
|
||||
// c.io.uncoalResps(1)(0).valid.expect(true.B)
|
||||
// c.io.uncoalResps(1)(0).bits.data.expect(0x5ca1ab1eL.U)
|
||||
// c.io.uncoalResps(1)(0).bits.source.expect(1.U)
|
||||
// c.io.uncoalResps(1)(1).valid.expect(false.B)
|
||||
// c.io.uncoalResps(2)(0).valid.expect(true.B)
|
||||
// c.io.uncoalResps(2)(0).bits.data.expect(0x5ca1ab1eL.U)
|
||||
// c.io.uncoalResps(2)(0).bits.source.expect(2.U)
|
||||
// c.io.uncoalResps(2)(1).valid.expect(false.B)
|
||||
// c.io.uncoalResps(3)(0).valid.expect(true.B)
|
||||
// c.io.uncoalResps(3)(0).bits.data.expect(0x5ca1ab1eL.U)
|
||||
// c.io.uncoalResps(3)(0).bits.source.expect(3.U)
|
||||
// c.io.uncoalResps(3)(1).valid.expect(false.B)
|
||||
// }
|
||||
// }
|
||||
}
|
||||
|
||||
class CoalInflightTableUnitTest extends AnyFlatSpec with ChiselScalatestTester {
|
||||
|
||||
Reference in New Issue
Block a user