diff options
| author | Jim Lawson | 2016-08-19 14:46:53 -0700 |
|---|---|---|
| committer | Jim Lawson | 2016-08-19 14:46:53 -0700 |
| commit | 525e5688f69f474240fe5a21d6210beb04cfef29 (patch) | |
| tree | c851d6d2f7157f9f02a1a17637d7cdd348fee7d1 /chiselFrontend | |
| parent | 119e6c7bb9096bbd163a439de09d4932303d0140 (diff) | |
Restore immutability of direction overrides.
Input, Output, and Flipped clone their inputs.
Diffstat (limited to 'chiselFrontend')
| -rw-r--r-- | chiselFrontend/src/main/scala/chisel3/core/Data.scala | 15 |
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 ") } } |
