ECE 545 Lecture 2 - Part 2: ECE 545 - Introduction To VHDL
ECE 545 Lecture 2 - Part 2: ECE 545 - Introduction To VHDL
Lecture 2 – Part 2
Data Flow
Modeling of
Combinational Logic
Today’s Topic
Combinational
Logic
Combinational …
Logic
Registers
VHDL Design
Styles
Major instructions
Concurrent statements
• concurrent signal assignment ()
• conditional concurrent signal assignment
(when-else)
• selected concurrent signal assignment
(with-select-when)
• generate scheme for equations
(for-generate)
Major instructions
Concurrent statements
• concurrent signal assignment ()
• conditional concurrent signal assignment
(when-else)
• selected concurrent signal assignment
(with-select-when)
• generate scheme for equations
(for-generate)
0 1 1
ci xi yi ci + 1 si
1 1 1
0 0 0 0 0
0 0 1 0 1
s i = x i y i c i
0 1 0 0 1
0 1 1 1 0 xiyi
1 0 0 0 1
ci 00 01 11 10
1 0 1 1 0
1 1 0 1 0 0 1
1 1 1 1 1
1 1 1 1
xi
yi si
ci
ci + 1
(c) Circuit
ECE 545 – Introduction to VHDL 8
Data-flow VHDL: Example (1)
LIBRARY ieee ;
USE ieee.std_logic_1164.all ;
ENTITY fulladd IS
PORT ( x : IN STD_LOGIC ;
y : IN STD_LOGIC ;
cin : IN STD_LOGIC ;
s : OUT STD_LOGIC ;
cout : OUT STD_LOGIC ) ;
END fulladd ;
• Logic operators
and or nand nor xor not xnor
Correct
y <= (a and b) or (c and d) ;
a <= ”0000”;
b <= ”1111”;
c <= a & b; -- c = ”00001111”
e <= ‘0’ & ‘0’ & ‘0’ & ‘0’ & ‘1’ & ‘1’ &
‘1’ & ‘1’; -- e <= ”00001111”
f <= (‘0’,‘0’,‘0’,‘0’,‘1’,‘1’,‘1’,‘1’) ;
-- f <= ”00001111”
a<<<1
LIBRARY ieee;
USE ieee.std_logic_1164.all;
USE ieee.std_logic_unsigned.all;
or
USE ieee.std_logic_signed.all;
Major instructions
Concurrent statements
• concurrent signal assignment ()
• conditional concurrent signal assignment
(when-else)
• selected concurrent signal assignment
(with-select-when)
• generate scheme for equations
(for-generate)
When - Else
target_signal <= value1 when condition1 else
value2 when condition2 else
. . .
valueN-1 when conditionN-1 else
valueN;
0
Value N
1
.… … 0
alue N-1 0
1 Target Signal
1
Value 2
Value 1
Condition N-1
Condition 2
Condition 1
• Relational operators
= /= < <= > >=
compare a = bc
Incorrect
… when a = b and c else …
equivalent to
… when (a = b) and c else …
Correct
… when a = (b and c) else …
LIBRARY ieee;
USE ieee.std_logic_1164.all;
ENTITY tri_state IS
PORT ( ena: IN STD_LOGIC;
input: IN STD_LOGIC_VECTOR(7 downto 0);
output: OUT STD_LOGIC_VECTOR (7 DOWNTO 0)
);
END tri_state;
Major instructions
Concurrent statements
• concurrent signal assignment ()
• conditional concurrent signal assignment
(when-else)
• selected concurrent signal assignment
(with-select-when)
• generate scheme for equations
(for-generate)
With –Select-When
with choice_expression select
target_signal <= expression1 when choices_1,
expression2 when choices_2,
. . .
expressionN when choices_N;
expression1 choices_1
expression2 choices_2
target_signal
expressionN choices_N
choice expression
WHEN value