Big integer constants

H

Hal Murray

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.
 
J

Jim Lewis

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:[email protected]
SynthWorks Design Inc. http://www.SynthWorks.com
1-503-590-4787

Expert VHDL Training for Hardware Design and Verification
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
M

Mike Treseler

Hal said:
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
 
G

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?

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')
 
P

Paul Uiterlinden

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.
 
G

Guest

Paul Uiterlinden said:
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.
 

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

Forum statistics

Threads
473,743
Messages
2,569,478
Members
44,899
Latest member
RodneyMcAu

Latest Threads

Top