Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > VHDL > Re: Nested For Loop incrementation

Reply
Thread Tools

Re: Nested For Loop incrementation

 
 
Ralf Hildebrandt
Guest
Posts: n/a
 
      07-02-2003
Hi Aaron!


> pair_arrayC : FOR col IN 0 TO row_length GENERATE
> CONSTANT pair_inc : INTEGER := pair_inc + 1; --This, of course,
> is wrong
> --but the type of
> thing I'd
> --like to do.



If "pair_inc" only depends on the iteration of the for-loop, the
for-variable "col" ist nearly the same like "pair_inc". -> You can use a
(linear) derivative X*col+Y instead:

Ao(X*col+Y) <= A(row);

where X, Y are constants.

Ralf

 
Reply With Quote
 
 
 
 
Egbert Molenkamp
Guest
Posts: n/a
 
      07-02-2003
I think the 'distance' between the rows is not a constant.
The distance between the same column positions of row 0
and row 1 is 7, between row 1 and row 2 is 6, etc.

Maybe the following function handles the problem.
My synthesis tool has no problem with it.

FUNCTION index(row,col : IN integer) RETURN integer IS
TYPE int_arr_tp IS ARRAY (0 TO 6) OF integer;
CONSTANT lut : int_arr_tp := (0,7,13,18,22,25,27);
BEGIN
RETURN lut(row)+col;
END index;
BEGIN
pair_arrayR : FOR row IN 0 TO 6 GENERATE
CONSTANT row_length : NATURAL := 6 - row;
BEGIN
pair_arrayC : FOR col IN 0 TO row_length GENERATE
BEGIN
AB_Cells : IF (row<4) AND (col<4) GENERATE
Ao(index(row,col)) <= A(row);
Bo(index(row,col)) <= B(3-col);
END GENERATE AB_Cells;
etc.

Egbert Molenkamp


"Ralf Hildebrandt" <(E-Mail Removed)> wrote in message
news:bdurgt$10vlhh$(E-Mail Removed)...
> Hi Aaron!
>
>
> > pair_arrayC : FOR col IN 0 TO row_length GENERATE
> > CONSTANT pair_inc : INTEGER := pair_inc + 1; --This, of course,
> > is wrong
> > --but the type of
> > thing I'd
> > --like to do.

>
>
> If "pair_inc" only depends on the iteration of the for-loop, the
> for-variable "col" ist nearly the same like "pair_inc". -> You can use a
> (linear) derivative X*col+Y instead:
>
> Ao(X*col+Y) <= A(row);
>
> where X, Y are constants.
>
> Ralf
>



 
Reply With Quote
 
 
 
 
Aaron McFarland
Guest
Posts: n/a
 
      07-02-2003
> If "pair_inc" only depends on the iteration of the for-loop, the
> for-variable "col" ist nearly the same like "pair_inc". -> You can use a
> (linear) derivative X*col+Y instead:
>
> Ao(X*col+Y) <= A(row);


Ralf,
Thanks for the reply. It is true that pair_inc can be calculated from
only "row" and "col", but I think the equations are an iterative
summation (or subtraction) looking something like this for each row:

col + 7*row <-- Row 0
col + 7*row 0 <-- Row 1
col + 7*row 1 <-- Row 2
col + 7*row - 2 1 <-- Row 3
col + 7*row 3 - 2 1 <-- Row 4
col + 7*row 4 3 2 1 <-- Row 5
col + 7*row 5 - 4 3 2 1 <-- Row 6

This would create the following values for pair_inc that correspond to
the combinations in the first post.

Col
0 1 2 3 4 5 6
Row --------------------
0 | 0 1 2 3 4 5 6
1 | 7 8 9 10 11 12
2 |13 14 15 16 17
3 |18 19 20 21
4 |22 23 24
5 |25 26
6 |27

Actually, they do not even really need to be in that order, but just
cover 0 to 27 with no bits missing. I need pair_inc to increment for
each iteration of Row *and* Col, not just Col.

--Aaron
 
Reply With Quote
 
Aaron McFarland
Guest
Posts: n/a
 
      07-03-2003
> I think the 'distance' between the rows is not a constant.
> The distance between the same column positions of row 0
> and row 1 is 7, between row 1 and row 2 is 6, etc.


Yes, that is the problem better explained

> Maybe the following function handles the problem.
> My synthesis tool has no problem with it.
>
> FUNCTION index(row,col : IN integer) RETURN integer IS
> TYPE int_arr_tp IS ARRAY (0 TO 6) OF integer;
> CONSTANT lut : int_arr_tp := (0,7,13,18,22,25,27);
> BEGIN
> RETURN lut(row)+col;
> END index;
>
> Egbert Molenkamp


Ah, I hadn't thought of a look up table. I think this should work,
I'll try it as soon as I get a chance tomorrow.

Thanks,
Aaron
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Triple nested loop python (While loop insde of for loop inside ofwhile loop) Isaac Won Python 9 03-04-2013 10:08 AM
About simple confusion of array incrementation sam C++ 4 06-26-2007 04:54 PM
Incrementation Max Java 3 03-23-2007 04:35 PM
Confusing incrementation Petterson Mikael XML 0 09-06-2006 11:40 AM
Variable name incrementation everett C++ 3 02-13-2004 07:12 PM



Advertisments