Skip to the selected question
ASIC.FYI

ASIC Question Bank

1,000+ hardware interview questions
DescriptionQ962
Q962DesignASIC interview problem

Count active lanes in a predicate mask

TechniquesPopulation countReductionWidth arithmetic
DifficultyEasy
TopicRTL Design
LanguageSystemVerilog
Requirements4 checkpoints
01

Problem

Implement a combinational population-count unit for a statically sized predicate mask. The result must represent every value from zero through WIDTH.

Example input and output

Use this case to check your interpretation
Input
WIDTH=5; predicate mask=5'b10111
Output
count=3'b100 (4 active lanes)
Explanation

$clog2(5+1)=3 result bits represent the all-active value five without truncating the four counted ones.

02

Requirements (4)

  • Support any static WIDTH >= 1, including non-powers of two.
  • Size the result with $clog2(WIDTH + 1) so the all-ones answer is representable.
  • Do not use a simulation-only system task as the implementation.
  • Assign the accumulator on every evaluation and avoid truncated intermediate results.