summaryrefslogtreecommitdiff
path: root/core/src/main/scala
diff options
context:
space:
mode:
Diffstat (limited to 'core/src/main/scala')
-rw-r--r--core/src/main/scala/chisel3/Aggregate.scala32
1 files changed, 22 insertions, 10 deletions
diff --git a/core/src/main/scala/chisel3/Aggregate.scala b/core/src/main/scala/chisel3/Aggregate.scala
index 042e78b1..aacf0b1c 100644
--- a/core/src/main/scala/chisel3/Aggregate.scala
+++ b/core/src/main/scala/chisel3/Aggregate.scala
@@ -1158,6 +1158,16 @@ abstract class Record(private[chisel3] implicit val compileOptions: CompileOptio
* Results in "`\$className(elt0.name -> elt0.value, ...)`"
*/
def toPrintable: Printable = toPrintableHelper(elements.toList)
+
+ /** Implementation of cloneType that is [optionally for Record] overridden by the compiler plugin
+ *
+ * @note This should _never_ be overridden or called in user-code
+ */
+ protected def _cloneTypeImpl: Record = {
+ throwException(
+ s"Internal Error! This should have been implemented by the chisel3-plugin. Please file an issue against chisel3"
+ )
+ }
}
/**
@@ -1182,6 +1192,15 @@ package experimental {
class BundleLiteralException(message: String) extends ChiselException(message)
class VecLiteralException(message: String) extends ChiselException(message)
+ /** Indicates that the compiler plugin should generate [[cloneType]] for this type
+ *
+ * All user-defined [[Record]]s should mix this trait in as it will be required for upgrading to Chisel 3.6.
+ */
+ trait AutoCloneType { self: Record =>
+
+ override def cloneType: this.type = _cloneTypeImpl.asInstanceOf[this.type]
+
+ }
}
/** Base class for data types defined as a bundle of other data types.
@@ -1217,7 +1236,7 @@ package experimental {
* }
* }}}
*/
-abstract class Bundle(implicit compileOptions: CompileOptions) extends Record {
+abstract class Bundle(implicit compileOptions: CompileOptions) extends Record with experimental.AutoCloneType {
assert(
_usingPlugin,
"The Chisel compiler plugin is now required for compiling Chisel code. " +
@@ -1385,15 +1404,8 @@ abstract class Bundle(implicit compileOptions: CompileOptions) extends Record {
clone
}
- /** Implementation of cloneType using runtime reflection. This should _never_ be overridden or called in user-code
- *
- * @note This is overridden by the compiler plugin (this implementation is never called)
- */
- protected def _cloneTypeImpl: Bundle = {
- throwException(
- s"Internal Error! This should have been implemented by the chisel3-plugin. Please file an issue against chisel3"
- )
- }
+ // This is overriden for binary compatibility reasons in 3.5
+ override protected def _cloneTypeImpl: Bundle = super._cloneTypeImpl.asInstanceOf[Bundle]
/** Default "pretty-print" implementation
* Analogous to printing a Map