Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > VHDL > Incrementing VHDL FOR loop constant by a value other than 1

Reply
Thread Tools

Incrementing VHDL FOR loop constant by a value other than 1

 
 
Josh Graham
Guest
Posts: n/a
 
      04-06-2004
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
 
Reply With Quote
 
 
 
 
Tim Hubberstey
Guest
Posts: n/a
 
      04-06-2004
Josh Graham wrote:
> 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;
--
Tim Hubberstey, P.Eng. . . . . . Hardware/Software Consulting Engineer
Marmot Engineering . . . . . . . VHDL, ASICs, FPGAs, embedded systems
Vancouver, BC, Canada . . . . . . . . . . . http://www.marmot-eng.com

 
Reply With Quote
 
 
 
 
Josh Graham
Guest
Posts: n/a
 
      04-06-2004
Thanks Tim
Josh
 
Reply With Quote
 
Nicolas Matringe
Guest
Posts: n/a
 
      04-07-2004
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;

--
____ _ __ ___
| _ \_)/ _|/ _ \ Adresse de retour invalide: retirez le -
| | | | | (_| |_| | Invalid return address: remove the -
|_| |_|_|\__|\___/

 
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
Count bits in VHDL, with loop and unrolled loop produces different results a s VHDL 16 03-08-2011 05:35 PM
Re: Count bits in VHDL, with loop and unrolled loop producesdifferent results a s VHDL 2 03-04-2011 08:08 PM
Incrementing variable names in a loop? Matt Brooks Ruby 9 09-21-2009 05:28 PM
Incrementing array indexes in for loop. Roger C++ 7 08-26-2007 08:18 AM



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