summaryrefslogtreecommitdiff
path: root/src/main/scala/chisel3/util/OneHot.scala
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/scala/chisel3/util/OneHot.scala')
-rw-r--r--src/main/scala/chisel3/util/OneHot.scala10
1 files changed, 5 insertions, 5 deletions
diff --git a/src/main/scala/chisel3/util/OneHot.scala b/src/main/scala/chisel3/util/OneHot.scala
index 53ba8c3d..7dd0c68b 100644
--- a/src/main/scala/chisel3/util/OneHot.scala
+++ b/src/main/scala/chisel3/util/OneHot.scala
@@ -35,7 +35,7 @@ object OHToUInt {
* Multiple bits may be high in the input.
*/
object PriorityEncoder {
- def apply(in: Seq[Bool]): UInt = PriorityMux(in, (0 until in.size).map(UInt(_)))
+ def apply(in: Seq[Bool]): UInt = PriorityMux(in, (0 until in.size).map(_.asUInt))
def apply(in: Bits): UInt = apply(in.toBools)
}
@@ -44,9 +44,9 @@ object PriorityEncoder {
object UIntToOH {
def apply(in: UInt, width: Int = -1): UInt =
if (width == -1) {
- UInt(1) << in
+ 1.U << in
} else {
- (UInt(1) << in(log2Up(width)-1,0))(width-1,0)
+ (1.U << in(log2Up(width)-1,0))(width-1,0)
}
}
@@ -55,8 +55,8 @@ object UIntToOH {
*/
object PriorityEncoderOH {
private def encode(in: Seq[Bool]): UInt = {
- val outs = Seq.tabulate(in.size)(i => UInt(BigInt(1) << i, in.size))
- PriorityMux(in :+ Bool(true), outs :+ UInt(0, in.size))
+ val outs = Seq.tabulate(in.size)(i => (BigInt(1) << i).asUInt(in.size.W))
+ PriorityMux(in :+ true.B, outs :+ 0.U(in.size.W))
}
def apply(in: Seq[Bool]): Seq[Bool] = {
val enc = encode(in)