summaryrefslogtreecommitdiff
path: root/src/main/scala/chisel3/util/OneHot.scala
diff options
context:
space:
mode:
authorducky2016-11-17 13:01:03 -0800
committerducky2016-11-21 13:31:12 -0800
commit54d3f8dc054e55dfbd01d1aa034169a3dabe89f2 (patch)
tree7f6f9de04de6eb08878ac46be339fefc2a71395f /src/main/scala/chisel3/util/OneHot.scala
parentcd904da0aa0e96ba679906a3ee5dbdc068eace48 (diff)
Restyle a lot of test code, mainly with regex
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)