Hardware interview practice
Count set bits with Kernighan's method
Return the number of 1 bits in a 32-bit unsigned integer.
Reviewed example
Work through one case
Input
value = 8'b1011_0100Expected output
4Four iterations clear the lowest remaining one-bit before the value reaches zero.
What to cover
Requirements
- Clear one set bit per iteration.
- Return zero for an all-zero input.
