Incrementing VHDL FOR loop constant by a value other than 1

J

Josh Graham

Hi all,
Is there anyway to increment a for loop constant in VHDL by a value
that is not equal to one? I am processing a vector and in each
iteration two consecutive elements need to be processed and loop
constant incremented by 2.

Thanks
Josh
 
T

Tim Hubberstey

Josh said:
Hi all,
Is there anyway to increment a for loop constant in VHDL by a value
that is not equal to one?

Not that I'm aware of.
I am processing a vector and in each
iteration two consecutive elements need to be processed and loop
constant incremented by 2.

Use a range that is half what you want and then use arithmetic to
generate the values:

for i in start to finish
loop
x(2*i) <= ...
x((2*i)+1) <= ...
end loop;
 
N

Nicolas Matringe

Josh Graham a écrit:
Thanks Tim
Josh

I'm afraid you can't but you can define a second variable that will be a
multiple of your loop variable:

process
variable j : natural range 0 to 56;
begin
for i in 0 to 7 loop
j := 8 * i;
<do whatever you like with j>
end loop;
end process;
 

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

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,905
Latest member
Kristy_Poole

Latest Threads

Top