fallback for hint select

This commit is contained in:
Richard Yan
2024-09-11 15:09:52 -07:00
parent f1a1b77828
commit daacae9edc
2 changed files with 30 additions and 17 deletions

View File

@@ -9,8 +9,12 @@ import org.chipsalliance.diplomacy.ValName
import org.chipsalliance.diplomacy.lazymodule._
import org.chipsalliance.diplomacy.nodes.{RenderedEdge, SimpleNodeImp, SinkNode, SourceNode}
object ExtPolicyNodeImp extends SimpleNodeImp[Int, Int, Int, UInt] {
def bundle(x: Int) = UInt(x.W)
class ExtPolicyBundle(x: Int) extends Bundle {
val hint = Output(UInt(x.W))
val actual = Input(UInt(x.W))
}
object ExtPolicyNodeImp extends SimpleNodeImp[Int, Int, Int, ExtPolicyBundle] {
def bundle(x: Int) = new ExtPolicyBundle(x)
def edge(x: Int, y: Int, p: Parameters, sourceInfo: SourceInfo): Int = x
def render(x: Int): RenderedEdge = RenderedEdge("ffffff")
}
@@ -23,17 +27,12 @@ class XbarWithExtPolicy(nameSuffix: Option[String] = None)
class ImplChild extends Impl {
val policy: TLArbiter.Policy = (width, valids, select) => {
val readys = policySlaveNode.in.head._1
Mux((valids & readys).orR,
readys, // take hint
TLArbiter.lowestIndexFirst(width, valids, select)
)
// readys & VecInit.fill(width)(VecInit((valids.asBools zip readys.asBools).map {
// case (v, r) => r || !v
// }).asUInt.andR).asUInt
val in = policySlaveNode.in.head._1
val hintHit = (valids & in.hint).orR
val fallback = TLArbiter.lowestIndexFirst(width, valids, !hintHit && select)
in.actual := select.asTypeOf(in.actual.cloneType)
Mux(hintHit, in.hint, fallback)
}
// val wide_bundle = TLBundleParameters.union((node.in ++ node.out).map(_._2.bundle))
// override def desiredName = (Seq("TLXbar") ++ nameSuffix ++ Seq(s"i${node.in.size}_o${node.out.size}_${wide_bundle.shortName}")).mkString("_")
TLXbar.circuit(policy, node.in, node.out)
}

View File

@@ -671,11 +671,26 @@ class RadianceClusterModuleImp(outer: RadianceCluster) extends ClusterModuleImp(
ws := TLArbiter.roundRobin(vs.getWidth, vs, uniform_fires(rw)(bid).asUInt.orR)
}
// mask valid into xbar to prevent triggering assertion
(word_selects_1h zip outer.uniform_nodes_in).foreach { case (ws, ui) =>
ui(bid).foreach { sources =>
// (word_selects_1h zip outer.uniform_nodes_in).foreach { case (ws, ui) =>
// ui(bid).foreach { sources =>
// val in_valid = sources.map(_.in.head._1.a.valid)
// val out_valid = sources.map(_.out.head._1.a.valid)
// val ws_actual = Mux((ws & VecInit(in_valid).asUInt).orR,
// ws, TLArbiter.roundRobin(
// in_valid.length, VecInit(in_valid).asUInt, VecInit(sources.map(_.in.head._1.a.fire)).asUInt.orR))
// (in_valid lazyZip out_valid lazyZip ws_actual.asBools).foreach { case (iv, ov, sel) =>
// ov := iv && sel // only present output valid if input is selected
// }
// }
// }
(word_selects_1h lazyZip outer.uniform_policy_nodes lazyZip outer.uniform_nodes_in).foreach { case (ws, pn, ui) =>
(pn(bid) zip ui(bid)).foreach { case (policies, sources) =>
val in_valid = sources.map(_.in.head._1.a.valid)
val out_valid = sources.map(_.out.head._1.a.valid)
(in_valid lazyZip out_valid lazyZip ws.asBools).foreach { case (iv, ov, sel) =>
val hint_hit = (ws & VecInit(in_valid).asUInt).orR
val ws_actual = Mux(hint_hit, ws, TLArbiter.lowestIndexFirst(
in_valid.length, VecInit(in_valid).asUInt, hint_hit && policies.out.head._1.actual(0)))
(in_valid lazyZip out_valid lazyZip ws_actual.asBools).foreach { case (iv, ov, sel) =>
ov := iv && sel // only present output valid if input is selected
}
}
@@ -683,8 +698,7 @@ class RadianceClusterModuleImp(outer: RadianceCluster) extends ClusterModuleImp(
(outer.uniform_policy_nodes zip word_selects_1h).zipWithIndex.foreach { case ((nodes_bw, ws), rw) =>
nodes_bw(bid).foreach { policy =>
println(s"policy out ${policy.out.head._1.getWidth}, word select ${ws.getWidth}")
policy.out.head._1 := ws
policy.out.head._1.hint := ws
}
}
}