diff options
| author | Andrew Waterman | 2015-08-04 00:27:43 -0700 |
|---|---|---|
| committer | Andrew Waterman | 2015-08-04 04:52:27 -0700 |
| commit | 13bf0218e7e9fe3fb336a9fe5cd18d7e262e4a03 (patch) | |
| tree | d2ab832cb96dc79f05f8a1a681cb80a298dac939 /src/main/scala/Chisel/utils.scala | |
| parent | 28d2d5a7f9c01273eac866a42b230664c3169a3b (diff) | |
Add better cloneTypeWidth and deprecate old one
Diffstat (limited to 'src/main/scala/Chisel/utils.scala')
| -rw-r--r-- | src/main/scala/Chisel/utils.scala | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/src/main/scala/Chisel/utils.scala b/src/main/scala/Chisel/utils.scala index b0255ef9..b1e6eb20 100644 --- a/src/main/scala/Chisel/utils.scala +++ b/src/main/scala/Chisel/utils.scala @@ -94,7 +94,10 @@ object Mux1H if (in.tail.isEmpty) in.head._2 else { val masked = in map {case (s, i) => Mux(s, i.toBits, Bits(0))} - in.head._2.fromBits(masked.reduceLeft(_|_)) + val width = + if (in.forall(_._2.knownWidth)) Some(in.map(_._2.getWidth).max) + else None + in.head._2.cloneTypeWidth(width).fromBits(masked.reduceLeft(_|_)) } } def apply[T <: Data](sel: UInt, in: Seq[T]): T = |
