Skip to content

Commit

Permalink
popcount: Fix output width
Browse files Browse the repository at this point in the history
  • Loading branch information
diskouna committed Jan 1, 2025
1 parent f36828f commit 7c28d39
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/popcount.sv
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

// Description: This module calculates the hamming weight (number of ones) in
// its input vector. Any unsigned INPUT_WIDTH larger or equal 1 is legal. The output result
// width is ceil(log2(INPUT_WIDTH))+1.
// width is ceil(log2(INPUT_WIDTH+1)).
//
// This module used to be implemented using a binary added tree. However,
// the heuristics of modern logic Synthesizers work much better with a flat high
Expand All @@ -21,7 +21,7 @@

module popcount #(
parameter int unsigned INPUT_WIDTH = 256,
localparam int unsigned PopcountWidth = $clog2(INPUT_WIDTH) + 1
localparam int unsigned PopcountWidth = $clog2(INPUT_WIDTH+1)
) (
input logic [ INPUT_WIDTH-1:0] data_i,
output logic [PopcountWidth-1:0] popcount_o
Expand Down

0 comments on commit 7c28d39

Please sign in to comment.