Egbert Molenkamp
"chak" <chak...@www.com> wrote in message
news:5dd17323.02041...@posting.google.com...
CONV_INTEGER--Converts a parameter of type INTEGER, UNSIGNED, SIGNED, or
STD_ULOGIC to an INTEGER value. The size of operands in CONV_INTEGER
functions are limited to the range -2147483647 to 2147483647, i.e., to a
31-bit UNSIGNED value or a 32-bit SIGNED value.
CONV_UNSIGNED--Converts a parameter of type INTEGER, UNSIGNED, SIGNED, or
STD_ULOGIC to an UNSIGNED value with SIZE bits.
CONV_SIGNED--Converts a parameter of type INTEGER, UNSIGNED, SIGNED, or
STD_ULOGIC to a SIGNED value with SIZE bits.
CONV_STD_LOGIC_VECTOR--Converts a parameter of type INTEGER, UNSIGNED,
SIGNED, or STD_LOGIC to a STD_LOGIC_VECTOR value with SIZE bits. Example
Four versions of each function are available; the correct version for each
function call is determined through operator overloading.
Two operands are required for the CONV_UNSIGNED, CONV_SIGNED, and
CONV_STD_LOGIC_VECTOR functions: the value to be converted and an integer
that specifies the size of the converted value. If the value to be converted
is smaller than the expected size, the value is extended as necessary.
.
LIBRARY ieee;
USE ieee.std_logic_1164.all;
USE ieee.std_logic_arith.all;
ENTITY adder IS
PORT (op1, op2 : IN UNSIGNED(7 DOWNTO 0);
result : OUT INTEGER);
END adder;
ARCHITECTURE maxpld OF adder IS
BEGIN
result <= CONV_INTEGER(op1 + op2);
END maxpld;
In this example, the ieee library is declared, and the std_logic_1164 and
std_logic_arith packages are specified. The inputs are declared with type
UNSIGNED, and the output is declared with type INTEGER.
maybe it could help you...
bye!
You should use the standard "numeric_std" library instead of the std_arith* that
are NOT standard despite their names.
Converting signed or unsigned to std_logic_vector is just a type casting:
slv_value <= std_logic_vector(uns_value)
If you need to convert integers... you'll have to use the conversion functions
TO_SIGNED, TO_UNSIGNED or TO_INTEGER
--
Nicolas MATRINGE IPricot European Headquarters
Conception electronique 10-12 Avenue de Verdun
Tel +33 1 46 52 53 11 F-92250 LA GARENNE-COLOMBES - FRANCE
Fax +33 1 46 52 53 02 http://www.IPricot.com/
use ieee.numeric_std.all ;
...
signal some_unsigned_value : unsigned( 7 downto 0 ) ;
signal some_std_logic_value : std_logic_vector(7 downto 0 ) ;
signal another_unsigned_value : unsigned( 7 downto 0 ) ;
...
some_unsigned_value <= to_stdlogicvector( some_unsigned_value ) ;
another_unsigned_value <= to_unsigned( some_std_logic_value ) ;
...
If you need to convert to bit vectors, you need to decide what how you want
X,Z,U etc to translate to '1's and '0's, since bit only takes on '1', or
'0'. If you are going to synthesize, you should really stay with
std_logic_vector, and its subsets, signed, and unsigned.
Regards,
"chak" <chak...@www.com> wrote in message
news:5dd17323.02041...@posting.google.com...
library IEEE;
use IEEE.STD_LOGIC_1164.all;
use IEEE.NUMERIC_STD.all;
...
signal BV: BIT_VECTOR(15 downto 0);
signal UV: UNSIGNED(1 to 16);
...
BV <= TO_BITVECTOR(STD_ULOGIC_VECTOR(UV));
UV <= UNSIGNED(TO_STDULOGICVECTOR(BV));
As suggested by Egbert the FAQ is a good starting point if you want
to understand all this.
Regards.
--
Renaud Pacalet, ENST / COMELEC, 46 rue Barrault 75634 Paris Cedex 13
Tel. : 01 45 81 78 08 | Fax : 01 45 80 40 36 | Mel : pac...@enst.fr
###### Fight Spam! Join EuroCAUCE: http://www.euro.cauce.org/ ######