summaryrefslogtreecommitdiff
path: root/chiselFrontend/src/main/scala/chisel3/core/Data.scala
diff options
context:
space:
mode:
authorAndrew Waterman2016-10-27 12:40:16 -0700
committerJack Koenig2016-10-28 00:35:04 -0700
commit09282f32bec847bcd0b652f778f42be13c7d027e (patch)
tree63065f44a5b0b57d579e893c89e72d5ea082c5a5 /chiselFrontend/src/main/scala/chisel3/core/Data.scala
parent4d684398a1774a8b6a7a86e9d2dd92a165e02cfe (diff)
Preserve legacy cloneType behavior in compatibility mode
f1507aa7cec86ca8f5de13ddc96fd046370dfe1d triggers a rocket-chip regression, because Chisel used to not preserve flippedness on cloneType.
Diffstat (limited to 'chiselFrontend/src/main/scala/chisel3/core/Data.scala')
-rw-r--r--chiselFrontend/src/main/scala/chisel3/core/Data.scala22
1 files changed, 13 insertions, 9 deletions
diff --git a/chiselFrontend/src/main/scala/chisel3/core/Data.scala b/chiselFrontend/src/main/scala/chisel3/core/Data.scala
index 86858e5d..2d3bfa2b 100644
--- a/chiselFrontend/src/main/scala/chisel3/core/Data.scala
+++ b/chiselFrontend/src/main/scala/chisel3/core/Data.scala
@@ -37,21 +37,21 @@ object DataMirror {
* Thus, an error will be thrown if these are used on bound Data
*/
object Input {
- def apply[T<:Data](source: T): T = {
+ def apply[T<:Data](source: T)(implicit compileOptions: CompileOptions): T = {
val target = source.chiselCloneType
Data.setFirrtlDirection(target, Direction.Input)
Binding.bind(target, InputBinder, "Error: Cannot set as input ")
}
}
object Output {
- def apply[T<:Data](source: T): T = {
+ def apply[T<:Data](source: T)(implicit compileOptions: CompileOptions): T = {
val target = source.chiselCloneType
Data.setFirrtlDirection(target, Direction.Output)
Binding.bind(target, OutputBinder, "Error: Cannot set as output ")
}
}
object Flipped {
- def apply[T<:Data](source: T): T = {
+ def apply[T<:Data](source: T)(implicit compileOptions: CompileOptions): T = {
val target = source.chiselCloneType
Data.setFirrtlDirection(target, Data.getFirrtlDirection(source).flip)
Binding.bind(target, FlippedBinder, "Error: Cannot flip ")
@@ -186,14 +186,18 @@ abstract class Data extends HasId {
* 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 = {
+ def chiselCloneType(implicit compileOptions: CompileOptions): this.type = {
// Call the user-supplied cloneType method
val clone = this.cloneType
- Data.setFirrtlDirection(clone, Data.getFirrtlDirection(this))
- //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))
+ // In compatibility mode, simply return cloneType; otherwise, propagate
+ // direction and flippedness.
+ if (compileOptions.checkSynthesizable) {
+ Data.setFirrtlDirection(clone, Data.getFirrtlDirection(this))
+ //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
}