[an error occurred while processing this directive]
|
CASE value IS
WHEN '0' | '1' => RETURN value;
WHEN 'H' => RETURN '1';
WHEN 'L' => RETURN '0';
WHEN OTHERS => RETURN 'X';
END CASE;
END rat;
FUNCTION std_logic_vector_2_int(vect : std_logic_vector)
RETURN INTEGER;
FUNCTION std_logic_vector_2_int(vect : std_logic_vector)
RETURN INTEGER IS
variable local_vect : std_logic_vector(vect'HIGH downto 0);
variable result : INTEGER := 0;
BEGIN
IF (rat(vect(vect'HIGH)) = '1') THEN -- negative number
local_vect := two_comp(vect);
ELSE
local_vect := vect;
END IF;
FOR i in vect'HIGH downto 0 LOOP
result := result * 2;
IF (rat(local_vect(i)) = '1') THEN
result := result + 1;
ELSIF (rat(local_vect(i)) /= '0') THEN
ASSERT FALSE
REPORT "Treating a non 0-1 std_logic_vector as 0 in std_logic_vector_2_int"
SEVERITY WARNING;
END IF;
END LOOP;
IF (rat(vect(vect'HIGH)) = '1') THEN
result := -1 * result;
END IF;
RETURN result;
END std_logic_vector_2_int;
E-mail: info@telesys.ru