From 191dad78009c808130b9d80807d1a2f95be301e9 Mon Sep 17 00:00:00 2001 From: "Wesley W. Terpstra" Date: Tue, 16 May 2017 20:51:55 -0700 Subject: [PATCH] diplomacy: provide connect access to edges without bundles Forcing the bundles to exist early can mess up module ownership. --- src/main/scala/diplomacy/Nodes.scala | 14 ++++++++++---- src/main/scala/uncore/tilelink2/Nodes.scala | 6 +++--- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/src/main/scala/diplomacy/Nodes.scala b/src/main/scala/diplomacy/Nodes.scala index 43db07b7..259eb8f4 100644 --- a/src/main/scala/diplomacy/Nodes.scala +++ b/src/main/scala/diplomacy/Nodes.scala @@ -18,8 +18,8 @@ trait InwardNodeImp[DI, UI, EI, BI <: Data] def bundleI(ei: EI): BI def colour: String def reverse: Boolean = false - def connect(bindings: () => Seq[(EI, BI, BI)])(implicit p: Parameters, sourceInfo: SourceInfo): (Option[LazyModule], () => Unit) = { - (None, () => bindings().foreach { case (_, i, o) => i <> o }) + def connect(edges: () => Seq[EI], bundles: () => Seq[(EI, BI, BI)])(implicit p: Parameters, sourceInfo: SourceInfo): (Option[LazyModule], () => Unit) = { + (None, () => bundles().foreach { case (_, i, o) => i <> o }) } // optional methods to track node graph @@ -244,7 +244,13 @@ abstract class MixedNode[DI, UI, EI, BI <: Data, DO, UO, EO, BO <: Data]( case BIND_STAR => BIND_QUERY case BIND_QUERY => BIND_STAR }) x.iPush(o, y, binding) - def bindings() = { + def edges() = { + val (iStart, iEnd) = x.iPortMapping(i) + val (oStart, oEnd) = y.oPortMapping(o) + require (iEnd - iStart == oEnd - oStart, s"Bug in diplomacy; ${iEnd-iStart} != ${oEnd-oStart} means port resolution failed") + Seq.tabulate(iEnd - iStart) { j => x.edgesIn(iStart+j) } + } + def bundles() = { val (iStart, iEnd) = x.iPortMapping(i) val (oStart, oEnd) = y.oPortMapping(o) require (iEnd - iStart == oEnd - oStart, s"Bug in diplomacy; ${iEnd-iStart} != ${oEnd-oStart} means port resolution failed") @@ -252,7 +258,7 @@ abstract class MixedNode[DI, UI, EI, BI <: Data, DO, UO, EO, BO <: Data]( (x.edgesIn(iStart+j), x.bundleIn(iStart+j), y.bundleOut(oStart+j)) } } - val (out, newbinding) = inner.connect(bindings _) + val (out, newbinding) = inner.connect(edges _, bundles _) LazyModule.stack.head.bindings = newbinding :: LazyModule.stack.head.bindings out } diff --git a/src/main/scala/uncore/tilelink2/Nodes.scala b/src/main/scala/uncore/tilelink2/Nodes.scala index 23b50e01..ff99906a 100644 --- a/src/main/scala/uncore/tilelink2/Nodes.scala +++ b/src/main/scala/uncore/tilelink2/Nodes.scala @@ -25,10 +25,10 @@ object TLImp extends NodeImp[TLClientPortParameters, TLManagerPortParameters, TL override def labelI(ei: TLEdgeIn) = (ei.manager.beatBytes * 8).toString override def labelO(eo: TLEdgeOut) = (eo.manager.beatBytes * 8).toString - override def connect(bindings: () => Seq[(TLEdgeIn, TLBundle, TLBundle)])(implicit p: Parameters, sourceInfo: SourceInfo): (Option[LazyModule], () => Unit) = { - val monitor = p(TLMonitorBuilder)(TLMonitorArgs(() => bindings().map(_._1), sourceInfo, p)) + override def connect(edges: () => Seq[TLEdgeIn], bundles: () => Seq[(TLEdgeIn, TLBundle, TLBundle)])(implicit p: Parameters, sourceInfo: SourceInfo): (Option[LazyModule], () => Unit) = { + val monitor = p(TLMonitorBuilder)(TLMonitorArgs(edges, sourceInfo, p)) (monitor, () => { - val eval = bindings () + val eval = bundles () monitor.foreach { m => (eval zip m.module.io.in) foreach { case ((_,i,o), m) => m := TLBundleSnoop(o,i) } } eval.foreach { case (_, bi, bo) => bi <> bo