library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;


entity Hamming_distance is
port (a :in std_logic_vector(7 downto 0);
		b :in std_logic_vector(7 downto 0);
		ham_dist :out integer range 0 to 8);
end Hamming_distance;

architecture Hamming_distance of Hamming_distance is

function "+" (d: integer; e:std_logic) return integer is
begin
if (e='1') then return d+1;
else return d;
end if;
end "+";

signal c: std_logic_vector(7 downto 0);
begin
c<=a xor b;
ham_dist<=conv_integer(0+c(7)+c(6)+c(5)+c(4)+c(3)+c(2)+c(1)+c(0));

end Hamming_distance;

