Data Types 77
delay := 4.5 ns;
ELSIF state = ‘ 0 ’ THEN
delay := 3 ns;
ELSE
delay := 4 ns;
END IF;
q <= state AFTER delay;
END PROCESS;
END and5;
This example is the architecture for a five-input ANDgate. There are two
variable declarations in the process declaration section: one for variable
stateand one for variable delay. Variable stateis used as a tempo-
rary storage area to hold the value of the ANDfunction of the inputs. Tem-
porary-storage value delayis used to hold the delay value that will be
used when scheduling the output value. Both of these values cannot be sta-
tic data because their values depend on the values of inputs a,b,c,d, and
e. Signals could have been used to store the data, but there are several rea-
sons why a signal was not used:
Variables are inherently more efficient because assignments hap-
pen immediately, while signals must be scheduled to occur.
Variables take less memory, while signals need more information
to allow for scheduling and signal attributes.
Using a signal would have required a WAITstatement to synchronize
the signal assignment to the same execution iteration as the usage.
When any of the input signals a,b,c,d, or echange, the process is in-
voked. Variable stateis assigned the ANDof all of the inputs. Next, based
on the value of variable state, variable delayis assigned a delay value.
Based on the delay value assigned to variable delay, output signal qwill
have the value of variable stateassigned to it.
Constants
Constant objects are names assigned to specific values of a type. Constants
give the designer the ability to have a better-documented model, and a
model that is easy to update. For instance, if a model requires a fixed
value in a number of instances, a constant should be used. By using a
constant, the designer can change the value of the constant and recompile,