binary to decimal

S

srinukasam

hi all
i need code for two functions in vhdl.
1. binary to integer ( any lenth _ no problem)
2. interger to binary

iam very thankful to you all .
bye
 
R

Ralf Hildebrandt

srinukasam said:
i need code for two functions in vhdl.
1. binary to integer ( any lenth _ no problem)
2. interger to binary

Take a look into the packages!

library IEEE;
use IEEE.numeric_std.all;
--
signal my_sulv1 : std_ulogic_vector(15 downto 0);
signal my_int : integer;
signal my_sulv2 : std_ulogic_vector(15 downto 0);
--
my_int <= to_integer(unsigned(my_sulv1));

my_sulv2 <= std_ulogic_vector(to_unsigned(my_int, 16));


Ralf
 
B

bstaicu

try conv_integer(unsigned(x)) and conv_std_logic_vector(integer,
number_of_bits_for_conversion)

I believe they're both defined in IEEE.std_logic_arith
 
R

Ralf Hildebrandt

bstaicu said:
try conv_integer(unsigned(x)) and conv_std_logic_vector(integer,
number_of_bits_for_conversion)

I believe they're both defined in IEEE.std_logic_arith

Non, please don't try them, because std_logic_arith is NOT a standard
library while numeric_std is one. Therefore your code may not run as
expected on different simulators and synthesis tools.

Ralf
 

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,769
Messages
2,569,581
Members
45,056
Latest member
GlycogenSupporthealth

Latest Threads

Top