Download as pdf or txt
Download as pdf or txt
You are on page 1of 4

CMSC 132 Comments

LATCHES AND FLIP-FLOPS • The WAIT statement has three conditional parts that may be combined: ON that
detects value changes, UNTIL that verifies a logical expression and FOR that limits in
time (timeout).
• A WAIT statement may exist without a condition and will then never be passed.
SEQUENTIAL STATEMENTS • A variable does not have an event and does therefore not work in a WAIT ON
WAIT statement. For the same reason expressions without signals do not work in a
WAIT UNTIL statement. Such WAIT statements are suspended forever.
IF • Most synthesis tools accept just one WAIT statement for each process. The number
is unlimited for simulation.
CASE • At simulation start every process executes until it reaches its first WAIT statement.
PROCESS
WHEN

WAIT
Syntax IF
[ label ‘:’ ] wait [ on sensitivity-list ] [ until boolean-expression ] SYNTAX
[ for time-expression ] ‘;’
[ if-label ‘:’ ] if boolean-expression then
sensitivity-list –› signal-name { ‘,’ signal-name }
{ sequential-statement }
{ elsif boolean-expression then
Examples { sequential-statement } }
SIGNAL s, p : BIT; [ else {sequential-statement } ]
... end if [ if-label ] ‘;’
VARIABLE v : BIT;
VARIABLE t : TIME;
...
EXAMPLES
WAIT ON s; -- Wait for value changes on s PROCESS(reset,clk)
WAIT ON s UNTIL s = ‘1’; -- Wait for a rising edge on s BEGIN
WAIT UNTIL s = ‘1’; -- Wait for a rising edge on s IF reset = ‘1’ THEN
WAIT; -- Never passed ...
WAIT UNTIL v; -- Never passed ELSIF clk’EVENT AND clk = ‘1’ THEN
WAIT UNTIL NOW = t; -- Never passed ...
WAIT ON s UNTIL p = ‘1’ FOR t; -- Wait for value changes on s, END IF;
-- then verify that p = ‘1’, or END PROCESS;
-- wait at maximum the time t ANDgate: IF en = ‘1’ THEN
-- (timeout) q <= d;
WAIT FOR 10 ns; -- Pass WAIT after 10 ns ELSE
WAIT FOR t - NOW; -- Pass WAIT after the time t q <= ‘0’;
-- minus current simulation time END IF;
Latch: IF en = ‘1’ THEN
q <= d;
END IF;
IF a = Func(i*2#01001001#) THEN
...
END IF;

COMMENTS
• All conditions in an IF statement must be of the type BOOLEAN.
• The syntax for the IF statement is quite odd – ELSIF is spelled as one word
without an intermediate ’E’. END IF is two separate words.
CASE SYNTAX
SYNTAX [ process-label ‘:’ ] [ postponed ] process [ ‘(’ sensitivity-list ‘)’ ] [ is ]
{ subprogram-decl. | subprogram-body | type-decl. | subtype-decl. |
[ case-label ‘:’ ] case expression is constant-decl. | variable-decl. | file-decl. | alias-decl. | attribute-decl. |
when choices ‘=>’ { sequential-statement } attribute-spec. | use-clause | group-template-decl. | group-decl. }
{ when choices ‘=>’ { sequential-statement } begin
} { sequential-statement }
end case [ case-label ] ‘;’ end [ postponed ] process [ process-label ] ‘;’
choices –› choice { | choice }

EXAMPLES
PROCESS EXAMPLES
BEGIN
WAIT ON number; ARCHITECTURE Behave OF Design IS
CASE number IS BEGIN
WHEN 0 => ... -- When ”number” is 0 FlipFlop: PROCESS(reset,clk)
WHEN 2 | 5 | 243 => ... -- When ”number” is 2, 5 or 243 BEGIN
WHEN 6 TO 18 => ... -- In the interval 6 to 18 IF reset = ‘1’ THEN
WHEN OTHERS => NULL; -- At all other values, do nothing q <= ‘0’;
END CASE; ELSIF clk’EVENT AND clk = ‘1’ THEN
END PROCESS; q <= d;
SIGNAL s : STD_ULOGIC; END IF;
... END PROCESS FlipFlop;
CASE s IS END ARCHITECTURE Behave;
WHEN ‘0’ => ... -- These two processes are equivalent
WHEN ‘1’ => ... PROCESS PROCESS(s)
WHEN OTHERS => NULL; -- Must exist (or a compilation error BEGIN BEGIN
-- will occur) REPORT ”s has a new value”; REPORT ”s has a new value”;
END CASE; WAIT ON s; END PROCESS;
END PROCESS;

COMMENTS
COMMENTS
• The CASE statement must specify all possible values of the expression. If not all
possible values are covered, a compilation error will occur. OTHERS may be used to • A PROCESS holds a number of sequential statements and executes parallel towards
cover ”all other values”. its environment.
• The expression can be of an integer type, an enumerated type or a one-dimensional • A PROCESS functions as an eternal loop. It must include at least one WAIT
array with elements written as characters (for example STRING, BIT_VECTOR, statement or a sensitivity list that specifies when the PROCESS shall
STD_LOGIC_VECTOR etc.). execute its sequential statements.
• Note that the types STD_LOGIC and STD_ULOGIC have more possible values than • A sensitivity list is equivalent to a WAIT ON statement placed as the final line in the
‘0’ and ‘1’. They must also be included in the CASE statement (see above). PROCESS. All sequential statements will execute once at simulation startup in such
• The reserved word NULL is useful in combination with OTHERS. Together they processes and after that the processes will suspend.
specify that ”at all other values nothing shall happen”. • POSTPONED defines that the PROCESS shall be executed as the final delta at a
specific occasion.

WHEN
SYNTAX

PROCESS
[ label ‘:’ ] [ postponed ] ( signal-name | signal-aggregate ) ‘<=’
[ guarded ] [ delay-mechanism ]
{ waveform when boolean-expression else } Combinational Logic Circuit
waveform [ when boolean-expression ] ‘;’ output is dependent on the inputs
delay-mechanism –› transport | [ reject time-expression ] inertial
waveform –› waveform-element { ‘,’ waveform-element } | unaffected
waveform-element –› ( value-expression | null ) [ after time-expression ]
Sequential Logic Circuit
systems which include memory elements that are capable
EXAMPLES of storing binary information
-- This architecture contains three processes. ”One” is an
-- ordinary process including a sequential signal assignment
-- while ”Two” and ”Three” are concurrent signal assignments 2 Main Types (Timing of Signals)
ARCHITECTURE Behave OF Design IS
BEGIN 1. Synchronous
One: PROCESS(data)
BEGIN 1. behaviour is defined from the knowledge of its signal at
outputSignal <= data;
END PROCESS One; discrete instance of time
Two: s <= ‘1’ WHEN sel = ”00” ELSE
UNAFFECTED WHEN sel = ”11” ELSE
2. Asynchronous
‘0’;
Three: s2 <= REJECT 3 ns INERTIAL d AFTER 5 ns;
1. depends upon the order in which its input signals
END ARCHITECTURE Behave;
MyBlock: BLOCK(en = ‘1’)
change and can be affected at any instance of time
BEGIN
Latch: q <= GUARDED d;
END BLOCK MyBlock; SEQUENTIAL CIRCUITS
COMMENTS Flip-flop
• A concurrent signal assignment is placed directly in an ARCHITECTURE or in a D
BLOCK without using a PROCESS. JK
• A concurrent signal assignment may preferably be named with a label. This label
simplifies simulation since the assignment then can be identified just as a named SR
PROCESS.
• The WHEN statement is the concurrent equivalent to the sequential IF statement. T
• UNAFFECTED is new to VHDL’93 and may be used to specify that a signal Latches
shall be left unaffected at a specific occasion, i.e. to keep its previous value.
D
JK
SR
T
D FLIP-FLOP and LATCH VHDL CODE

The D latch is used to capture, or ``latch'' the logic level which is http://esd.cs.ucr.edu/labs/tutorial/tb_ckt.vhd
present on the Data line when the clock input is high. If the data on
the line changes state while the clock pulse is high, then the
output,Q, follows the input, D.
The D flip-flop, while a slightly more complicated circuit, performs a
function very similar to the D latch. In the case of the D flip-flop,
however, the rising edge of the clock pulse is used to ``capture'' the
input to the flip flop. This device is very useful when it is necessary
to ``capture'' a logic level on a line which is very rapidly varying.
This type of device is said to be ``edge triggered'' -- either rising
edge triggered (i.e. a 0-1 transition) or falling edge triggered (i.e., a
1-0 transition) devices are available.

You might also like