Search code examples
while-loopvhdl

vhdl code (while loop)


description: I would like to write a vhdl while loop that will find the largest integer in an array [A] of 20 integers.

Question:
what should my algorithm look like, to input where the sequential statements are?

My vhdl code:

highnum: WHILE i LOOP
if 
(arr[i]>arr[HighestSoFar]){HighestSoFar=i;}20
i<= i + 1;
end if;
exit;
END LOOP highnum;

This does not need to be synthesizable but I dont know how to form this for loop, in fact im not sure what the syntax would look like. a detailed example explaining how to would be appreciated.


Solution

  • You are requesting examples. Wikibooks has plenty of examples:

    The for loop structure:

    [label:] [WHILE <condition> | FOR <condition>] LOOP
       [statements]
       [exit;]
       [next;]
     END LOOP [label];