diff options
| author | ducky | 2016-05-05 11:50:39 -0700 |
|---|---|---|
| committer | ducky | 2016-05-05 11:50:39 -0700 |
| commit | 9036d96bb032c19de31131f2296120e708cbc3dc (patch) | |
| tree | cf17173fab309b09670ca7529680e09d61341451 /src/main/scala/Chisel/SeqUtils.scala | |
| parent | 623a301df1f5a1954f8e4a64ef97c99c3900da28 (diff) | |
Move Chisel API into separate chiselFrontend compilation unit in preparation for source locator macros
Diffstat (limited to 'src/main/scala/Chisel/SeqUtils.scala')
| -rw-r--r-- | src/main/scala/Chisel/SeqUtils.scala | 47 |
1 files changed, 0 insertions, 47 deletions
diff --git a/src/main/scala/Chisel/SeqUtils.scala b/src/main/scala/Chisel/SeqUtils.scala deleted file mode 100644 index c63f5735..00000000 --- a/src/main/scala/Chisel/SeqUtils.scala +++ /dev/null @@ -1,47 +0,0 @@ -// See LICENSE for license details. - -package Chisel - -private[Chisel] object SeqUtils { - /** Equivalent to Cat(r(n-1), ..., r(0)) */ - def asUInt[T <: Bits](in: Seq[T]): UInt = { - if (in.tail.isEmpty) { - in.head.asUInt - } else { - val left = asUInt(in.slice(0, in.length/2)) - val right = asUInt(in.slice(in.length/2, in.length)) - right ## left - } - } - - /** Counts the number of true Bools in a Seq */ - def count(in: Seq[Bool]): UInt = { - if (in.size == 0) { - UInt(0) - } else if (in.size == 1) { - in.head - } else { - count(in.slice(0, in.size/2)) + (UInt(0) ## count(in.slice(in.size/2, in.size))) - } - } - - /** Returns data value corresponding to first true predicate */ - def priorityMux[T <: Bits](in: Seq[(Bool, T)]): T = { - if (in.size == 1) { - in.head._2 - } else { - Mux(in.head._1, in.head._2, priorityMux(in.tail)) - } - } - - /** Returns data value corresponding to lone true predicate */ - def oneHotMux[T <: Data](in: Iterable[(Bool, T)]): T = { - if (in.tail.isEmpty) { - in.head._2 - } else { - val masked = for ((s, i) <- in) yield Mux(s, i.toBits, Bits(0)) - val width = in.map(_._2.width).reduce(_ max _) - in.head._2.cloneTypeWidth(width).fromBits(masked.reduceLeft(_|_)) - } - } -} |
