Forum Discussion
Altera_Forum
Honored Contributor
13 years agoprocesses: while loop does not work, for loop does work. Why?
I want to write this code for a basic synchronous counter more efficiently... u_count: process(rst_i, clk_i) -- generated on rising edge variable i: integer :=1; begin if rst_i = '1' ...
Altera_Forum
Honored Contributor
13 years agoAs far as I know, it is almost always discouraged to write a while loop, if it is possible to make it a for loop, in any language.
This is because it is easy to make a mistake with a while loop, so that it never ends, software nor hardware will like this. Ofcourse you could also write a neverending forloop, but a forloop always has at least some exit statement. So wether it compiles or not, if you can write it as a for loop, just do.