diff --git a/build.sbt b/build.sbt index b72a4b6e918..4a107b61ac1 100644 --- a/build.sbt +++ b/build.sbt @@ -394,7 +394,9 @@ lazy val unipublish = ProblemFilters.exclude[DirectMissingMethodProblem]("chisel3.*.hasAutoSeed"), // _circuit was package private ProblemFilters.exclude[DirectMissingMethodProblem]("chisel3.*._circuit"), - ProblemFilters.exclude[DirectMissingMethodProblem]("chisel3.*._circuit_=") + ProblemFilters.exclude[DirectMissingMethodProblem]("chisel3.*._circuit_="), + // setRef was package private + ProblemFilters.exclude[IncompatibleMethTypeProblem]("chisel3.*.setRef") ), // Forward doc command to unidoc Compile / doc := (ScalaUnidoc / doc).value, diff --git a/core/src/main/scala/chisel3/Aggregate.scala b/core/src/main/scala/chisel3/Aggregate.scala index bf5659c6620..9e6282c95c2 100644 --- a/core/src/main/scala/chisel3/Aggregate.scala +++ b/core/src/main/scala/chisel3/Aggregate.scala @@ -230,8 +230,9 @@ sealed class Vec[T <: Data] private[chisel3] (gen: => T, val length: Int) extend // simpler. private lazy val self: Seq[T] = { val _self = Vector.fill(length)(gen) + val thisNode = Node(this) // Share the same Node for all elements. for ((elt, i) <- _self.zipWithIndex) - elt.setRef(this, i) + elt.setRef(thisNode, i) _self } @@ -382,7 +383,7 @@ sealed class Vec[T <: Data] private[chisel3] (gen: => T, val length: Int) extend port.bind(ChildBinding(this), reconstructedResolvedDirection) val i = Vec.truncateIndex(p, length)(UnlocatableSourceInfo) - port.setRef(this, i) + port.setRef(Node(this), i) port } @@ -992,9 +993,10 @@ abstract class Record extends Aggregate { !opaqueType || (_elements.size == 1 && _elements.head._1 == ""), s"Opaque types must have exactly one element with an empty name, not ${_elements.size}: ${elements.keys.mkString(", ")}" ) + val thisNode = Node(this) // Share the same Node for all elements. // Names of _elements have already been namespaced (and therefore sanitized) for ((name, elt) <- _elements) { - elt.setRef(this, name, opaque = opaqueType) + elt.setRef(thisNode, name, opaque = opaqueType) } } diff --git a/core/src/main/scala/chisel3/internal/Builder.scala b/core/src/main/scala/chisel3/internal/Builder.scala index f36a40905b3..7c71e486ab0 100644 --- a/core/src/main/scala/chisel3/internal/Builder.scala +++ b/core/src/main/scala/chisel3/internal/Builder.scala @@ -259,13 +259,13 @@ private[chisel3] trait HasId extends chisel3.InstanceId { _refVar = imm } } - private[chisel3] def setRef(parent: HasId, name: String, opaque: Boolean = false): Unit = { - if (!opaque) setRef(Slot(Node(parent), name)) - else setRef(OpaqueSlot(Node(parent))) + private[chisel3] def setRef(parent: Node, name: String, opaque: Boolean = false): Unit = { + if (!opaque) setRef(Slot(parent, name)) + else setRef(OpaqueSlot(parent)) } - private[chisel3] def setRef(parent: HasId, index: Int): Unit = setRef(Index(Node(parent), ILit(index))) - private[chisel3] def setRef(parent: HasId, index: UInt): Unit = setRef(Index(Node(parent), index.ref)) + private[chisel3] def setRef(parent: Node, index: Int): Unit = setRef(Index(parent, ILit(index))) + private[chisel3] def setRef(parent: Node, index: UInt): Unit = setRef(Index(parent, index.ref)) private[chisel3] def getRef: Arg = _ref.get private[chisel3] def getOptionRef: Option[Arg] = _ref diff --git a/core/src/main/scala/chisel3/properties/Object.scala b/core/src/main/scala/chisel3/properties/Object.scala index 853fc5acdb2..7472f1dd4ff 100644 --- a/core/src/main/scala/chisel3/properties/Object.scala +++ b/core/src/main/scala/chisel3/properties/Object.scala @@ -6,7 +6,7 @@ import scala.language.experimental.macros import chisel3.{Module, RawModule, SpecifiedDirection} import chisel3.experimental.{BaseModule, SourceInfo} -import chisel3.internal.firrtl.ir.{DefClass, DefObject} +import chisel3.internal.firrtl.ir.{DefClass, DefObject, Node} import chisel3.internal.sourceinfo.InstTransform import chisel3.internal.{throwException, Builder, HasId, NamedComponent, ObjectFieldBinding} @@ -65,14 +65,14 @@ class DynamicObject private[chisel3] (val className: ClassType) extends HasId wi */ def getField[T](name: String)(implicit tpe: PropertyType[T]): Property[tpe.Type] = { val field = Property[T]() - field.setRef(this, name) + field.setRef(Node(this), name) field.bind(ObjectFieldBinding(_parent.get), SpecifiedDirection.Unspecified) field } def getField[T](name: String, property: Property[T]): Property[T] = { val field = property.cloneType - field.setRef(this, name) + field.setRef(Node(this), name) field.bind(ObjectFieldBinding(_parent.get), SpecifiedDirection.Unspecified) field }