Big integer constants

Discussion in 'VHDL' started by Hal Murray, Nov 10, 2004.

  1. Hal Murray

    Hal Murray Guest

    I want to do something like
    x <= x + 123456789123123;
    where the constant is bigger than 32 bits.

    Is there a standard/clean way to do this?

    In case it matters, I actually want to pass the constant
    in as a generic. I'm willing to write ugly code as long
    as it gets good results.

    --
    The suespammers.org mail server is located in California. So are all my
    other mailboxes. Please do not send unsolicited bulk e-mail or unsolicited
    commercial e-mail to my suespammers.org address or any of my other addresses.
    These are my opinions, not necessarily my employer's. I hate spam.
     
    Hal Murray, Nov 10, 2004
    #1
    1. Advertising

  2. Hal Murray

    Jim Lewis Guest

    I suppose there is the obvious:
    split it into more than one integer.

    > I want to do something like
    > x <= x + 123456789123123;
    > where the constant is bigger than 32 bits.
    >
    > Is there a standard/clean way to do this?
    >
    > In case it matters, I actually want to pass the constant
    > in as a generic. I'm willing to write ugly code as long
    > as it gets good results.
    >



    --
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    Jim Lewis
    Director of Training mailto:
    SynthWorks Design Inc. http://www.SynthWorks.com
    1-503-590-4787

    Expert VHDL Training for Hardware Design and Verification
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     
    Jim Lewis, Nov 10, 2004
    #2
    1. Advertising

  3. Hal Murray wrote:
    > I want to do something like
    > x <= x + 123456789123123;
    > where the constant is bigger than 32 bits.
    >
    > Is there a standard/clean way to do this?


    Type unsigned can handle it.

    -- Mike Treseler
     
    Mike Treseler, Nov 10, 2004
    #3
  4. Hal Murray

    Guest

    (Hal Murray) writes:

    > I want to do something like
    > x <= x + 123456789123123;
    > where the constant is bigger than 32 bits.
    >
    > Is there a standard/clean way to do this?


    Use hex or aggregates:

    unsigned(to_stdlogicvector(bit_vector'(X"00007048860F9033"))(63 DOWNTO 0))

    or

    (46 DOWNTO 44 => '1',
    38 => '1', 35 => '1', 31 => '1',
    26 DOWNTO 25 => '1',
    19 DOWNTO 15 => '1',
    12 => '1',
    5 DOWNTO 4 => '1',
    1 DOWNTO 0 => '1',
    OTHERS => '0')
     
    , Nov 11, 2004
    #4
  5. wrote:
    > (Hal Murray) writes:
    >
    >
    >>I want to do something like
    >> x <= x + 123456789123123;
    >>where the constant is bigger than 32 bits.
    >>
    >>Is there a standard/clean way to do this?

    >
    >
    > Use hex or aggregates:
    >
    > unsigned(to_stdlogicvector(bit_vector'(X"00007048860F9033"))(63 DOWNTO 0))


    The qualification and conversions are not needed. Since the 93 standard
    bit literals may be used for std_logic_vectors (and signed/unsigned) as
    well. So the following is valid:

    example: PROCESS IS
    VARIABLE uns: unsigned(63 DOWNTO 0);
    BEGIN
    uns := uns + X"1234567890ABCDEF";
    WAIT;
    END PROCESS example;

    Paul.
     
    Paul Uiterlinden, Nov 12, 2004
    #5
  6. Hal Murray

    Guest

    Paul Uiterlinden <> writes:

    > wrote:
    > > (Hal Murray) writes:
    > >
    > >>I want to do something like
    > >> x <= x + 123456789123123;
    > >>where the constant is bigger than 32 bits.
    > >>
    > >>Is there a standard/clean way to do this?

    > > Use hex or aggregates:
    > > unsigned(to_stdlogicvector(bit_vector'(X"00007048860F9033"))(63 DOWNTO 0))

    >
    > The qualification and conversions are not needed. Since the 93 standard bit
    > literals may be used for std_logic_vectors (and signed/unsigned) as well. So the
    > following is valid:
    >
    > example: PROCESS IS
    > VARIABLE uns: unsigned(63 DOWNTO 0);
    > BEGIN
    > uns := uns + X"1234567890ABCDEF";
    > WAIT;
    > END PROCESS example;


    Yes, I have should have been clearer in saying that all the extra conversions
    etc. are only needed if you want the expression to work in both the -87 and -93
    environments. This is the standard idiom that is in the VHDL FAQ for such dual
    environment use.

    By way of defense I can say that at least one major simulator only recently
    (June 2004) changed their default to be VHDL-93 instead of -87.
     
    , Nov 12, 2004
    #6
    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. Replies:
    11
    Views:
    727
    Roedy Green
    Sep 18, 2005
  2. Shaguf
    Replies:
    0
    Views:
    506
    Shaguf
    Dec 24, 2008
  3. Shaguf
    Replies:
    0
    Views:
    479
    Shaguf
    Dec 26, 2008
  4. Shaguf
    Replies:
    0
    Views:
    257
    Shaguf
    Dec 26, 2008
  5. Shaguf
    Replies:
    0
    Views:
    236
    Shaguf
    Dec 24, 2008
Loading...

Share This Page