Home > VHDL > Concurrent Statements > When Statement
Conditional Signal Assignments (When Statement)� : When a Conditional Signal Assignment Statement is run the Boolean expressions are checked. ������� The value of the expression preceded to WHEN keyword is assigned.��� If Boolean expressions are not true, ELSE keyword is assigned.� The syntax is : ����������������� Signal_name <= { expression when condition else } �������������������������� expression; � Example 1 : �������� ENTITY sig IS ����������������� PORT�������� (input0, input1, sel: IN STD_LOGIC; �������������������������� output : OUT STD_LOGIC); �������� END condsig; �������� ARCHITECTURE behave OF sig IS �������� BEGIN ����������������� output <= input0 WHEN sel = '0' ELSE input1;������������ �������� END behave; � Example 2 : �������� ENTITY sigm IS ����������������� PORT�������� (high, mid, low: IN STD_LOGIC; �������������������������� q: OUT INTEGER); �������� END sigm; �������� ARCHITECTURE behave OF sigm IS �������� BEGIN �������� Q <=� 3 WHEN high = '1' ELSE ����������������� 2 WHEN mid� = '1' ELSE ����������������� 1 WHEN low� = '1' ELSE ����������������� 0;���������������������������������� �������� END behave;