Add chiseltest for inflight table

This commit is contained in:
Hansung Kim
2023-03-11 23:20:50 -08:00
parent df0c2ba89f
commit 6de95587de
2 changed files with 56 additions and 5 deletions

View File

@@ -153,11 +153,6 @@ class CoalescingUnit(numLanes: Int = 1)(implicit p: Parameters)
inflightCoalReqTable.io.lookup.ready := tlCoal.d.valid
inflightCoalReqTable.io.lookupSourceId := tlCoal.d.bits.source
// FIXME: Reuse ShiftQueue(coalRegEntry) for now, but swap out to actual
// table structure
// val inflightCoalReqTable = Reg(
// Vec(NumInflightCoalRequests, new InflightCoalReqEntry(sourceWidth))
// )
(node.in zip node.out)(0) match {
case ((tlIn, edgeIn), (tlOut, _)) =>
assert(

View File

@@ -0,0 +1,56 @@
import chisel3._
import chiseltest._
import org.scalatest.flatspec.AnyFlatSpec
import freechips.rocketchip.tilelink._
class MyModule extends Module {
val io = IO(new Bundle {
val in = Input(UInt(16.W))
val out = Output(UInt(16.W))
})
io.out := RegNext(io.in)
}
class BasicTest extends AnyFlatSpec with ChiselScalatestTester {
// test class body here
it should "do something" in {
// test case body here
test(new MyModule) { c =>
// test body here
c.io.in.poke(0.U)
c.clock.step()
c.io.out.expect(0.U)
c.io.in.poke(42.U)
c.clock.step()
c.io.out.expect(42.U)
println("Last output value :" + c.io.out.peek().litValue)
}
}
}
class CoalescingUnitTest extends AnyFlatSpec with ChiselScalatestTester {
behavior of "inflight coalesced request table"
val numLanes = 4
val sourceWidth = 2
val entries = 4
val inflightCoalReqTableEntry =
new InflightCoalReqTableEntry(numLanes, sourceWidth)
it should "whatever" in {
test(new InflightCoalReqTable(numLanes, sourceWidth, entries)) { c =>
// val tableEntry = new InflightCoalReqTableEntry(numLanes, sourceWidth)
val respSourceId = 0.U
c.io.enq.valid.poke(true.B)
c.io.enq.bits.fromLane.poke(0.U)
c.io.enq.bits.respSourceId.poke(respSourceId)
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(respSourceId)
c.io.lookup.valid.expect(true.B)
c.io.lookup.bits.expect(respSourceId)
}
}
}