Decimal numbers

T

Tim Hubberstey

Ed said:
When using std_logic_vectors(xx downto yy) I can use either binary numbers
in the form "11010101" or hex numbers in the form x"00". How can I use
decimal numbers?

Use type conversion functions:

library ieee;
use ieee.numeric_std.all;
....
signal some_vector : std_logic_vector(x-1 downto 0);
....
some_vector <= std_logic_vector(to_unsigned(DECIMAL_VAL, x);
or
some_vector <= std_logic_vector(to_signed(DECIMAL_VAL, x);

Limitations: Maximum value for 'x' is 31 for unsigned, 32 for signed.
 
E

Ed

Hello,

When using std_logic_vectors(xx downto yy) I can use either binary numbers
in the form "11010101" or hex numbers in the form x"00". How can I use
decimal numbers? I've done a google search but can't find any answers.

Thanks,
 
T

Thomas Reinemann

Tim said:
some_vector <= std_logic_vector(to_unsigned(DECIMAL_VAL, x);
or
some_vector <= std_logic_vector(to_signed(DECIMAL_VAL, x);
some_vector <= std_logic_vector(to_signed(DECIMAL_VAL,some_vector'length);

will automatically pass the right value to "to_signed". Of course you
can use it in "to_unsigned".

Regards,

Tom
 

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

No members online now.

Forum statistics

Threads
473,766
Messages
2,569,569
Members
45,042
Latest member
icassiem

Latest Threads

Top