to_std_logic_vector(integer, n)

W

Weng Tianxiang

Guest
Hi,
I copies the following notes from a web post in this group as for my
later use.
-- std_logic_vector( std_logic_vector ) : converting std_logic_vector
to std_logic_vector
-- std_logic_vector( std_logic_vector ) : converting std_logic_vector
to std_logic_vector
-- to_std_logic_vector( integer, n ) : converting integer to n bits
std_logic_vector
-- signed( std_logic_vector ) : converting std_logic_vector to integer

Finally when I wanted to use the function to_std_logic_vector( integer,
n ), I found ieee.numeric_std.all has no such function.

What function can I use to transfer an integer to std_logic_vector?

Thank you.

Weng
 
Weng Tianxiang wrote:

What function can I use to transfer an integer to std_logic_vector?

my_slv_u<=std_logic_vector(to_unsigned(my_integer));
my_slv_s<=std_logic_vector(to_signed(my_integer));

Take always the (longer) way over unsigned / signed to define well, if
you want to take the value as signed or unsigned.


Ralf
 
On 12 Feb 2006 08:46:47 -0800, "Weng Tianxiang" <wtxwtx@gmail.com>
wrote:

Hi,
I copies the following notes from a web post in this group as for my
later use.
-- std_logic_vector( std_logic_vector ) : converting std_logic_vector
to std_logic_vector
-- std_logic_vector( std_logic_vector ) : converting std_logic_vector
to std_logic_vector
-- to_std_logic_vector( integer, n ) : converting integer to n bits
std_logic_vector
-- signed( std_logic_vector ) : converting std_logic_vector to integer

Finally when I wanted to use the function to_std_logic_vector( integer,
n ), I found ieee.numeric_std.all has no such function.

What function can I use to transfer an integer to std_logic_vector?
Use to_signed(), then convert the result to std_logic_vector.

Similarly, if you start with a Natural instead of Integer, use
to_unsigned();

Regards,
Allan
 
Hi Ralf and Allan,
Thank you very much for your fast help.

My home project was waiting for the error to eliminate.

Weng
 

Welcome to EDABoard.com

Sponsor

Back
Top