What is the difference of "array (63 downto 0) of ...." and

F

fl

Guest
Hi,
I know downto and to for one dimension array. I see the following definition in a file.
But for two dimension array, what happens?

...................
TYPE ram_type IS ARRAY (63 DOWNTO 0) of std_logic_vector(31 DOWNTO 0);
...................


I want to know what is the difference between the above one with:

...................
TYPE ram_type IS ARRAY (0 TO 63) of std_logic_vector(31 DOWNTO 0);
...................


Thanks,
 
On Tue, 26 Feb 2013 06:32:56 -0800 (PST)
fl <rxjwg98@gmail.com> wrote:

Hi,
I know downto and to for one dimension array. I see the following definition in a file.
But for two dimension array, what happens?

..................
TYPE ram_type IS ARRAY (63 DOWNTO 0) of std_logic_vector(31 DOWNTO 0);
..................


I want to know what is the difference between the above one with:

..................
TYPE ram_type IS ARRAY (0 TO 63) of std_logic_vector(31 DOWNTO 0);
..................


Thanks,
Probably nothing. Technically, this affects your ability to take
slices of the RAM array, use shift operators, assign the array from
concatenation results, etc. But practically, if you're using it as a
RAM, you're only going to index one element of it at a time, and
therefore you'll never notice any difference.

--
Rob Gaddi, Highland Technology -- www.highlandtechnology.com
Email address domain is currently out of order. See above to fix.
 
Rob Gaddi wrote:
On Tue, 26 Feb 2013 06:32:56 -0800 (PST)
fl <rxjwg98@gmail.com> wrote:

Hi,
I know downto and to for one dimension array. I see the following definition in a file.
But for two dimension array, what happens?

..................
TYPE ram_type IS ARRAY (63 DOWNTO 0) of std_logic_vector(31 DOWNTO 0);
..................


I want to know what is the difference between the above one with:

..................
TYPE ram_type IS ARRAY (0 TO 63) of std_logic_vector(31 DOWNTO 0);
..................


Thanks,

Probably nothing. Technically, this affects your ability to take
slices of the RAM array, use shift operators, assign the array from
concatenation results, etc. But practically, if you're using it as a
RAM, you're only going to index one element of it at a time, and
therefore you'll never notice any difference.

Just one word of caution. If this is for synthesis, you should check
with the tool providers for the suggested templates to infer RAM. I
know that Xilinx XST is pretty finicky about how to infer block RAM
for instance, and although it should make no difference, you may find
that one works and another infers a lot of flip-flops.

-- Gabor
 
On Tuesday, February 26, 2013 11:12:31 AM UTC-6, Rob Gaddi wrote:
On Tue, 26 Feb 2013 06:32:56 -0800 (PST) fl <rxjwg98@gmail.com> wrote: > Hi, > I know downto and to for one dimension array. I see the following definition in a file. > But for two dimension array, what happens? > > ................... > TYPE ram_type IS ARRAY (63 DOWNTO 0) of std_logic_vector(31 DOWNTO 0); > .................. > > > I want to know what is the difference between the above one with: > > .................. > TYPE ram_type IS ARRAY (0 TO 63) of std_logic_vector(31 DOWNTO 0); > .................. > > > Thanks, Probably nothing. Technically, this affects your ability to take slices of the RAM array, use shift operators, assign the array from concatenation results, etc. But practically, if you're using it as a RAM, you're only going to index one element of it at a time, and therefore you'll never notice any difference. -- Rob Gaddi, Highland Technology -- www.highlandtechnology.com Email address domain is currently out of order. See above to fix.
Probably just semantics, but the index direction does not affect "whether" you can slice/shift/concatenate an array, but "how". Any reference to the range or subrange of an array must be in the same direction as the array's declaration.

Just for my own preference, I use downto with SLV unless it is on an external interface that is explicitly declared with "to" direction. Note that when given a numeric interpretation (as in signed/unsigned types), the arithmetic MSB is the leftmost bit, not the highest numbered bit. If you are interfacing to a device bus that uses bit 0 as the MSB, then you would use "to" as the direction for that interface.

You can assign between arrays (aka vectors) with different directions just fine. No matter what the direction, assignments are done left-right.

Again, for my own preference, I usually use "to" direction for arrays of vectors or integers. This sometimes makes it easier to keep track of which index is which (for an array of SLV, etc.)

Andy
 
Im going to be a little pedant.

What you have is not a 2d array. Its a 1d array of 1d arrays. In the strong typing of VHDL, it can make a difference.
 
On Wednesday, February 27, 2013 9:38:08 AM UTC-6, Tricky wrote:
Im going to be a little pedant. What you have is not a 2d array. Its a 1d array of 1d arrays. In the strong typing of VHDL, it can make a difference.
Even more pedantic, a true 2d array object can be assigned with an aggregate expression that describes an array of arrays. See the resolution_table constant in the reference package body for ieee.std_logic_1164.

But you cannot assign a 2d array object to/from an object that is an array of arrays. Nor can you slice a 2d array.

Go figure...

Andy
 

Welcome to EDABoard.com

Sponsor

Back
Top