You are here : vhdlstd_logic_arithconv_signed

conv_signed() - std_logic_arith

These functions convert the arg argument to a 2's complement signed 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.


Syntax

function conv_signed(arg: integer, size: integer) return signed;
function conv_signed(arg: unsigned, size: integer) return signed;
function conv_signed(arg: signed, size: integer) return signed;
function conv_signed(arg: std_ulogic, size: integer) return signed;


Example

signal u1 : unsigned (3 downto 0);
signal s1, s2, s3 : signed (3 downto 0);
signal i1, i2 : integer;
...
u1 <= "0101";
i1 <= 6;
i2 <= -2;
wait for 10 ns;
s1 <= conv_signed(u1, 4);   -- = "0101" = +5
s2 <= conv_signed(i1, 4);   -- = "0110" = +6
s3 <= conv_signed(i2, 4);   -- = "1110" = -2


Output / Return Value


Limitations


Alternatives / See Also


Reference

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