In the previous tutorial we learned how to delay time using the wait for statement. We also learned about the process loop. We now know that if we let it, the process “thread” will loop within the process forever.

But what if we want to do something just once at the beginning of the process? And then loop over some other code at the end? The simplest kind of loop in VHDL can be created by using the loop statement.

This blog post is part of the Basic VHDL Tutorials series.

The syntax for the simple loop is:

end loop;

Such a loop will continue indefinitely, or until an exit; is encountered. The exit statement can be used for breaking out of any loop.


This video tutorial teaches you how to create a simple loop, and how to break out of it:

The final code we created in this tutorial:

entity T03_LoopTb is
end entity;

architecture sim of T03_LoopTb is

    process is
        report "Hello!";
            report "Peekaboo!";
        end loop;
        report "Goodbye!";
    end process;

end architecture;

The output to the simulator console when we pressed the run button in ModelSim:

VSIM 2> run
# ** Note: Hello!
#    Time: 0 ns  Iteration: 0  Instance: /t03_looptb
# ** Note: Peekaboo!
#    Time: 0 ns  Iteration: 0  Instance: /t03_looptb
# ** Note: Goodbye!
#    Time: 0 ns  Iteration: 0  Instance: /t03_looptb

Get exclusive access to exercises and answers!


When running the final code in the simulator we saw that the first “Hello!” was printed to the ModelSim console. Then, the “Peekaboo!” between the loop; and end loop; was printed. On the next line the program hit the exit; statement, causing the program to break out of the loop. Finally, “Goodbye!” was printed. After this nothing more happens because the program is paused forever on the wait; statement.

We can see from the timestamps of the printouts that everything happened at 0 ns simulation time. As we learned from the previous tutorial, everything other than wait statements consume zero time.


  • The loop statement implements an infinite loop
  • The exit statement will break out of any loop

Go to the next tutorial »

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.