dimension of an integer

M

Max

How can I obtain the dimension in bit of an integer?

I have a generic, and I need to store its value in a std_logic_vector,
but I don't know the dimansion of this vector.

thanks
 
J

Johan Wouters

Max said:
How can I obtain the dimension in bit of an integer?

I have a generic, and I need to store its value in a std_logic_vector,
but I don't know the dimansion of this vector.

thanks

Maybe you can use attributes such as 'high and 'low etc?
--
===================================================================
Johan Wouters === Easics NV
Senior ASIC designer === a TranSwitch Company
Tel: +32-16-395 616 === System-on-Chip Design
Fax: +32-16-395 619 Interleuvenlaan 86, B-3001 Leuven, BELGIUM
mailto:[email protected] http://www.easics.com
 
J

Jim Lewis

Assignments to unconstrained integer signals typically
result in 32 bit signed hardware.

For synthesis, I only recommend using integers
as literal values numeric expressions:
Y <= '1' when A > 12 else '0' ;
Count <= Count + 1 ;

In this case you don't need any conversions, it
works because of the overloading.


For a quick tutorial on VHDL overloading, conversions, ... see my
MAPLD paper, VHDL Math Tricks of the Trade. It is available
at http://www.synthworks.com/papers

Cheers,
Jim Lewis
--
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
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
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
S

sean

(e-mail address removed) (Max) wrote in message
How can I obtain the dimension in bit of an integer?

I have a generic, and I need to store its value in a std_logic_vector,
but I don't know the dimansion of this vector.

If you use the CONV_STD_LOGIC_VECTOR function in std_logic_arith you
specify the number of bits for the resulting vector, eg

CONV_STD_LOGIC_VECTOR(5, 4) returns a 4-bit vector "0101"

Other conversion functions have the same arguments.

If you want an integer-type signal to be synthesised with a certain
number of bits, you define the range when you declare the signal, eg

signal blahblah : integer range 0 to 15; will synthesise to a 4 bit
signal.

Sean
 

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,744
Messages
2,569,483
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top