conv_unsigned
function
function conv_unsigned(arg: integer, size: integer) return unsigned;
function conv_unsigned(arg: unsigned, size: integer) return unsigned;
function conv_unsigned(arg: signed, size: integer) return unsigned;
function conv_unsigned(arg: std_ulogic, size: integer) return unsigned;
These functions convert the arg
argument to an unsigned
value with size
bits.
The function provided by the std_logic_arith
library can't convert a std_logic_vector
to an integer because it is impossible to determine if it represents an unsigned or signed value. Functions that do this are included in the std_logic_unsigned
and std_logic_signed
libraries.
signal u1, u2 : unsigned (3 downto 0); signal s1 : signed (3 downto 0); signal i1, i2 : integer; ... s1 <= "0101"; i1 <= 13; wait for 10 ns; u1 <= conv_unsigned(s1, 4); -- = "0101" = 5 u2 <= conv_unsigned(i1, 4); -- = "1101" = 13