How to use Loop and Exit in VHDL

preview_player
Показать описание
Learn how to to create a loop in VHDL, and how to break out of it. There are several types of loops in VHDL. There is the implicit “process loop”, the While loop, and the For loop. And then there is the simple loop which is just called “Loop”.

Blog post for this video:

The syntax for the Loop statement in VHDL is:
loop
[code to loop through]
end loop;

The syntax for breaking out of a loop in VHDL is:
exit;

The Loop statement will cause the program to loop forever between the “loop” and “end loop;” statements. All kind of loops (except for the implicit process loop) can be broken out of by using the Exit statement.

Loop statements are typically used in testbenches when you want a process to execute some code initially, and then loop forever over some other code.

Example process with initial code:

process is
begin

[code to be executed initially]

wait for 50 ns;

loop
wait until rising_edge(Clk);

[code to be executed forever at every clock cycle]

end loop;
end process;

Loop and Exit statements can combined in testbenches where you want the program to loop over some code, and exit it based on some criteria. The Loop statement is equivalent to the "While true Loop" statement.

Example of process which loops and restarts when some criteria is met:

process is
begin

[code to be executed every time the process restarts]

wait for 50 ns;

loop
wait until rising_edge(Clk);

if [criteria for restarting the process] then
exit;
end if;

[code to be executed every clock cycle]

end loop;
end process;
Рекомендации по теме
Комментарии
Автор

This is an awesome series. You did an amazing job. I love how you just get to the point and show us while you're talking.

eliya
Автор

Your tutorials are incredibly useful and not complicated to follow, unlike even some of the MOOCs that are available online. Thanks for the guidance :)

vishwasacharyan
Автор

Mann just found ur channel today and its a treasure❤

theunknown
Автор

Thank you for some really good tutorials ;)

Timo-iuuc
Автор

Thank you for the tutorial. Very useful.

I have a question, what microphone you’re using? It’s crisp and clear.

Thank you.

adsaci
Автор

Interesting that wait statement is AFTER the report "goodbye" statement yet during runtime, simulation honors the wait statement and waits forever without printing goodbye. That is different behavior from typical programming language, looks like even though you right everything in one file, the process loop is controlled by specific syntaxes and inner loop is controlled by other specific syntaxes

RatedAAliens
Автор

I've been having an issue with the process codes. They don't run the "wait for <amount> <time type>;" line. I'm wondering if it's because the Starter Edition isn't able to utilize Wait For statements. Is that correct?

TotalKaosEntertainment