CoursVHDL 01process
CoursVHDL 01process
entity IF_else is
port( A,B,C,D: in std_logic;
S: in std_logic_vector (2 downto 0);
o: out std_logic
);
end IF_else;
begin
process (A,B,C,D,S)
begin
if S(0)='1' then
o<=A;
elsif S(1)='1' then
o <=B;
elsif S(2)='1' then
o <=C;
else
o <=D;
end if;
end process;
end Behavioral;
• Avoiding using more than three levels of
if_else statements because the path from the
input to the output will be more and more
longer.
• Longer the path longer the delay (time)
• If statement produces priority-encoded logic
• Multiplexer in cascade.
• Case statement is a series of parallel checks to
check a condition
• Statements following each ‘when’ clause is
evaluated, only if the choice value matches the
expression value.
Does not result a priority logic strucutre unlike if
statement.
Case statement produces parallel logic (one Mux)
Corresponds to the « with ..0 select » in concurrent
statements.
• Generate synchronous logic.
• Example: D-Flip Flop
• Any assignment under a clock generates a
Flip-Flop.
• “if” of clk has not an else.
• We can use if above “if” of the clock
• We can put if clk inside a previous “if else “
block
Any assignment under a clock generates a Flip-Flop.
(clk’ event and clk=‘1) Rising_edge(clk)
These are the same!
• Using if clk inside previous if-else block
okay!
• With nested if_else statement
• Using Variables inside a clocked process:
They used as temporal connections that
need values immediately.
We have to consume all variables inside the
process itself.
We use := to assign variables.
<= is used for ports and signals.
• Remember:
Any assignment under if (clk’event) generates
a FF.
Assignments
Assignments above or outside the if
(clk’event) do not generate FFs.
What hardware will generate the
below code?
AND --- OR --Mux21—Flip Flop
• Incompletely specified conditional expression
infers A LATCH.
• We have to add the else satement if it is
needed.
• If we do not add a nedded else, then, we get a
latch
• Most Synthesizer tools provide warnings
when latches are inferred.
• If we need of that latch design, then, it is okay.
WARNING:Xst:737 - Found 1-
bit latch for signal <Z>.
Latches may be generated
from
incomplete case or if
statements.
We do not recommend the
use of latches in
FPGA/CPLD designs, as they
may lead to timing problems.