function vector2integer (bv: std_logic_vector (4 downto 0)) return integer is
variable result, abit : integer := 0;
variable count : integer := 0;
begin
bits : for I in bv'low to bv'high loop
abit := 0;
if bv(I) = '1' then
abit := 2**(I - bv'low);
end if;
result := result + abit;
count := count + 1;
exit bits when count = 5;
end loop bits;
return (result);
end vector2integer;