case(step)
0 : $display ( "starting step” );
1 : $display ( "step number 2" );
2 : $display ( "step 3" );
default : $display ( "undefined step" );
endcase
While Loop
statements in “while” loop executes a code segment as long as the while condition is true. While loop
syntax is shown below:
Example -
count = 0;
while (count < 12)
count = count +3;
end
For Loop
Example -
// This code displays counts from 0 to 30.
for (count= 0; count < 31; count = count +1) begin
$display ( "Count is %d" , count);
end
for (initial; condition; end expression) // first initial will be done, if the condtion is true then
// for loop body is executed and at the end of loop
// execute the end expression.
begin
// for loop body
Statements
end
While (condition) // while condition is true the statements is executed and
// when condition is false, the loop will be terminating.
begin
Statements
end