You are here : vhdlstd_logic_arithconv_integer

conv_integer() - std_logic_arith

These functions convert the arg argument to an integer. If the argument contains any undefined elements, a runtime warning is produced and 0 is returned.

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.


Syntax

function conv_integer(arg: integer) return integer;
function conv_integer(arg: unsigned) return integer;
function conv_integer(arg: signed) return integer;
function conv_integer(arg: std_ulogic) return small_int;


Example

signal b : std_logic;
signal u1 : unsigned (3 downto 0);
signal s1 : signed (3 downto 0);
signal i1, i2, i3 : integer;
...
u1 <= "1001";
s1 <= "1001";
b <= 'X';
wait for 10 ns;
i1 <= conv_integer(u1);  -- 9
i2 <= conv_integer(s1);  -- -7
i3 <= conv_integer(b);   -- warning produced in simulator


Output / Return Value


Limitations


Alternatives / See Also


Reference

https://www.cs.sfu.ca/~ggbaker/reference/std_logic/arith/conv_integer.html