binary to decimal

Discussion in 'VHDL' started by srinukasam, Jun 16, 2005.

  1. srinukasam

    srinukasam Guest

    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
     
    srinukasam, Jun 16, 2005
    #1
    1. Advertising

  2. srinukasam wrote:

    > 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
     
    Ralf Hildebrandt, Jun 16, 2005
    #2
    1. Advertising

  3. srinukasam

    bstaicu Guest

    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
     
    bstaicu, Jun 17, 2005
    #3
  4. bstaicu wrote:

    > 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
     
    Ralf Hildebrandt, Jun 17, 2005
    #4
  5. srinukasam

    vipinlal

    Joined:
    Feb 25, 2010
    Messages:
    38
    hop this helps:
    vhdlguru.blogspot.com/2010/04/8-bit-binary-to-bcd-converter-double.html
     
    vipinlal, Apr 19, 2010
    #5
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Ven
    Replies:
    3
    Views:
    1,327
  2. Gilbert Fine
    Replies:
    8
    Views:
    904
    Zentrader
    Aug 1, 2007
  3. Vitaliy
    Replies:
    1
    Views:
    476
    Peter Otten
    May 29, 2008
  4. valpa
    Replies:
    11
    Views:
    1,521
    Steven D'Aprano
    Mar 24, 2009
  5. Replies:
    0
    Views:
    293
Loading...

Share This Page