From c34853447b01ccda0a44370419b88c0c27025bdd Mon Sep 17 00:00:00 2001 From: Hansung Kim Date: Mon, 16 Oct 2023 01:11:50 -0700 Subject: [PATCH] Implement metadata retrieval in SourceGenerator --- src/main/scala/tilelink/Coalescing.scala | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/src/main/scala/tilelink/Coalescing.scala b/src/main/scala/tilelink/Coalescing.scala index 6ee71e9..bdc6edb 100644 --- a/src/main/scala/tilelink/Coalescing.scala +++ b/src/main/scala/tilelink/Coalescing.scala @@ -265,9 +265,8 @@ case class CoalescedResponse(config: CoalescerConfig) class SourceGenerator[T <: Data]( sourceWidth: Int, metadata: Option[T] = None, - ignoreInUse: Boolean = true -) - extends Module { + ignoreInUse: Boolean = false +) extends Module { val io = IO(new Bundle { val gen = Input(Bool()) val reclaim = Input(Valid(UInt(sourceWidth.W))) @@ -275,6 +274,14 @@ class SourceGenerator[T <: Data]( // for debugging; indicates whether there is at least one inflight request // that hasn't been reclaimed yet val inflight = Output(Bool()) + // below are used when metadata is not None + // `peek` is the retrieved metadata saved for the request when corresponding + // request has come back (and hence `reclaim` was set). + // Although these do not use ValidIO, it is safe because any in-flight + // response coming back should have allocated a valid entry in the table + // when it went out. + val meta = Input(metadata.getOrElse(UInt(0.W))) + val peek = Output(metadata.getOrElse(UInt(0.W))) }) val head = RegInit(UInt(sourceWidth.W), 0.U) head := Mux(io.gen, head + 1.U, head) @@ -304,8 +311,12 @@ class SourceGenerator[T <: Data]( io.id.bits := lowestFree when(io.gen && io.id.valid /* fire */ ) { occupancyTable(io.id.bits).id.valid := true.B // mark in use + if (metadata.isDefined) { + occupancyTable(io.id.bits).meta := io.meta + } } when(io.reclaim.valid) { + // @perf: would this require multiple write ports? occupancyTable(io.reclaim.bits).id.valid := false.B // mark freed } @@ -319,6 +330,10 @@ class SourceGenerator[T <: Data]( outstanding := outstanding - 1.U } + if (metadata.isDefined) { + io.peek := occupancyTable(io.reclaim.bits).meta + } + dontTouch(outstanding) }