Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > VHDL > for loop problem

Reply
Thread Tools

for loop problem

 
 
mk.supriya@gmail.com
Guest
Posts: n/a
 
      07-26-2007
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;

 
Reply With Quote
 
 
 
 
mk.supriya@gmail.com
Guest
Posts: n/a
 
      07-26-2007
On Jul 26, 5:31 pm, mk.supr...@gmail.com 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

 
Reply With Quote
 
 
 
 
Colin Paul Gloster
Guest
Posts: n/a
 
      07-26-2007
In news: oups.com
timestamped Thu, 26 Jul 2007 05:44:21 -0700,
posted:
|------------------------------------------------------------------------------|
|"On Jul 26, 5:31 pm, mk.supr...@gmail.com 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
 
Reply With Quote
 
mk.supriya@gmail.com
Guest
Posts: n/a
 
      07-26-2007
On Jul 26, 5:59 pm, Colin Paul Gloster <Colin_Paul_Glos...@ACM.org>
wrote:
> Innews: groups.com
> timestamped Thu, 26 Jul 2007 05:44:21 -0700, mk.supr...@gmail.com
> posted:
> |--------------------------------------------------------------------------*----|
> |"On Jul 26, 5:31 pm, mk.supr...@gmail.com 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;

 
Reply With Quote
 
Mike Treseler
Guest
Posts: n/a
 
      07-26-2007
wrote:

> i am using xilinx simulator.


Consider trying the xilinx oem modelsim simulator.
-- Mike Treseler
 
Reply With Quote
 
mk.supriya@gmail.com
Guest
Posts: n/a
 
      07-26-2007
On Jul 26, 6:47 pm, Mike Treseler <mike_trese...@comcast.net> wrote:
> mk.supr...@gmail.com wrote:
> > i am using xilinx simulator.

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


i have to license that

 
Reply With Quote
 
Mike Treseler
Guest
Posts: n/a
 
      07-26-2007
wrote:

> i have to license that


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

-- Mike Treseler

 
Reply With Quote
 
Brad Smallridge
Guest
Posts: n/a
 
      07-26-2007
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: oups.com...
> On Jul 26, 5:31 pm, mk.supr...@gmail.com 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
>



 
Reply With Quote
 
mk.supriya@gmail.com
Guest
Posts: n/a
 
      07-26-2007
On Jul 26, 11:15 pm, "Brad Smallridge" <bradsmallri...@dslextreme.com>
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
>
> <mk.supr...@gmail.com> wrote in message
>
> news: oups.com...
>
>
>
> > On Jul 26, 5:31 pm, mk.supr...@gmail.com 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.

 
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
Getting a loop to activate a loop above it Byte Python 4 03-24-2006 03:04 AM
Condition outside loop or separate loop for different condition? - Java 12 06-15-2005 08:50 AM
while loop in a while loop Steven Java 5 03-30-2005 09:19 PM
Loop the loop... =?Utf-8?B?VGltOjouLg==?= ASP .Net 2 02-16-2005 12:21 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57