Skip to the selected question
ASIC.FYI

ASIC Question Bank

1,000+ hardware interview questions
DescriptionQ504
Page ↗
Q504FWASIC interview problem

Compute Hamming distance

TechniquesBitsXORPopcount
DifficultyEasy
TopicBit Manipulation
LanguageSystemVerilog
Requirements2 checkpoints
01

Problem

Return the number of bit positions where two 32-bit integers differ.

Example input and output

Use this case to check your interpretation
Input
left = 4'b1010, right = 4'b0011
Output
2
Explanation

The XOR is 1001, which contains two set bits.

02

Requirements (2)

  • Use XOR to expose mismatches.
  • Count the set bits in the XOR result.