46 Chapter Three
q <= I1 AFTER 10 ns;
WHEN 2 =>
q <= I2 AFTER 10 ns;
WHEN 3 =>
q <= I3 AFTER 10 ns;
WHEN OTHERS =>
NULL;
END CASE;
END PROCESS;
END better;
This simple coding difference makes a tremendous operational difference.
When the first statement:
muxval := 0;
is executed, the value 0 is placed in variable muxvalimmediately. The
value is not scheduled because muxval, in this example, is a variable, not
a signal. Variables represent local storage as opposed to signals, which
represent circuit interconnect. The local storage is updated immediately,
and the new value can be used later in the model for further computations.
Because muxvalis initialized to 0 immediately, the next two statements
in the process use 0 as the initial value and add appropriate numbers,
depending on the values of signals aand b. These assignments are also
immediate, and therefore when the CASEstatement executes, variable
muxvalcontains the correct value. From this value, the correct input signal
can be propagated to the output.
Sequential Statements
Sequential statements exist inside the boundaries of a process statement
as well as in subprograms. In this chapter, we are most concerned with
sequential statements inside process statements. In Chapter 5, we discuss
subprograms and the statements contained within them.
The sequential statements that we discuss are:
IF
CASE
LOOP
EXIT
ASSERT
WAIT