Hamming distance

The Hamming distance between two bit-vectors is defined as the number of bit locations in which the two vectors differ. For example, the Hamming distance of the vectors 00110 and 10100 is 2. Design a circuit that calculates the Hamming distance of two 3-bit vectors. The distance should be represented with a 2-bit number.

Specification

module hamming3(a, b, distance);
   input [2:0] a, b;
   output [1:0] distance;

Input

Output

Problem information

Author: Jordi Cortadella

Generation: 2026-02-03T12:13:14.492Z

© Jutge.org, 2006–2026.
https://jutge.org