summaryrefslogtreecommitdiff
path: root/chiselFrontend/src/main/scala/chisel3/core/Data.scala
diff options
context:
space:
mode:
authorJim Lawson2016-10-24 10:31:26 -0700
committerJim Lawson2016-10-24 10:31:26 -0700
commitb0b5fd3140186651eb558bd6f4ca51c618deacc9 (patch)
tree1393bbb14303af86aeb5e5ed0375f302864b8307 /chiselFrontend/src/main/scala/chisel3/core/Data.scala
parent82625071405672eb4a19363d6f73f359ac28a7f5 (diff)
parent5df30b390ae5817c4793c6d4e0c5466d96d241f1 (diff)
Merge branch 'master' into tobits-deprecation
Diffstat (limited to 'chiselFrontend/src/main/scala/chisel3/core/Data.scala')
-rw-r--r--chiselFrontend/src/main/scala/chisel3/core/Data.scala13
1 files changed, 13 insertions, 0 deletions
diff --git a/chiselFrontend/src/main/scala/chisel3/core/Data.scala b/chiselFrontend/src/main/scala/chisel3/core/Data.scala
index 0e473e7e..86858e5d 100644
--- a/chiselFrontend/src/main/scala/chisel3/core/Data.scala
+++ b/chiselFrontend/src/main/scala/chisel3/core/Data.scala
@@ -173,7 +173,19 @@ abstract class Data extends HasId {
private[core] def width: Width
private[core] def legacyConnect(that: Data)(implicit sourceInfo: SourceInfo): Unit
+ /** cloneType must be defined for any Chisel object extending Data.
+ * It is responsible for constructing a basic copy of the object being cloned.
+ * If cloneType needs to recursively clone elements of an object, it should call
+ * the cloneType methods on those elements.
+ * @return a copy of the object.
+ */
def cloneType: this.type
+
+ /** chiselCloneType is called at the top-level of a clone chain.
+ * It calls the client's cloneType() method to construct a basic copy of the object being cloned,
+ * then performs any fixups required to reconstruct the appropriate core state of the cloned object.
+ * @return a copy of the object with appropriate core state.
+ */
def chiselCloneType: this.type = {
// Call the user-supplied cloneType method
val clone = this.cloneType
@@ -181,6 +193,7 @@ abstract class Data extends HasId {
//TODO(twigg): Do recursively for better error messages
for((clone_elem, source_elem) <- clone.allElements zip this.allElements) {
clone_elem.binding = UnboundBinding(source_elem.binding.direction)
+ Data.setFirrtlDirection(clone_elem, Data.getFirrtlDirection(source_elem))
}
clone
}