From 11c1112661e04094bccfd805e737e0318eb91ebc Mon Sep 17 00:00:00 2001 From: Albert Magyar Date: Wed, 22 Nov 2017 17:51:51 -0800 Subject: Add auto clone implementation for inner Bundles (#722) --- chiselFrontend/src/main/scala/chisel3/core/Data.scala | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'chiselFrontend/src/main/scala/chisel3/core/Data.scala') diff --git a/chiselFrontend/src/main/scala/chisel3/core/Data.scala b/chiselFrontend/src/main/scala/chisel3/core/Data.scala index 19adf01b..d84a86e9 100644 --- a/chiselFrontend/src/main/scala/chisel3/core/Data.scala +++ b/chiselFrontend/src/main/scala/chisel3/core/Data.scala @@ -208,6 +208,13 @@ abstract class Data extends HasId { } } + // If this Data is an instance of an inner class, record enclosing class + // This is only used for cloneType! + private[core] var outerModule: Option[BaseModule] = + (Option(this.getClass.getEnclosingClass) zip Builder.currentModule) + .find({ case (c, m) => c.isAssignableFrom(m.getClass) }) + .map({ case (_, m) => m }) + // User-specified direction, local at this node only. // Note that the actual direction of this node can differ from child and parent specifiedDirection. private var _specifiedDirection: SpecifiedDirection = SpecifiedDirection.Unspecified -- cgit v1.2.3 From 43e4d6dbd0f131c7484dc24cb09ab3a25614cb62 Mon Sep 17 00:00:00 2001 From: Richard Lin Date: Fri, 22 Dec 2017 01:21:41 -0800 Subject: address review style comments --- chiselFrontend/src/main/scala/chisel3/core/Data.scala | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) (limited to 'chiselFrontend/src/main/scala/chisel3/core/Data.scala') diff --git a/chiselFrontend/src/main/scala/chisel3/core/Data.scala b/chiselFrontend/src/main/scala/chisel3/core/Data.scala index d84a86e9..35401fa1 100644 --- a/chiselFrontend/src/main/scala/chisel3/core/Data.scala +++ b/chiselFrontend/src/main/scala/chisel3/core/Data.scala @@ -209,11 +209,9 @@ abstract class Data extends HasId { } // If this Data is an instance of an inner class, record enclosing class - // This is only used for cloneType! - private[core] var outerModule: Option[BaseModule] = - (Option(this.getClass.getEnclosingClass) zip Builder.currentModule) - .find({ case (c, m) => c.isAssignableFrom(m.getClass) }) - .map({ case (_, m) => m }) + // This is only used for cloneType, and is mutable to allow autoCloneType to preserve the + // original outerModule. + private[core] var outerModule: Option[BaseModule] = Builder.currentModule // User-specified direction, local at this node only. // Note that the actual direction of this node can differ from child and parent specifiedDirection. -- cgit v1.2.3 From ade792ee7c5bb718f738f5e4c3886b2e87c68756 Mon Sep 17 00:00:00 2001 From: Jack Koenig Date: Thu, 28 Dec 2017 16:56:05 -0800 Subject: Add support for autoclonetype of bound, anonymous inner Bundles Also change Data.outerModule to Bundle._outerInst since it is only used in autoclonetype. _outerInst is also Option[Object] instead of Option[BaseModule] because the outer object could also be a Bundle. --- chiselFrontend/src/main/scala/chisel3/core/Data.scala | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) (limited to 'chiselFrontend/src/main/scala/chisel3/core/Data.scala') diff --git a/chiselFrontend/src/main/scala/chisel3/core/Data.scala b/chiselFrontend/src/main/scala/chisel3/core/Data.scala index 35401fa1..1cf50e9f 100644 --- a/chiselFrontend/src/main/scala/chisel3/core/Data.scala +++ b/chiselFrontend/src/main/scala/chisel3/core/Data.scala @@ -208,11 +208,6 @@ abstract class Data extends HasId { } } - // If this Data is an instance of an inner class, record enclosing class - // This is only used for cloneType, and is mutable to allow autoCloneType to preserve the - // original outerModule. - private[core] var outerModule: Option[BaseModule] = Builder.currentModule - // User-specified direction, local at this node only. // Note that the actual direction of this node can differ from child and parent specifiedDirection. private var _specifiedDirection: SpecifiedDirection = SpecifiedDirection.Unspecified @@ -245,6 +240,7 @@ abstract class Data extends HasId { // This information is supplemental (more than is necessary to generate FIRRTL) and is used to // perform checks in Chisel, where more informative error messages are possible. private var _binding: Option[Binding] = None + private[core] def bindingOpt = _binding private[core] def hasBinding = _binding.isDefined // Only valid after node is bound (synthesizable), crashes otherwise private[core] def binding = _binding.get -- cgit v1.2.3