diff options
| author | Andrew Waterman | 2019-03-14 02:04:34 -0700 |
|---|---|---|
| committer | Edward Wang | 2019-03-15 11:49:17 -0700 |
| commit | 52168a5f3edee6c427a2bf4e1fd033259b46ac9e (patch) | |
| tree | 3b75834905c3930494ed4a0174da168c4cda08af | |
| parent | 6c39009771d3c9169f66e8a65b5d8f996d5c6e1f (diff) | |
Fix PopCount width
| -rw-r--r-- | chiselFrontend/src/main/scala/chisel3/core/SeqUtils.scala | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/chiselFrontend/src/main/scala/chisel3/core/SeqUtils.scala b/chiselFrontend/src/main/scala/chisel3/core/SeqUtils.scala index e87fb045..f15fb178 100644 --- a/chiselFrontend/src/main/scala/chisel3/core/SeqUtils.scala +++ b/chiselFrontend/src/main/scala/chisel3/core/SeqUtils.scala @@ -37,7 +37,9 @@ private[chisel3] object SeqUtils { def do_count(in: Seq[Bool])(implicit sourceInfo: SourceInfo, compileOptions: CompileOptions): UInt = in.size match { case 0 => 0.U case 1 => in.head - case n => count(in take n/2) +& count(in drop n/2) + case n => + val sum = count(in take n/2) +& count(in drop n/2) + sum(BigInt(n).bitLength - 1, 0) } /** Returns the data value corresponding to the first true predicate. |
