contents.gifindex.gif

When-Then-Else Keyword

Syntax

[ WHEN condition THEN ] [!] element=expression ;
[ ELSE equation ];
-or-
[ WHEN condition THEN ] equation ;
[ ELSE equation ];

condition - Any valid expression.

element - An identifier naming a signal or set of signals, or an actual set, to which the value of the expression will be assigned.

expression - Any valid expression.

Use

This statement is used in equations. Equations use the four assignment operators = and ?= (combinational or detailed), and := and ?:= (registered pin-to-pin).


Note: Equation blocks used within a conditional expression such as When-Then-Else result in logic functions that are logically ANDed with the conditional expression that is in effect.


CAUTION: When-Then-Else is only supported in equations. Use If-Then-Else for state diagrams.

Example

WHEN B THEN A=B;
ELSE A=C;

WHEN (Mode == S_Data) THEN { Out_data := S_in;
S_Valid := 1;
}
ELSE WHEN (Mode == T_Data) THEN { Out_data := T_in;
T_Valid := 1;
}


See Also

Equations

Equation Blocks