Re: Nested For Loop incrementation

Discussion in 'VHDL' started by Ralf Hildebrandt, Jul 2, 2003.

  1. 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
    Ralf Hildebrandt, Jul 2, 2003
    #1
    1. Advertising

  2. 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" <> wrote in message
    news:bdurgt$10vlhh$...
    > 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
    >
    Egbert Molenkamp, Jul 2, 2003
    #2
    1. Advertising

  3. > 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
    Aaron McFarland, Jul 2, 2003
    #3
  4. > 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
    Aaron McFarland, Jul 3, 2003
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. everett

    Variable name incrementation

    everett, Feb 13, 2004, in forum: C++
    Replies:
    3
    Views:
    424
    Jon Bell
    Feb 13, 2004
  2. Petterson Mikael

    Confusing incrementation

    Petterson Mikael, Sep 6, 2006, in forum: XML
    Replies:
    0
    Views:
    393
    Petterson Mikael
    Sep 6, 2006
  3. Max

    Incrementation

    Max, Mar 23, 2007, in forum: Java
    Replies:
    3
    Views:
    367
  4. sam
    Replies:
    4
    Views:
    312
    Andre Kostur
    Jun 26, 2007
  5. Isaac Won
    Replies:
    9
    Views:
    372
    Ulrich Eckhardt
    Mar 4, 2013
Loading...

Share This Page