36 Chapter Two
some more of the details:
LIBRARY IEEE;
USE IEEE.std_logic_1164.ALL;
ENTITY latch IS
PORT( d, clk : IN std_logic;
q, qb : OUT std_logic);
END latch;
ARCHITECTURE latch_guard OF latch IS
BEGIN
G1 : BLOCK( clk = ‘ 1 ’)
BEGIN
q <= GUARDED d AFTER 5 ns;
qb <= GUARDED NOT(d) AFTER 7 ns;
END BLOCK G1;
END latch_guard;
This model illustrates how a latch model could be written using a
guarded block. This is a very simple-minded model; however, more complex
and more accurate models will be shown later. The entity declares the four
ports needed for the latch, and the architecture has only one statement in
it. The statement is a guarded block statement. A guarded block statement
looks like a typical block statement, except for the guard expression after
the keyword BLOCK. The guard expression in this example is (clk = ‘ 1 ’).
This is a boolean expression that returns TRUEwhen clkis equal to a ‘ 1 ’
value and FALSEwhen clkis equal to any other value.
When the guard expression is true, all of the drivers of guarded signal
assignment statements are enabled, or turned on. When the guard
expression is false, all of the drivers of guarded signal assignment state-
ments are disabled, or turned off. There are two guarded signal assignment
statements in this model: One is the statement that assigns a value to q
and the other is the statement that assigns a value to qb. A guarded signal
assignment statement is recognized by the keyword GUARDEDbetween the
<=and the expression part of the statement.
When port clkof the entity has the value ‘ 1 ’, the guard expression is
true, and the value of input dis scheduled on the qoutput after 5 nano-
seconds, and the NOT value of dis scheduled on the qboutput after 7
nanoseconds. When port clkhas the value ‘ 0 ’or any other legal value
of the type, outputs qand qbturn off and the output value of the signal
is determined by the default value assigned by the resolution function.
When clkis not equal to ‘ 1 ’, the drivers created by the signal assignments
for qand qbin this architecture are effectively turned off. The drivers do
not contribute to the overall value of the signal.
Signal assignments can be guarded by using the keywordGUARDED.A