PDA

View Full Version : RANGE attribute use


Shannon
09-01-2007, 11:22 PM
The newbie is back!

Why can't I do this:

type table_array IS ARRAY (0 to 16) of STD_LOGIC_VECTOR(11 downto 0);
signal table: table_array;
....

FOR i in 1 to table'RANGE loop
....


Shannon

KJ
09-02-2007, 01:15 AM
"Shannon" <[email protected]> wrote in message
news:[email protected] ups.com...
> The newbie is back!
>
> Why can't I do this:
>
> type table_array IS ARRAY (0 to 16) of STD_LOGIC_VECTOR(11 downto 0);
> signal table: table_array;
> ...
>
> FOR i in 1 to table'RANGE loop
> ...
Because the correct syntax is...
FOR i in table'RANGE loop
KJ

Shannon
09-02-2007, 03:36 AM
On Sep 1, 5:15 pm, "KJ" <[email protected]> wrote:
> "Shannon" <[email protected]> wrote in message
>
> news:[email protected] ups.com...> The newbie is back!
>
> > Why can't I do this:
>
> > type table_array IS ARRAY (0 to 16) of STD_LOGIC_VECTOR(11 downto 0);
> > signal table: table_array;
> > ...
>
> > FOR i in 1 to table'RANGE loop
> > ...
>
> Because the correct syntax is...
> FOR i in table'RANGE loop
> KJ

Almost.

An allowed syntax is:

FOR i in 1 to 10 Loop

Correct?

if table'range = 10 then why couldn't I say

FOR i in 1 to table'range Loop

?

Allan Herriman
09-02-2007, 05:05 AM
On Sun, 02 Sep 2007 02:36:33 -0000, Shannon <[email protected]>
wrote:

>On Sep 1, 5:15 pm, "KJ" <[email protected]> wrote:
>> "Shannon" <[email protected]> wrote in message
>>
>> news:[email protected] ups.com...> The newbie is back!
>>
>> > Why can't I do this:
>>
>> > type table_array IS ARRAY (0 to 16) of STD_LOGIC_VECTOR(11 downto 0);
>> > signal table: table_array;
>> > ...
>>
>> > FOR i in 1 to table'RANGE loop
>> > ...
>>
>> Because the correct syntax is...
>> FOR i in table'RANGE loop
>> KJ
>
>Almost.
>
>An allowed syntax is:
>
>FOR i in 1 to 10 Loop
>
>Correct?

Good so far.

>if table'range = 10 then why couldn't I say

No. table'range isn't "10". It is a range 1 to 10. It includes both
the left and right limits, and the direction (to or downto).

Regards,
Allan

Shannon
09-02-2007, 05:18 AM
On Sep 1, 9:05 pm, Allan Herriman <[email protected]> wrote:
> On Sun, 02 Sep 2007 02:36:33 -0000, Shannon <[email protected]>
> wrote:
>
>
>
> >On Sep 1, 5:15 pm, "KJ" <[email protected]> wrote:
> >> "Shannon" <[email protected]> wrote in message
>
> >>news:[email protected] ups.com...> The newbie is back!
>
> >> > Why can't I do this:
>
> >> > type table_array IS ARRAY (0 to 16) of STD_LOGIC_VECTOR(11 downto 0);
> >> > signal table: table_array;
> >> > ...
>
> >> > FOR i in 1 to table'RANGE loop
> >> > ...
>
> >> Because the correct syntax is...
> >> FOR i in table'RANGE loop
> >> KJ
>
> >Almost.
>
> >An allowed syntax is:
>
> >FOR i in 1 to 10 Loop
>
> >Correct?
>
> Good so far.
>
> >if table'range = 10 then why couldn't I say
>
> No. table'range isn't "10". It is a range 1 to 10. It includes both
> the left and right limits, and the direction (to or downto).
>
> Regards,
> Allan

Darn! You were too fast for me Allan. I feel so dumb. I thought
RANGE meant "max". I'll just use 'right or 'high. duh...I feel
silly. In my defense I'm trying to code and take care of my two year
old and 11 month old kids at the same time...It has an effect on your
concentration.

Shannon