to_std_logic_vector(integer, n)

W

Weng Tianxiang

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
 
R

Ralf Hildebrandt

Weng said:
[ieee.numeric_std.all]
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
 
A

Allan Herriman

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
 
W

Weng Tianxiang

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

My home project was waiting for the error to eliminate.

Weng
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,772
Messages
2,569,593
Members
45,111
Latest member
KetoBurn
Top