please help me with this pc of code

Discussion in 'VHDL' started by mk.supriya@gmail.com, Jul 31, 2007.

  1. Guest

    hello,
    please go through the following code and tell me where i am wrong.
    this is a FOR loop to do some arithmetic operations on a matrix.
    instead of the outermost loop(j), if i assign, 0, 1, 2...etc manually,
    i am able to get the desired result, but when i run this loop, only
    1st row gets the right values. remaining rows, get some very high
    values

    for j in 0 to 2 loop
    temp := 1;
    row1 := hm1(j); -- here if i put 0, 1, w/o j loop, correct result
    for count in 0 to 2 loop
    col := 0;
    tempc := 0;
    while ( col < (temp * 2)) loop
    row2(col) := row1(tempc) + row1(tempc + temp);
    row2(col + 1) := row1(tempc) - row1(tempc + temp);
    tempc := tempc + 1;
    col := col + 2;
    end loop;
    row1 := row2;
    temp := temp * 2;
    end loop;
    hm2(j):= row2;-- here if i put 0, 1, w/o j loop, correct result
    end loop;
    , Jul 31, 2007
    #1
    1. Advertising

  2. Andy Guest

    On Jul 31, 7:15 am, wrote:
    > hello,
    > please go through the following code and tell me where i am wrong.
    > this is a FOR loop to do some arithmetic operations on a matrix.
    > instead of the outermost loop(j), if i assign, 0, 1, 2...etc manually,
    > i am able to get the desired result, but when i run this loop, only
    > 1st row gets the right values. remaining rows, get some very high
    > values
    >
    > for j in 0 to 2 loop
    > temp := 1;
    > row1 := hm1(j); -- here if i put 0, 1, w/o j loop, correct result
    > for count in 0 to 2 loop
    > col := 0;
    > tempc := 0;
    > while ( col < (temp * 2)) loop
    > row2(col) := row1(tempc) + row1(tempc + temp);
    > row2(col + 1) := row1(tempc) - row1(tempc + temp);
    > tempc := tempc + 1;
    > col := col + 2;
    > end loop;
    > row1 := row2;
    > temp := temp * 2;
    > end loop;
    > hm2(j):= row2;-- here if i put 0, 1, w/o j loop, correct result
    > end loop;


    Please read the documentation for your simulator and learn how to use
    break points, monitors, etc. in your simulation.

    Otherwise, instrument your code with assert and/or report statements
    to tell you what's going on as the code executes.

    These are basic code debugging skills that will serve you well in the
    future.

    Andy
    Andy, Jul 31, 2007
    #2
    1. Advertising

  3. Guest

    On Jul 31, 6:10 pm, Andy <> wrote:
    > On Jul 31, 7:15 am, wrote:
    >
    >
    >
    >
    >
    > > hello,
    > > please go through the following code and tell me where i am wrong.
    > > this is a FOR loop to do some arithmetic operations on a matrix.
    > > instead of the outermost loop(j), if i assign, 0, 1, 2...etc manually,
    > > i am able to get the desired result, but when i run this loop, only
    > > 1st row gets the right values. remaining rows, get some very high
    > > values

    >
    > > for j in 0 to 2 loop
    > > temp := 1;
    > > row1 := hm1(j); -- here if i put 0, 1, w/o j loop, correct result
    > > for count in 0 to 2 loop
    > > col := 0;
    > > tempc := 0;
    > > while ( col < (temp * 2)) loop
    > > row2(col) := row1(tempc) + row1(tempc + temp);
    > > row2(col + 1) := row1(tempc) - row1(tempc + temp);
    > > tempc := tempc + 1;
    > > col := col + 2;
    > > end loop;
    > > row1 := row2;
    > > temp := temp * 2;
    > > end loop;
    > > hm2(j):= row2;-- here if i put 0, 1, w/o j loop, correct result
    > > end loop;

    >
    > Please read the documentation for your simulator and learn how to use
    > break points, monitors, etc. in your simulation.


    thanks. i was applying breakpoints and stepping through the code, but
    now i realised that unless i give a wait statement i am not able to
    view the output on my simulation window.
    now i am getting the right output
    , Jul 31, 2007
    #3
    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. Replies:
    4
    Views:
    508
    Chris Uppal
    May 5, 2005
  2. KK
    Replies:
    2
    Views:
    552
    Big Brian
    Oct 14, 2003
  3. MuZZy
    Replies:
    7
    Views:
    1,748
    Mike Hewson
    Jan 7, 2005
  4. Kevin Wan
    Replies:
    5
    Views:
    721
    Kevin Wan
    Jan 17, 2007
  5. mera
    Replies:
    7
    Views:
    1,103
Loading...

Share This Page