From 2092cb4ec81cc567aba1ea33cb97e0239a275570 Mon Sep 17 00:00:00 2001 From: "Wesley W. Terpstra" Date: Wed, 8 Nov 2017 15:32:45 -0800 Subject: [PATCH] diplomacy: reprotect Node bundles after module construction is completed --- src/main/scala/diplomacy/LazyModule.scala | 8 +++++++- src/main/scala/diplomacy/Nodes.scala | 5 +++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/src/main/scala/diplomacy/LazyModule.scala b/src/main/scala/diplomacy/LazyModule.scala index 4f56dc6f..fe0955e8 100644 --- a/src/main/scala/diplomacy/LazyModule.scala +++ b/src/main/scala/diplomacy/LazyModule.scala @@ -165,7 +165,9 @@ sealed trait LazyModuleImpLike extends BaseModule protected[diplomacy] def instantiate() = { val childDangles = wrapper.children.reverse.flatMap { c => implicit val sourceInfo = c.info - Module(c.module).dangles + val mod = Module(c.module) + mod.finishInstantiate() + mod.dangles } wrapper.instantiate() val nodeDangles = wrapper.nodes.reverse.flatMap(_.instantiate()) @@ -184,6 +186,10 @@ sealed trait LazyModuleImpLike extends BaseModule } (auto, dangles) } + + protected[diplomacy] def finishInstantiate() { + wrapper.nodes.reverse.foreach { _.finishInstantiate() } + } } class LazyModuleImp(val wrapper: LazyModule) extends MultiIOModule with LazyModuleImpLike { diff --git a/src/main/scala/diplomacy/Nodes.scala b/src/main/scala/diplomacy/Nodes.scala index 94db342a..fb017814 100644 --- a/src/main/scala/diplomacy/Nodes.scala +++ b/src/main/scala/diplomacy/Nodes.scala @@ -93,6 +93,7 @@ abstract class BaseNode(implicit val valName: ValName) val serial = BaseNode.serial BaseNode.serial = BaseNode.serial + 1 protected[diplomacy] def instantiate(): Seq[Dangle] + protected[diplomacy] def finishInstantiate(): Unit def name = lazyModule.name + "." + valName.name def omitGraphML = outputs.isEmpty && inputs.isEmpty @@ -387,6 +388,10 @@ sealed abstract class MixedNode[DI, UI, EI, BI <: Data, DO, UO, EO, BO <: Data]( danglesOut ++ danglesIn } + protected[diplomacy] def finishInstantiate() = { + bundlesSafeNow = false + } + // connects the outward part of a node with the inward part of this node protected[diplomacy] def bind(h: OutwardNode[DI, UI, BI], binding: NodeBinding)(implicit p: Parameters, sourceInfo: SourceInfo) { val x = this // x := y