diff options
| author | Chick Markley | 2017-04-12 20:55:37 -0700 |
|---|---|---|
| committer | GitHub | 2017-04-12 20:55:37 -0700 |
| commit | 97902cdc53eec52aa0cd806b8cb49a0e3f2fb769 (patch) | |
| tree | 97911b991c1aa2bb80cb50335777165cb9871a31 /chiselFrontend/src/main/scala/chisel3/core/Data.scala | |
| parent | db6a727485153cbb92989be2f5d67e059e0878ad (diff) | |
Fix one hot mux (#573)
* still trying to find right mix
* Making some progress on Mux1H
* Mux1H that works in non-optimzed fashion for FixedPoint, works pretty well in general
Catches some additional problem edge cases
Some tests that illustrate most of this
* Moved in Angie's code for handling FixedPoint case
Cleaned up tests considerably, per @ducky64 review
* Just a bit more cleanup
Diffstat (limited to 'chiselFrontend/src/main/scala/chisel3/core/Data.scala')
| -rw-r--r-- | chiselFrontend/src/main/scala/chisel3/core/Data.scala | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/chiselFrontend/src/main/scala/chisel3/core/Data.scala b/chiselFrontend/src/main/scala/chisel3/core/Data.scala index c9cfe27b..556f2aeb 100644 --- a/chiselFrontend/src/main/scala/chisel3/core/Data.scala +++ b/chiselFrontend/src/main/scala/chisel3/core/Data.scala @@ -35,9 +35,10 @@ object DataMirror { * - For other types of the same class are are the same: clone of any of the elements * - Otherwise: fail */ +//scalastyle:off cyclomatic.complexity private[core] object cloneSupertype { def apply[T <: Data](elts: Seq[T], createdType: String)(implicit sourceInfo: SourceInfo, - compileOptions: CompileOptions): T = { + compileOptions: CompileOptions): T = { require(!elts.isEmpty, s"can't create $createdType with no inputs") if (elts forall {_.isInstanceOf[Bits]}) { @@ -45,7 +46,9 @@ private[core] object cloneSupertype { case (elt1: Bool, elt2: Bool) => elt1 case (elt1: Bool, elt2: UInt) => elt2 // TODO: what happens with zero width UInts? case (elt1: UInt, elt2: Bool) => elt1 // TODO: what happens with zero width UInts? - case (elt1: UInt, elt2: UInt) => if (elt1.width == (elt1.width max elt2.width)) elt1 else elt2 // TODO: perhaps redefine Widths to allow >= op? + case (elt1: UInt, elt2: UInt) => + // TODO: perhaps redefine Widths to allow >= op? + if (elt1.width == (elt1.width max elt2.width)) elt1 else elt2 case (elt1: SInt, elt2: SInt) => if (elt1.width == (elt1.width max elt2.width)) elt1 else elt2 case (elt1: FixedPoint, elt2: FixedPoint) => { (elt1.binaryPoint, elt2.binaryPoint, elt1.width, elt2.width) match { @@ -59,13 +62,17 @@ private[core] object cloneSupertype { } } case (elt1, elt2) => - throw new AssertionError(s"can't create $createdType with heterogeneous Bits types ${elt1.getClass} and ${elt2.getClass}") + throw new AssertionError( + s"can't create $createdType with heterogeneous Bits types ${elt1.getClass} and ${elt2.getClass}") }).asInstanceOf[T] } model.chiselCloneType - } else { + } + else { for (elt <- elts.tail) { - require(elt.getClass == elts.head.getClass, s"can't create $createdType with heterogeneous types ${elts.head.getClass} and ${elt.getClass}") - require(elt typeEquivalent elts.head, s"can't create $createdType with non-equivalent types ${elts.head} and ${elt}") + require(elt.getClass == elts.head.getClass, + s"can't create $createdType with heterogeneous types ${elts.head.getClass} and ${elt.getClass}") + require(elt typeEquivalent elts.head, + s"can't create $createdType with non-equivalent types ${elts.head} and ${elt}") } elts.head.chiselCloneType } |
