Microsoft Word - Digital Logic Design v_4_6a

(lily) #1
F <= ‘1’ when “0001”,
‘1’ when “0010”,
‘1’ when “0011” | “0101” | “0111”,
‘1’ when “1011” | “1101”,
‘0’ when others;
end prime2_arch;

 Sequential “If-then-else” statement
This sequential statement will give us the ability to make decisions, based on the value of a Boolean-
expression to execute a sequential statement or not.


 Syntax of “If-then-else” statement simple to fully nested

if Boolean-expression then sequential-statement -- do only on true
end if;

if Boolean-expression then sequential-statement -- handle true and false
else sequential-statement
end if;

if Boolean-expression then sequential-statement -- nested if statements
elsif Boolean-expression then sequential-statement
...
elsif Boolean-expression then sequential-statement
end if;

if Boolean-expression then sequential-statement
elsif Boolean-expression then sequential-statement
...
elsif Boolean-expression then sequential-statement
else sequential-statement -- catch all else
end if;

 Example – using “If-then-else” statements to implement the prime number detector

architecture prime5_arch of prime is
begin
process(N)
variable NI: Integer;
begin
NI :=CONV_INTEGER(N);
if NI=1 or NI=2 then F <= ‘1’;
elsif NI=3 or NI=5 or NI=7 or NI=11 or NI=13 then F <= ‘1’;
else F <= ‘0’;
end if;
end process;
end prime5_arch;

 Sequential “Case” statement
This statement evaluates the given expression, finds a matching value in one of the choices, and
executes the corresponding sequential-statements.


Note: Choice may take multiple values using vertical bar operator “|”

 Syntax
case expression is
Free download pdf