Добавил:
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
ЛО САПР / VHDL.PDF
Скачиваний:
43
Добавлен:
17.04.2013
Размер:
5.27 Mб
Скачать

Sequential Statements

If several values are assigned to a given signal in one process, only the last assignment is effective. Even if a signal in a process is assigned, read, and reassigned, the value read (either inside or outside the process) is the last assignment value.

If several processes (or other concurrent statements) assign values to one signal, the drivers are wired together. The resulting circuit depends on the expressions and the target technology. The circuit might be invalid, wired AND, wired OR, or a three-state bus. See the “Concurrent Statements” chapter for more information.

 

 

 

The following example shows the different effects of variable and

 

 

 

signal assignments.

 

 

signal S1,

S2: BIT;

 

 

signal S_OUT:

 

BIT_VECTOR(1 to 8);

 

 

. . .

 

 

 

 

 

process( S1, S2 )

 

 

 

variable

V1,

V2: BIT;

 

 

begin

 

 

 

 

 

V1

:= ’1’;

--

This sets the value of V1

 

 

V2

:= ’1’;

--

This sets the value of V2

 

 

S1

<= ’1’;

--

This assignment is the driver for S1

S2

<= ’1’;

--

This has no effect because of the

 

 

 

 

--

assignment later in this process

 

S_OUT(1)

<= V1;

-- Assigns ’1’, the value

assigned

above

S_OUT(2)

<= V2;

-- Assigns ’1’, the value

assigned

above

S_OUT(3)

<= S1;

-- Assigns ’1’, the value

assigned

above

S_OUT(4)

<= S2;

-- Assigns ’0’, the value

assigned

below

V1

:= ’0’;

--

This sets the new value of V1

 

V2

:= ’0’;

--

This sets the new value of V2

 

S2

<= ’0’;

--

This assignment overrides

the previous one since it is

 

 

 

--

the last assignment to this signal

in this process

S_OUT(5)

<= V1;

-- Assigns ’0’, the value

assigned

above

S_OUT(6)

<= V2;

-- Assigns ’0’, the value

assigned

above

S_OUT(7)

<= S1;

-- Assigns ’1’, the value

assigned

above

S_OUT(8)

<= S2;

-- Assigns ’0’, the value

assigned

above

end process;

if Statements

The if statement executes a sequence of statements. The sequence depends on the value of one or more conditions. The syntax follows.

VHDL Reference Guide

5-9

VHDL Reference Guide

if condition then

 

[

{ sequential_statement }

 

elsif condition

then ]

{sequential_statement }

[ else

{sequential_statement } ]

end if;

Each condition must be a Boolean expression. Each branch of an if statement can have one or more sequential_statements.

Evaluating Conditions

An if statement evaluates each condition in order. Only the first true condition causes the execution of the if statement’s branch statements. The remainder of the if statement is skipped.

If none of the conditions is true and the else clause is present, those statements are executed. If none of the conditions is true and no else clause is present, none of the statements is executed.

The following example shows an if statement. The figure following the example illustrates the corresponding circuit.

signal A, B, C, P1, P2, Z: BIT;

if (P1 = ’1’) then Z <= A;

elsif (P2 = ’0’) then Z <= B;

else

Z <= C; end if;

Figure 5-2 Schematic Design for if Statement

5-10

Xilinx Development System

Соседние файлы в папке ЛО САПР