Sei sulla pagina 1di 9

Lecture 9

Conditional statement (if else)

// In case the condition evaluates to x or z, the false statement is executed


Multiway branching: case statement
Shortcut for if else
Loops:While
Loops: for
while vs. for
for loop is written in concise form
for loop is usually used when the number of iteration cycle
is known
The iteration variable is changed smoothly over a range
while loop is more general
while loop can take any Boolean equation/ expression and
handle complex end conditions
Example:
while (a>(b+c))
begin
.....

b=d/e;
c=d%e;
end
Loop: repeat
Iterates over a fixed number of intervals
Takes a constant or variable.
In case of variable, the variable is evaluated only
at the beginning of the loop
Loop: forever
Continue forever similar to an infinite while
loop, e.g. while (1)
Used in test benches with timing constructs

Potrebbero piacerti anche