summaryrefslogtreecommitdiff
path: root/src/main/scala/chisel3/util/OneHot.scala
diff options
context:
space:
mode:
authorJack Koenig2022-01-10 10:39:52 -0800
committerJack Koenig2022-01-10 15:53:55 -0800
commit3131c0daad41dea78bede4517669e376c41a325a (patch)
tree55baed78a6a01f80ff3952a08233ca553a19964f /src/main/scala/chisel3/util/OneHot.scala
parentdd36f97a82746cec0b25b94651581fe799e24579 (diff)
Apply scalafmt
Command: sbt scalafmtAll
Diffstat (limited to 'src/main/scala/chisel3/util/OneHot.scala')
-rw-r--r--src/main/scala/chisel3/util/OneHot.scala11
1 files changed, 5 insertions, 6 deletions
diff --git a/src/main/scala/chisel3/util/OneHot.scala b/src/main/scala/chisel3/util/OneHot.scala
index 03f470c7..23b350e5 100644
--- a/src/main/scala/chisel3/util/OneHot.scala
+++ b/src/main/scala/chisel3/util/OneHot.scala
@@ -20,15 +20,15 @@ import chisel3._
object OHToUInt {
def apply(in: Seq[Bool]): UInt = apply(Cat(in.reverse), in.size)
def apply(in: Vec[Bool]): UInt = apply(in.asUInt, in.size)
- def apply(in: Bits): UInt = apply(in, in.getWidth)
+ def apply(in: Bits): UInt = apply(in, in.getWidth)
def apply(in: Bits, width: Int): UInt = {
if (width <= 2) {
Log2(in, width)
} else {
- val mid = 1 << (log2Ceil(width)-1)
- val hi = in(width-1, mid)
- val lo = in(mid-1, 0)
+ val mid = 1 << (log2Ceil(width) - 1)
+ val hi = in(width - 1, mid)
+ val lo = in(mid - 1, 0)
Cat(hi.orR, apply(hi | lo, mid))
}
}
@@ -44,7 +44,7 @@ object OHToUInt {
*/
object PriorityEncoder {
def apply(in: Seq[Bool]): UInt = PriorityMux(in, (0 until in.size).map(_.asUInt))
- def apply(in: Bits): UInt = apply(in.asBools)
+ def apply(in: Bits): UInt = apply(in.asBools)
}
/** Returns the one hot encoding of the input UInt.
@@ -52,7 +52,6 @@ object PriorityEncoder {
* @example {{{
* UIntToOH(2.U) // results in "b0100".U
* }}}
- *
*/
object UIntToOH {
def apply(in: UInt): UInt = 1.U << in