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 <
rxj...@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