Skip to content

Commit

Permalink
fix: fix while loop in ReverseImpl (#4525)
Browse files Browse the repository at this point in the history
  • Loading branch information
unlsycn authored Nov 24, 2024
1 parent ef022f5 commit 31d6768
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions src/main/scala/chisel3/util/BitwiseImpl.scala
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,12 @@ private[chisel3] trait ReverseImpl {
var res = in
var shift = length >> 1
var mask = ((BigInt(1) << length) - 1).asUInt(length.W)
var initial = true
while (initial || shift > 0) {
initial = false
while ({
mask = mask ^ (mask(length - shift - 1, 0) << shift)
res = ((res >> shift) & mask) | ((res(length - shift - 1, 0) << shift) & !mask)
res = ((res >> shift) & mask) | ((res(length - shift - 1, 0) << shift) & ~mask)
shift = shift >> 1
}
shift > 0
}) {}
res
case _ =>
val half = (1 << log2Ceil(length)) / 2
Expand Down

0 comments on commit 31d6768

Please sign in to comment.