From 870ed3d219b48ea50b490325e4af9711c8ab35c9 Mon Sep 17 00:00:00 2001 From: "Wesley W. Terpstra" Date: Mon, 25 Sep 2017 18:09:03 -0700 Subject: [PATCH] diplomacy: fix the order of auto signals --- src/main/scala/diplomacy/LazyModule.scala | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/main/scala/diplomacy/LazyModule.scala b/src/main/scala/diplomacy/LazyModule.scala index ab22641f..2337e95a 100644 --- a/src/main/scala/diplomacy/LazyModule.scala +++ b/src/main/scala/diplomacy/LazyModule.scala @@ -154,12 +154,13 @@ sealed trait LazyModuleImpLike extends BaseModule Module(c.module).dangles } val nodeDangles = wrapper.nodes.reverse.flatMap(_.instantiate()) - val (toConnect, toForward) = (nodeDangles ++ childDangles).groupBy(_.source).partition(_._2.size == 2) - val forward = toForward.map(_._2(0)).toList - toConnect.foreach { case (_, Seq(a, b)) => + val allDangles = nodeDangles ++ childDangles + val done = Set() ++ allDangles.groupBy(_.source).values.filter(_.size == 2).map { case Seq(a, b) => require (a.flipped != b.flipped) if (a.flipped) { a.data <> b.data } else { b.data <> a.data } + a.source } + val forward = allDangles.filter(d => !done(d.source)) val auto = IO(new AutoBundle(forward.map { d => (d.name, d.data, d.flipped) }:_*)) val dangles = (forward zip auto.elements) map { case (d, (_, io)) => if (d.flipped) { d.data <> io } else { io <> d.data }