prepared by P. Bakowski
Sequential statements
VHDL provides a number of constructs used to modify the state of objects such as variables. These modifications are the results of variable assignments. The activation of the assignments is decided by control instructions such as if, case and loop. In principle the variable assignments are (or not) executed in a sequential order following the order of writing (typo logical order) and the results of control instructions.
Variable assignment
A variable is given a new value using an assignment statement called in VHDL sequential assignment. In the assignment expression the target object and the assigned value must have the same base type.
The majority of traditional control instructions used in programming language is present in VHDL. All of these constructs use conditional expressions providing boolean result ('true' or 'false') The simplest control instruction is the if .. then .. end if statement. It may be completed with else (elsif) keywords to allow multiple conditions. More complex constructs such as case - end case or loop - end loop permit to describe multiple tests and loops.
The if statement is used to select one or none of a collection of statements depending on some condition expression Note that conditions are expressions resulting in boolean values. If the condition is evaluated to true, the corresponding statement list is executed. Otherwise, if the else clause is present, the else statement list is executed.
elsif statement
Multiple conditions can be built with if statement followed by elsif clause(s):
The case statement is used to select a collection of statements based on the range of values of a given expression called selection expression. The selection must be of discrete type or a one-dimensional array.
For the matching choice the expression is selected and the statement list executed. All the choices must be distinct and all values must be represented in the choice lists. If some choice is not specified than the default choice must be indicated through the use of others keyword. I
loop statements
A basic loop statement is:
exit and next statements
The next statement terminates execution of the current iteration and starts the subsequent iteration. exit statement terminates execution of the current iteration and terminates the loop. If the when clause is present but the condition is false, the iteration continues normally.
Assertions
The assert statement tests the boolean condition. If this is false, it displays a message containing report string and affects the simulation run if required. The general structure of assertion clause is:
If the severity clause is present the expression must be of the type severity_level: (note, warning, failure, error) . If it is omitted, the default is error .
A simulator may terminate execution if an assertion violation occurs and the severity value is failure or error.
Exercises