summaryrefslogtreecommitdiff
path: root/chiselFrontend
diff options
context:
space:
mode:
Diffstat (limited to 'chiselFrontend')
-rw-r--r--chiselFrontend/src/main/scala/chisel3/core/Data.scala15
1 files changed, 8 insertions, 7 deletions
diff --git a/chiselFrontend/src/main/scala/chisel3/core/Data.scala b/chiselFrontend/src/main/scala/chisel3/core/Data.scala
index cb6d427d..ce7b58b4 100644
--- a/chiselFrontend/src/main/scala/chisel3/core/Data.scala
+++ b/chiselFrontend/src/main/scala/chisel3/core/Data.scala
@@ -31,27 +31,28 @@ object DataMirror {
/**
* Input, Output, and Flipped are used to define the directions of Module IOs.
*
-* Note that they do not currently call target to be a newType or cloneType.
-* This is nominally for performance reasons to avoid too many extra copies when
-* something is flipped multiple times.
+* Note that they currently clone their source argument, including its bindings.
*
* Thus, an error will be thrown if these are used on bound Data
*/
object Input {
- def apply[T<:Data](target: T): T = {
+ def apply[T<:Data](source: T): 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](target: T): T = {
+ def apply[T<:Data](source: T): 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](target: T): T = {
- Data.setFirrtlDirection(target, Data.getFirrtlDirection(target).flip)
+ def apply[T<:Data](source: T): T = {
+ val target = source.chiselCloneType
+ Data.setFirrtlDirection(target, Data.getFirrtlDirection(source).flip)
Binding.bind(target, FlippedBinder, "Error: Cannot flip ")
}
}