for loop problem

M

mk.supriya

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;
 
M

mk.supriya

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
 
C

Colin Paul Gloster

In timestamped Thu, 26 Jul 2007 05:44:21 -0700, (e-mail address removed)
posted:
|------------------------------------------------------------------------------|
|"On Jul 26, 5:31 pm, (e-mail address removed) 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
 
M

mk.supriya

Intimestamped Thu, 26 Jul 2007 05:44:21 -0700, (e-mail address removed)
posted:
|--------------------------------------------------------------------------­----|
|"On Jul 26, 5:31 pm, (e-mail address removed) 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;
 
B

Brad Smallridge

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
 
M

mk.supriya

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







- 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.
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,236
Members
46,822
Latest member
israfaceZa

Latest Threads

Top