Merged with origin/graphics, MemTracer able to read and write according to tracefile

This commit is contained in:
Vamber Yang
2023-03-08 17:38:59 -08:00

View File

@@ -7,8 +7,15 @@ import chisel3.util._
import freechips.rocketchip.config.Parameters import freechips.rocketchip.config.Parameters
import freechips.rocketchip.diplomacy._ import freechips.rocketchip.diplomacy._
import freechips.rocketchip.devices.tilelink.TLTestRAM import freechips.rocketchip.devices.tilelink.TLTestRAM
import freechips.rocketchip.util.ShiftQueue
import freechips.rocketchip.unittest._ import freechips.rocketchip.unittest._
class CoalRegEntry(val addressWidth: Int) extends Bundle {
val source = UInt(64.W)
val address = UInt(addressWidth.W)
val data = UInt(64.W /* FIXME hardcoded */ )
}
class CoalescingUnit(numThreads: Int = 1)(implicit p: Parameters) class CoalescingUnit(numThreads: Int = 1)(implicit p: Parameters)
extends LazyModule { extends LazyModule {
// val beatBytes = 8 // val beatBytes = 8
@@ -49,31 +56,37 @@ class CoalescingUnit(numThreads: Int = 1)(implicit p: Parameters)
lazy val module = new Impl lazy val module = new Impl
class Impl extends LazyModuleImp(this) { class Impl extends LazyModuleImp(this) {
// Per-lane FIFO that buffers incoming requests. // Per-lane FIFO that buffers incoming requests
val addressWidth = node.in(0)._1.a.bits.address.getWidth.W val addressWidth = node.in(0)._1.params.addressBits
val coalRegEntry = new CoalRegEntry(addressWidth)
val fifos = Seq.tabulate(numThreads) { _ => val fifos = Seq.tabulate(numThreads) { _ =>
Module(new Queue(UInt(addressWidth), 4 /* FIXME hardcoded */ )) Module(
new ShiftQueue(coalRegEntry, 4 /* FIXME hardcoded */ )
)
} }
// Override IdentityNode implementation so that we wire node output to the // Override IdentityNode implementation so that we wire node output to the
// FIFO output, instead of directly passing through node input // FIFO output, instead of directly passing through node input.
// (see IdentityNode.instantiate()). // See IdentityNode definition in `diplomacy/Nodes.scala`.
((node.in zip node.out) zip fifos) foreach { ((node.in zip node.out) zip fifos) foreach {
case (((tlIn, _), (tlOut, edgeOut)), fifo) => case (((tlIn, _), (tlOut, edgeOut)), fifo) =>
val newReq = Wire(coalRegEntry)
newReq.source := tlIn.a.bits.source
newReq.address := tlIn.a.bits.address
newReq.data := tlIn.a.bits.data
fifo.io.enq.valid := tlIn.a.valid fifo.io.enq.valid := tlIn.a.valid
fifo.io.enq.bits := tlIn.a.bits.address fifo.io.enq.bits := newReq
fifo.io.deq.ready := true.B fifo.io.deq.ready := true.B
val head = fifo.io.deq.bits
tlOut.a.valid := fifo.io.deq.valid tlOut.a.valid := fifo.io.deq.valid
// FIXME: generate Get or Put according to read/write // FIXME: generate Get or Put according to read/write
tlOut.a.bits := edgeOut tlOut.a.bits := edgeOut
.Get( .Get(
// FIXME: When using TLRAM, unlike TLTestRAM, D responses do not come fromSource = head.source,
// around immediately, so need to keep track of inflight requests and
// allocate sourceId accordingly.
fromSource = 0.U,
// `toAddress` should be aligned to 2**lgSize // `toAddress` should be aligned to 2**lgSize
toAddress = fifo.io.deq.bits, toAddress = head.address,
// 64 bits = 8 bytes = 2**(3) bytes // 64 bits = 8 bytes = 2**(3) bytes
lgSize = 0.U lgSize = 0.U
// data = (i + 100).U // data = (i + 100).U
@@ -82,8 +95,6 @@ class CoalescingUnit(numThreads: Int = 1)(implicit p: Parameters)
._2 ._2
tlIn.d <> tlOut.d tlIn.d <> tlOut.d
val fifoInput = tlIn.a
dontTouch(fifoInput)
dontTouch(tlIn.a) dontTouch(tlIn.a)
dontTouch(tlOut.a) dontTouch(tlOut.a)
dontTouch(tlOut.d) dontTouch(tlOut.d)
@@ -162,6 +173,7 @@ class MemTraceDriverImp(outer: MemTraceDriver, numThreads: Int)
tlOut.a.bits.data := 0.U tlOut.a.bits.data := 0.U
when (req.is_store) { when (req.is_store) {
tlOut.a.bits := edge.Put( tlOut.a.bits := edge.Put(
fromSource = 0.U, fromSource = 0.U,
toAddress = req.address, toAddress = req.address,
// 64 bits = 8 bytes = 2**(3) bytes // 64 bits = 8 bytes = 2**(3) bytes