Numeric_std unsigned issues?

Discussion in 'VHDL' started by rman123, Mar 28, 2011.

  1. rman123

    rman123

    Joined:
    Mar 28, 2011
    Messages:
    3
    I'm trying to convert a decimal number that is greater than 2^31 to a 32 bit unsigned number.

    mem_i <= to_unsigned(2952790016, 32);

    I have numeric_std included. It throws the error on compile:
    Error: ./src/test_tb.vhd(147): near "2952790016": (vcom-119) Integer value exceeds INTEGER'high.
    # ** Warning: [14] ./src/test_tb.vhd(147): (vcom-1144) Value -1342177280 is out of std.standard.natural range 0 to 2147483647.

    Firstly, why is this looking at INTEGER'high? Shouldn't a to_unsigned() be looking at a NATURAL? Secondly, isn't the natural range up to 2^32-1 (4294967295)?

    Any explanation about integers, naturals, and type conversions would be appreciated.
     
    rman123, Mar 28, 2011
    #1
    1. Advertising

  2. rman123

    joris

    Joined:
    Jan 29, 2009
    Messages:
    152
    I'm pretty sure this error occurs while parsing the integer value 2952790016 - before passing it to the to_unsigned function.
    (Because the Integer type is defined to be a signed 32-bit value)

    I think you'll have to hardcode it as X"B0000000".
     
    joris, Mar 29, 2011
    #2
    1. Advertising

  3. rman123

    rman123

    Joined:
    Mar 28, 2011
    Messages:
    3
    Thanks for the reply.

    Bummer.
     
    rman123, Mar 30, 2011
    #3
    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. Mike Treseler

    Re: Quartus warning in NUMERIC_STD.vhd

    Mike Treseler, Jul 11, 2003, in forum: VHDL
    Replies:
    2
    Views:
    1,860
    Clyde R. Shappee
    Jul 13, 2003
  2. lezah
    Replies:
    2
    Views:
    7,721
    Mike Treseler
    Feb 6, 2004
  3. ALuPin

    std_logic_arith / numeric_std

    ALuPin, Apr 6, 2004, in forum: VHDL
    Replies:
    5
    Views:
    11,214
    Tim Hubberstey
    Apr 8, 2004
  4. Mark Norton
    Replies:
    12
    Views:
    10,707
  5. pozz
    Replies:
    12
    Views:
    760
    Tim Rentsch
    Mar 20, 2011
Loading...

Share This Page