summaryrefslogtreecommitdiff
path: root/src/main/scala/chisel3/util/OneHot.scala
diff options
context:
space:
mode:
authorJack2022-01-12 04:27:19 +0000
committerJack2022-01-12 04:27:19 +0000
commit29df513e348cc809876893f650af8180f0190496 (patch)
tree06daaea954b4e5af7113f06e4bdbb78b33515cb3 /src/main/scala/chisel3/util/OneHot.scala
parent5242ce90659decb9058ee75db56e5c188029fbf9 (diff)
parent747d16311bdf185d2e98e452b14cb5d8ccca004c (diff)
Merge branch 'master' into 3.5-release
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