for loop problem

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

  1. Guest

    hello,
    i am having a small problem with this pc of code, can anyone help me
    with it.
    during simulation i get an error - Index 8 out of bound 0 to 7 on line
    4

    for count in 0 to 2 loop
    for row in 0 to 7 loop
    tempc := 0;
    for col in 0 to (temp - 1) loop
    mat2(row)(col) <= (mat1(row)(tempc) + mat1(row)(tempc + 1)) / 2;
    mat2(row)(col + temp) <= (mat1(row)(tempc) - mat1(row)(tempc + 1)) /
    2;
    tempc := tempc + 2;
    end loop;
    end loop;
    mat1 <= mat2;
    temp := temp/2;
    end loop;
     
    , Jul 26, 2007
    #1
    1. Advertising

  2. Guest

    On Jul 26, 5:31 pm, wrote:
    > hello,
    > i am having a small problem with this pc of code, can anyone help me
    > with it.
    > during simulation i get an error - Index 8 out of bound 0 to 7 on line
    > 4
    >
    > for count in 0 to 2 loop
    > for row in 0 to 7 loop
    > tempc := 0;
    > for col in 0 to (temp - 1) loop
    > mat2(row)(col) <= (mat1(row)(tempc) + mat1(row)(tempc + 1)) / 2;
    > mat2(row)(col + temp) <= (mat1(row)(tempc) - mat1(row)(tempc + 1)) /
    > 2;
    > tempc := tempc + 2;
    > end loop;
    > end loop;
    > mat1 <= mat2;
    > temp := temp/2;
    > end loop;


    here temp = 4.
    now it is simulating, earlier i had given only temp, when i changed to
    temp - 1 in the for loop it works, but now, even though i had
    initialized mat1 to contain 255, it does not show on the simulator,
    and at the end of the simulation both mat1 and mat2 contain only zeroes
     
    , Jul 26, 2007
    #2
    1. Advertising

  3. In news:
    timestamped Thu, 26 Jul 2007 05:44:21 -0700,
    posted:
    |------------------------------------------------------------------------------|
    |"On Jul 26, 5:31 pm, wrote: |
    |> hello, |
    |> i am having a small problem with this pc of code, can anyone help me |
    |> with it. |
    |> during simulation i get an error - Index 8 out of bound 0 to 7 on line |
    |> 4 |
    |> |
    |> for count in 0 to 2 loop |
    |> for row in 0 to 7 loop |
    |> tempc := 0; |
    |> for col in 0 to (temp - 1) loop |
    |> mat2(row)(col) <= (mat1(row)(tempc) + mat1(row)(tempc + 1)) / 2; |
    |> mat2(row)(col + temp) <= (mat1(row)(tempc) - mat1(row)(tempc + 1)) /|
    |> 2; |
    |> tempc := tempc + 2; |
    |> end loop; |
    |> end loop; |
    |> mat1 <= mat2; |
    |> temp := temp/2; |
    |> end loop; |
    | |
    |here temp = 4. |
    |now it is simulating, earlier i had given only temp, when i changed to |
    |temp - 1 in the for loop it works," |
    |------------------------------------------------------------------------------|

    Hello,

    You have confused me. The code you had showed earlier had temp - 1 so
    can you simulated the code I have quoted above?

    |------------------------------------------------------------------------------|
    |" but now, even though i had |
    |initialized mat1 to contain 255, it does not show on the simulator, |
    |and at the end of the simulation both mat1 and mat2 contain only zeroes" |
    |------------------------------------------------------------------------------|

    This surprises me for a simulation (which simulator are you using?),
    but as synthesis tools will ignore an initialization (by which an
    assignment at the declaration is meant, I am unsure whether your
    unshown code really does that) it is a good idea to not rely on
    initializations anyway.

    Regards,
    Colin Paul Gloster
     
    Colin Paul Gloster, Jul 26, 2007
    #3
  4. Guest

    On Jul 26, 5:59 pm, Colin Paul Gloster <>
    wrote:
    > Innews:
    > timestamped Thu, 26 Jul 2007 05:44:21 -0700,
    > posted:
    > |--------------------------------------------------------------------------­----|
    > |"On Jul 26, 5:31 pm, wrote: |
    > |> hello, |
    > |> i am having a small problem with this pc of code, can anyone help me |
    > |> with it. |
    > |> during simulation i get an error - Index 8 out of bound 0 to 7 on line |
    > |> 4 |
    > |> |
    > |> for count in 0 to 2 loop |
    > |> for row in 0 to 7 loop |
    > |> tempc := 0; |
    > |> for col in 0 to (temp - 1) loop |
    > |> mat2(row)(col) <= (mat1(row)(tempc) + mat1(row)(tempc + 1)) / 2; |
    > |> mat2(row)(col + temp) <= (mat1(row)(tempc) - mat1(row)(tempc + 1)) /|
    > |> 2; |
    > |> tempc := tempc + 2; |
    > |> end loop; |
    > |> end loop; |
    > |> mat1 <= mat2; |
    > |> temp := temp/2; |
    > |> end loop; |
    > | |
    > |here temp = 4. |
    > |now it is simulating, earlier i had given only temp, when i changed to |
    > |temp - 1 in the for loop it works," |
    > |--------------------------------------------------------------------------­----|
    >
    > Hello,
    >
    > You have confused me. The code you had showed earlier had temp - 1 so
    > can you simulated the code I have quoted above?
    >
    > |--------------------------------------------------------------------------­----|
    > |" but now, even though i had |
    > |initialized mat1 to contain 255, it does not show on the simulator, |
    > |and at the end of the simulation both mat1 and mat2 contain only zeroes" |
    > |--------------------------------------------------------------------------­----|
    >
    > This surprises me for a simulation (which simulator are you using?),
    > but as synthesis tools will ignore an initialization (by which an
    > assignment at the declaration is meant, I am unsure whether your
    > unshown code really does that) it is a good idea to not rely on
    > initializations anyway.
    >
    > Regards,
    > Colin Paul Gloster


    i am using xilinx simulator. during synthesis i am planning to store
    data onto the flash and then read from it. but as of now, to analyse
    the problem i split the code, go thru this, now again i am getting
    error index 8 out of bound 0 to 7
    architecture Behavioral of test is
    signal row1, row2: row;
    begin
    process is
    variable tempc, temp: integer;
    constant value1: integer := 255;
    begin
    for i in 0 to 7 loop
    row1(i) <= value1;
    end loop;
    temp := 4;
    tempc := 0;
    for count in 0 to 2 loop
    for i in 0 to (temp-1) loop
    row2(i) <= (row1(tempc) + row1(tempc + 1))/2;
    row2(i + temp) <= (row1(tempc) - row1(tempc + 1)) / 2;
    tempc := tempc + 2;
    end loop;
    temp := temp/2;
    end loop;
    half <= row2;
    wait for 1 ns;
    end process;
    end Behavioral;
     
    , Jul 26, 2007
    #4
  5. wrote:

    > i am using xilinx simulator.


    Consider trying the xilinx oem modelsim simulator.
    -- Mike Treseler
     
    Mike Treseler, Jul 26, 2007
    #5
  6. Guest

    On Jul 26, 6:47 pm, Mike Treseler <> wrote:
    > wrote:
    > > i am using xilinx simulator.

    >
    > Consider trying the xilinx oem modelsim simulator.
    > -- Mike Treseler


    i have to license that
     
    , Jul 26, 2007
    #6
  7. wrote:

    > i have to license that


    If you are doing serious work,
    it might be worth it.

    -- Mike Treseler
     
    Mike Treseler, Jul 26, 2007
    #7
  8. Hello MK,

    I see that you found your index problem.

    I think you should post all of your code.
    I can't figure out what you are trying
    to do. Is it top secret?

    Can we assume that you are using the free
    Xilinx web package. And are you using the
    Xilinx simulator or ModelSimXE?

    Part of your problem might be that when you
    make an <= signal assignment, this schedules
    a change in the signal at a future time. If
    you make another schedule that overwrites it,
    then the first assignment is nullified.

    I would put a "wait for 5 ns" in your inner
    most loop. So you can see the simulation as
    it unfolds.

    Brad Smallridge
    AiVision

    <> wrote in message
    news:...
    > On Jul 26, 5:31 pm, wrote:
    >> hello,
    >> i am having a small problem with this pc of code, can anyone help me
    >> with it.
    >> during simulation i get an error - Index 8 out of bound 0 to 7 on line
    >> 4
    >>
    >> for count in 0 to 2 loop
    >> for row in 0 to 7 loop
    >> tempc := 0;
    >> for col in 0 to (temp - 1) loop
    >> mat2(row)(col) <= (mat1(row)(tempc) + mat1(row)(tempc + 1)) / 2;
    >> mat2(row)(col + temp) <= (mat1(row)(tempc) - mat1(row)(tempc +
    >> 1)) /
    >> 2;
    >> tempc := tempc + 2;
    >> end loop;
    >> end loop;
    >> mat1 <= mat2;
    >> temp := temp/2;
    >> end loop;

    >
    > here temp = 4.
    > now it is simulating, earlier i had given only temp, when i changed to
    > temp - 1 in the for loop it works, but now, even though i had
    > initialized mat1 to contain 255, it does not show on the simulator,
    > and at the end of the simulation both mat1 and mat2 contain only zeroes
    >
     
    Brad Smallridge, Jul 26, 2007
    #8
  9. Guest

    On Jul 26, 11:15 pm, "Brad Smallridge" <>
    wrote:
    > Hello MK,
    >
    > I see that you found your index problem.
    >
    > I think you should post all of your code.
    > I can't figure out what you are trying
    > to do. Is it top secret?
    >
    > Can we assume that you are using the free
    > Xilinx web package. And are you using the
    > Xilinx simulator or ModelSimXE?
    >
    > Part of your problem might be that when you
    > make an <= signal assignment, this schedules
    > a change in the signal at a future time. If
    > you make another schedule that overwrites it,
    > then the first assignment is nullified.
    >
    > I would put a "wait for 5 ns" in your inner
    > most loop. So you can see the simulation as
    > it unfolds.
    >
    > Brad Smallridge
    > AiVision
    >
    > <> wrote in message
    >
    > news:...
    >
    >
    >
    > > On Jul 26, 5:31 pm, wrote:
    > >> hello,
    > >> i am having a small problem with this pc of code, can anyone help me
    > >> with it.
    > >> during simulation i get an error - Index 8 out of bound 0 to 7 on line
    > >> 4

    >
    > >> for count in 0 to 2 loop
    > >> for row in 0 to 7 loop
    > >> tempc := 0;
    > >> for col in 0 to (temp - 1) loop
    > >> mat2(row)(col) <= (mat1(row)(tempc) + mat1(row)(tempc + 1)) / 2;
    > >> mat2(row)(col + temp) <= (mat1(row)(tempc) - mat1(row)(tempc +
    > >> 1)) /
    > >> 2;
    > >> tempc := tempc + 2;
    > >> end loop;
    > >> end loop;
    > >> mat1 <= mat2;
    > >> temp := temp/2;
    > >> end loop;

    >
    > > here temp = 4.
    > > now it is simulating, earlier i had given only temp, when i changed to
    > > temp - 1 in the for loop it works, but now, even though i had
    > > initialized mat1 to contain 255, it does not show on the simulator,
    > > and at the end of the simulation both mat1 and mat2 contain only zeroes- Hide quoted text -

    >
    > - Show quoted text -


    i found a way out. i do have a licensed version of xilinx, and have a
    license for modelsim xe but i havent set it up as yet.
    the problem was:
    i should have put tempc := 0 imediately after the first loop started,
    now my haar twavelet ransformation works. thanks.
     
    , Jul 26, 2007
    #9
    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. =?Utf-8?B?VGltOjouLg==?=

    Loop the loop...

    =?Utf-8?B?VGltOjouLg==?=, Feb 16, 2005, in forum: ASP .Net
    Replies:
    2
    Views:
    1,415
    Karl Seguin
    Feb 16, 2005
  2. Steven

    while loop in a while loop

    Steven, Mar 24, 2005, in forum: Java
    Replies:
    5
    Views:
    2,289
    Tim Slattery
    Mar 30, 2005
  3. -
    Replies:
    12
    Views:
    715
    Remon van Vliet
    Jun 15, 2005
  4. Byte
    Replies:
    4
    Views:
    438
  5. Isaac Won
    Replies:
    9
    Views:
    452
    Ulrich Eckhardt
    Mar 4, 2013
Loading...

Share This Page