Remove module dependency for uncoalescer instantiation
for easier unittesting. now builds.
This commit is contained in:
@@ -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