summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--core/src/main/scala/chisel3/Module.scala13
-rw-r--r--core/src/main/scala/chisel3/experimental/hierarchy/Lookupable.scala2
2 files changed, 13 insertions, 2 deletions
diff --git a/core/src/main/scala/chisel3/Module.scala b/core/src/main/scala/chisel3/Module.scala
index 56dce4d5..1ae65969 100644
--- a/core/src/main/scala/chisel3/Module.scala
+++ b/core/src/main/scala/chisel3/Module.scala
@@ -193,7 +193,18 @@ package internal {
// Underlying object of which this is a clone of
val _proto: T
def getProto: T = _proto
- def isACloneOf(a: Any): Boolean = this == a || _proto == a
+
+ /** Determines whether another object is a clone of the same underlying proto
+ *
+ * @param a
+ */
+ def hasSameProto(a: Any): Boolean = {
+ val aProto = a match {
+ case x: IsClone[BaseModule] => x._proto
+ case o => o
+ }
+ this == aProto || _proto == aProto
+ }
}
// Private internal class to serve as a _parent for Data in cloned ports
diff --git a/core/src/main/scala/chisel3/experimental/hierarchy/Lookupable.scala b/core/src/main/scala/chisel3/experimental/hierarchy/Lookupable.scala
index b9617723..2242c1c4 100644
--- a/core/src/main/scala/chisel3/experimental/hierarchy/Lookupable.scala
+++ b/core/src/main/scala/chisel3/experimental/hierarchy/Lookupable.scala
@@ -217,7 +217,7 @@ private[chisel3] object Lookupable {
}
(m, context) match {
case (c, ctx) if ctx == c => Left(c)
- case (c, ctx: IsClone[_]) if ctx.isACloneOf(c) => Right(ctx.asInstanceOf[IsClone[A]])
+ case (c, ctx: IsClone[_]) if ctx.hasSameProto(c) => Right(ctx.asInstanceOf[IsClone[A]])
case (c, ctx) if c._parent.isEmpty => Left(c)
case (_, _) =>
cloneModuleToContext(Left(m._parent.get), context) match {