Skip to content

Commit

Permalink
Util: Concatenate the input and 1 as the new input in priorityEncode …
Browse files Browse the repository at this point in the history
…to solve the input is all 0
  • Loading branch information
sinceforYy committed May 24, 2024
1 parent 86353a7 commit 74983f8
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/main/scala/yunsuan/vector/VectorConvert/util/CLZ.scala
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@ import chisel3.util._
class CLZ(len: Int, zero: Boolean) extends Module {

val inWidth = len
val outWidth = (inWidth - 1).U.getWidth
val outWidth = inWidth.U.getWidth

val io = IO(new Bundle() {
val in = Input(UInt(inWidth.W))
val out = Output(UInt(outWidth.W))
})

io.out := PriorityEncoder(io.in.asBools.reverse)
io.out := PriorityEncoder(Cat(io.in, 1.U).asBools.reverse)
}

object CLZ {
Expand Down

0 comments on commit 74983f8

Please sign in to comment.