Re: [sv-bc] Question on foreach loop

From: Gordon Vreugdenhil <gordonv_at_.....>
Date: Fri Nov 17 2006 - 07:08:26 PST
Skipping an iterator allows one to iterate over (effectively)
a set of slices.  In practice I would expect to see this with
the missing index value filled in by either a parameter,
function or task formal, or similar.

For example:

   parameter int my_section = 1;
   bit [3:0][2:1] B [5:1][4];
....
   initial
      foreach( B [ q, r, , s ] )
          B[q][r][my_section][s] = 0;

Gord.




Stuart Sutherland wrote:

> I am having a little difficulty understanding one of the foreach loop
> examples in section 10.5.3 of the LRM.
> 
>   bit [3:0][2:1] B [5:1][4];
>   foreach( B [ q, r, , s ] ) ...
> 
> The LRM states: "The second foreach causes q to iterate from 5 to 1, r from
> 0 to 3, and s from 2 to 1 (iteration over the third index is skipped)".
> 
> I do I read or write into the array if the third index is "skipped"?  It is
> illegal to skip the third index when accessing the array (i.e.:
> B[q][r][][s]), so of what value is skipping one of the iterators?
> 
> Stu
> ~~~~~~~~~~~~~~~~~~~~~~~~~
> Stuart Sutherland
> stuart@sutherland-hdl.com
> +1-503-692-0898
>  
> 
> 

-- 
--------------------------------------------------------------------
Gordon Vreugdenhil                                503-685-0808
Model Technology (Mentor Graphics)                gordonv@model.com
Received on Fri Nov 17 07:08:30 2006

This archive was generated by hypermail 2.1.8 : Fri Nov 17 2006 - 07:09:52 PST