integer width during synthesis

S

Sachin Chandra

Guest
Hello,
I was wondering if its possible to change the size of allocation for
an integer from 32 bits to maybe 8 bits. I was considering this
because i need to access individual elements of an array or a vector.
If i use an integer and considering the maximum value i need is 16
using an integer with 32 bits is a waste and hence i needed to know if
i can set it using the synthesizer.
Or can i typecast it like its done in C.
thanks in advance
sachin
 
Then do not use integer, use reg[3:0] if the maximum value is 8
"Sachin Chandra" <chandras20@hotmail.com> Đ´ČëĎűϢĐÂÎĹ
:2b3ac527.0312231907.7403017f@posting.google.com...
Hello,
I was wondering if its possible to change the size of allocation for
an integer from 32 bits to maybe 8 bits. I was considering this
because i need to access individual elements of an array or a vector.
If i use an integer and considering the maximum value i need is 16
using an integer with 32 bits is a waste and hence i needed to know if
i can set it using the synthesizer.
Or can i typecast it like its done in C.
thanks in advance
sachin
 
chandras20@hotmail.com (Sachin Chandra) wrote in message news:<2b3ac527.0312231907.7403017f@posting.google.com>...
Hello,
I was wondering if its possible to change the size of allocation for
an integer from 32 bits to maybe 8 bits.
No. And in fact, an integer is not specifically 32 bits. It is an
implementation-defined size that is at least 32 bits. I would not
advise using an integer for anything that is supposed to represent
actual hardware.

I was considering this
because i need to access individual elements of an array or a vector.
If i use an integer and considering the maximum value i need is 16
using an integer with 32 bits is a waste and hence i needed to know if
i can set it using the synthesizer.
You don't have to use an integer for an index into an array or vector.
You can use a smaller vector as an index. Declare your index variable
or net to be a vector of the appropriate width (5 bits if you really
need to represent 16, 4 bits if you really meant 16 values between 0
and 15). You can still use it as an index into an array or vector.

However, I would expect an intelligent synthesis tool to optimize away
any excess bits anyway. If you are selecting one of 16 bits, it should
create a 16-to-1 mux, with 4 select bits, and throw any additional
unused select bits away.
 

Welcome to EDABoard.com

Sponsor

Back
Top