Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TLSourceShrinker: Preserve metadata when no shrinkage is required #2466

Merged
merged 3 commits into from
May 15, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
18 changes: 10 additions & 8 deletions src/main/scala/tilelink/SourceShrinker.scala
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,21 @@ import scala.math.{min,max}
class TLSourceShrinker(maxInFlight: Int)(implicit p: Parameters) extends LazyModule
{
require (maxInFlight > 0)
private def noShrinkRequired(client: TLClientPortParameters) = maxInFlight >= client.endSourceId

// The SourceShrinker completely destroys all FIFO property guarantees
private val client = TLMasterParameters.v1(
name = "TLSourceShrinker",
sourceId = IdRange(0, maxInFlight))
val node = TLAdapterNode(
// We erase all client information since we crush the source Ids
clientFn = { cp => TLMasterPortParameters.v1(
clients = Seq(client.v1copy(requestFifo = cp.clients.exists(_.requestFifo))),
echoFields = cp.echoFields,
requestFields = cp.requestFields,
responseKeys = cp.responseKeys
)},
clientFn = { cp => if (noShrinkRequired(cp)) { cp } else {
// We erase all client information since we crush the source Ids
TLMasterPortParameters.v1(
clients = Seq(client.v1copy(requestFifo = cp.clients.exists(_.requestFifo))),
echoFields = cp.echoFields,
requestFields = cp.requestFields,
responseKeys = cp.responseKeys)
} },
managerFn = { mp => mp.v1copy(managers = mp.managers.map(m => m.v1copy(fifoId = if (maxInFlight==1) Some(0) else m.fifoId))) })

lazy val module = new LazyModuleImp(this) {
Expand All @@ -39,7 +41,7 @@ class TLSourceShrinker(maxInFlight: Int)(implicit p: Parameters) extends LazyMod
in.c.ready := Bool(true)
in.e.ready := Bool(true)

if (maxInFlight >= edgeIn.client.endSourceId) {
if (noShrinkRequired(edgeIn.client)) {
out.a <> in.a
in.d <> out.d
} else {
Expand Down
4 changes: 2 additions & 2 deletions src/main/scala/tilelink/Xbar.scala
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ class TLXbar(policy: TLArbiter.Policy = TLArbiter.roundRobin)(implicit p: Parame
endSinkId = TLXbar.mapOutputIds(seq).map(_.end).max,
managers = seq.flatMap { port =>
require (port.beatBytes == seq(0).beatBytes,
s"Xbar data widths don't match: ${port.managers.map(_.name)} has ${port.beatBytes}B vs ${seq(0).managers.map(_.name)} has ${seq(0).beatBytes}B")
s"Xbar ($name with parent $parent) data widths don't match: ${port.managers.map(_.name)} has ${port.beatBytes}B vs ${seq(0).managers.map(_.name)} has ${seq(0).beatBytes}B")
val fifoIdMapper = fifoIdFactory()
port.managers map { manager => manager.v1copy(
fifoId = manager.fifoId.map(fifoIdMapper(_))
Expand All @@ -66,7 +66,7 @@ class TLXbar(policy: TLArbiter.Policy = TLArbiter.roundRobin)(implicit p: Parame
lazy val module = new LazyModuleImp(this) {
if ((node.in.size * node.out.size) > (8*32)) {
println (s"!!! WARNING !!!")
println (s" Your TLXbar ($name) is very large, with ${node.in.size} Masters and ${node.out.size} Slaves.")
println (s" Your TLXbar ($name with parent $parent) is very large, with ${node.in.size} Masters and ${node.out.size} Slaves.")
println (s"!!! WARNING !!!")
}

Expand Down