ECE 448 Lecture 3 Combinational-Circuit Building...
Transcript of ECE 448 Lecture 3 Combinational-Circuit Building...
![Page 1: ECE 448 Lecture 3 Combinational-Circuit Building …ece.gmu.edu/coursewebpages/ECE/ECE448/S15/viewgraphs/ECE...ECE 448 – FPGA and ASIC Design with VHDL George Mason University Combinational-Circuit](https://reader034.fdocuments.net/reader034/viewer/2022051508/5aae372d7f8b9a5d0a8bd61f/html5/thumbnails/1.jpg)
George Mason University ECE 448 – FPGA and ASIC Design with VHDL
Combinational-Circuit Building Blocks
Data Flow Modeling of
Combinational Logic
ECE 448 Lecture 3
![Page 2: ECE 448 Lecture 3 Combinational-Circuit Building …ece.gmu.edu/coursewebpages/ECE/ECE448/S15/viewgraphs/ECE...ECE 448 – FPGA and ASIC Design with VHDL George Mason University Combinational-Circuit](https://reader034.fdocuments.net/reader034/viewer/2022051508/5aae372d7f8b9a5d0a8bd61f/html5/thumbnails/2.jpg)
2 ECE 448 – FPGA and ASIC Design with VHDL
Reading
• S. Brown and Z. Vranesic, Fundamentals of Digital Logic with VHDL Design Chapter 6, Combinational-Circuit Building Blocks Chapter 5.5, Design of Arithmetic Circuits Using CAD Tools
• P. Chu, FPGA Prototyping by VHDL Examples Chapter 3, RT-level combinational circuit Sections 3.1, 3.2, 3.3, 3.6, 3.7.1, 3.7.3.
Required
Recommended
![Page 3: ECE 448 Lecture 3 Combinational-Circuit Building …ece.gmu.edu/coursewebpages/ECE/ECE448/S15/viewgraphs/ECE...ECE 448 – FPGA and ASIC Design with VHDL George Mason University Combinational-Circuit](https://reader034.fdocuments.net/reader034/viewer/2022051508/5aae372d7f8b9a5d0a8bd61f/html5/thumbnails/3.jpg)
3 ECE 448 – FPGA and ASIC Design with VHDL
Types of VHDL Description (Modeling Styles)
![Page 4: ECE 448 Lecture 3 Combinational-Circuit Building …ece.gmu.edu/coursewebpages/ECE/ECE448/S15/viewgraphs/ECE...ECE 448 – FPGA and ASIC Design with VHDL George Mason University Combinational-Circuit](https://reader034.fdocuments.net/reader034/viewer/2022051508/5aae372d7f8b9a5d0a8bd61f/html5/thumbnails/4.jpg)
4 ECE 448 – FPGA and ASIC Design with VHDL
Types of VHDL Description
Components and interconnects
structural
VHDL Descriptions
dataflow
Concurrent statements
behavioral
• Registers • State machines • Instruction decoders
Sequential statements
Subset most suitable for synthesis
• Testbenches
![Page 5: ECE 448 Lecture 3 Combinational-Circuit Building …ece.gmu.edu/coursewebpages/ECE/ECE448/S15/viewgraphs/ECE...ECE 448 – FPGA and ASIC Design with VHDL George Mason University Combinational-Circuit](https://reader034.fdocuments.net/reader034/viewer/2022051508/5aae372d7f8b9a5d0a8bd61f/html5/thumbnails/5.jpg)
5 ECE 448 – FPGA and ASIC Design with VHDL
Synthesizable VHDL
Dataflow VHDL VHDL code
synthesizable
VHDL code synthesizable
Dataflow VHDL
![Page 6: ECE 448 Lecture 3 Combinational-Circuit Building …ece.gmu.edu/coursewebpages/ECE/ECE448/S15/viewgraphs/ECE...ECE 448 – FPGA and ASIC Design with VHDL George Mason University Combinational-Circuit](https://reader034.fdocuments.net/reader034/viewer/2022051508/5aae372d7f8b9a5d0a8bd61f/html5/thumbnails/6.jpg)
6 ECE 448 – FPGA and ASIC Design with VHDL
Data-Flow VHDL
• concurrent signal assignment (⇐)
• conditional concurrent signal assignment (when-else)
• selected concurrent signal assignment (with-select-when)
Concurrent Statements
![Page 7: ECE 448 Lecture 3 Combinational-Circuit Building …ece.gmu.edu/coursewebpages/ECE/ECE448/S15/viewgraphs/ECE...ECE 448 – FPGA and ASIC Design with VHDL George Mason University Combinational-Circuit](https://reader034.fdocuments.net/reader034/viewer/2022051508/5aae372d7f8b9a5d0a8bd61f/html5/thumbnails/7.jpg)
7 ECE 448 – FPGA and ASIC Design with VHDL
Concurrent signal assignment
target_signal <= expression;
<=
![Page 8: ECE 448 Lecture 3 Combinational-Circuit Building …ece.gmu.edu/coursewebpages/ECE/ECE448/S15/viewgraphs/ECE...ECE 448 – FPGA and ASIC Design with VHDL George Mason University Combinational-Circuit](https://reader034.fdocuments.net/reader034/viewer/2022051508/5aae372d7f8b9a5d0a8bd61f/html5/thumbnails/8.jpg)
8 ECE 448 – FPGA and ASIC Design with VHDL
Conditional concurrent signal assignment
target_signal <= value1 when condition1 else value2 when condition2 else . . . valueN-1 when conditionN-1 else valueN;
When - Else
![Page 9: ECE 448 Lecture 3 Combinational-Circuit Building …ece.gmu.edu/coursewebpages/ECE/ECE448/S15/viewgraphs/ECE...ECE 448 – FPGA and ASIC Design with VHDL George Mason University Combinational-Circuit](https://reader034.fdocuments.net/reader034/viewer/2022051508/5aae372d7f8b9a5d0a8bd61f/html5/thumbnails/9.jpg)
9 ECE 448 – FPGA and ASIC Design with VHDL
Selected concurrent signal assignment
with choice_expression select target_signal <= expression1 when choices_1, expression2 when choices_2, . . . expressionN when choices_N;
With –Select-When
![Page 10: ECE 448 Lecture 3 Combinational-Circuit Building …ece.gmu.edu/coursewebpages/ECE/ECE448/S15/viewgraphs/ECE...ECE 448 – FPGA and ASIC Design with VHDL George Mason University Combinational-Circuit](https://reader034.fdocuments.net/reader034/viewer/2022051508/5aae372d7f8b9a5d0a8bd61f/html5/thumbnails/10.jpg)
10 ECE 448 – FPGA and ASIC Design with VHDL
Modeling Wires and Buses
![Page 11: ECE 448 Lecture 3 Combinational-Circuit Building …ece.gmu.edu/coursewebpages/ECE/ECE448/S15/viewgraphs/ECE...ECE 448 – FPGA and ASIC Design with VHDL George Mason University Combinational-Circuit](https://reader034.fdocuments.net/reader034/viewer/2022051508/5aae372d7f8b9a5d0a8bd61f/html5/thumbnails/11.jpg)
11 ECE 448 – FPGA and ASIC Design with VHDL
Signals
SIGNAL a : STD_LOGIC;
SIGNAL b : STD_LOGIC_VECTOR(7 DOWNTO 0);
wire
a
bus
b
1
8
![Page 12: ECE 448 Lecture 3 Combinational-Circuit Building …ece.gmu.edu/coursewebpages/ECE/ECE448/S15/viewgraphs/ECE...ECE 448 – FPGA and ASIC Design with VHDL George Mason University Combinational-Circuit](https://reader034.fdocuments.net/reader034/viewer/2022051508/5aae372d7f8b9a5d0a8bd61f/html5/thumbnails/12.jpg)
12 ECE 448 – FPGA and ASIC Design with VHDL
Merging wires and buses
SIGNAL a: STD_LOGIC_VECTOR(3 DOWNTO 0); SIGNAL b: STD_LOGIC_VECTOR(4 DOWNTO 0); SIGNAL c: STD_LOGIC; SIGNAL d: STD_LOGIC_VECTOR(9 DOWNTO 0); d <= a & b & c;
4
5
10
a
b
c d = a || b || c
![Page 13: ECE 448 Lecture 3 Combinational-Circuit Building …ece.gmu.edu/coursewebpages/ECE/ECE448/S15/viewgraphs/ECE...ECE 448 – FPGA and ASIC Design with VHDL George Mason University Combinational-Circuit](https://reader034.fdocuments.net/reader034/viewer/2022051508/5aae372d7f8b9a5d0a8bd61f/html5/thumbnails/13.jpg)
13 ECE 448 – FPGA and ASIC Design with VHDL
Splitting buses
SIGNAL a: STD_LOGIC_VECTOR(3 DOWNTO 0); SIGNAL b: STD_LOGIC_VECTOR(4 DOWNTO 0); SIGNAL c: STD_LOGIC; SIGNAL d: STD_LOGIC_VECTOR(9 DOWNTO 0); a <= d(9 downto 6); b <= d(5 downto 1); c <= d(0);
4
5
10
a = d9..6
b = d5..1
c = d0
d
![Page 14: ECE 448 Lecture 3 Combinational-Circuit Building …ece.gmu.edu/coursewebpages/ECE/ECE448/S15/viewgraphs/ECE...ECE 448 – FPGA and ASIC Design with VHDL George Mason University Combinational-Circuit](https://reader034.fdocuments.net/reader034/viewer/2022051508/5aae372d7f8b9a5d0a8bd61f/html5/thumbnails/14.jpg)
14 ECE 448 – FPGA and ASIC Design with VHDL
Combinational-Circuit Building Blocks
![Page 15: ECE 448 Lecture 3 Combinational-Circuit Building …ece.gmu.edu/coursewebpages/ECE/ECE448/S15/viewgraphs/ECE...ECE 448 – FPGA and ASIC Design with VHDL George Mason University Combinational-Circuit](https://reader034.fdocuments.net/reader034/viewer/2022051508/5aae372d7f8b9a5d0a8bd61f/html5/thumbnails/15.jpg)
15 ECE 448 – FPGA and ASIC Design with VHDL
Fixed Shifters & Rotators
![Page 16: ECE 448 Lecture 3 Combinational-Circuit Building …ece.gmu.edu/coursewebpages/ECE/ECE448/S15/viewgraphs/ECE...ECE 448 – FPGA and ASIC Design with VHDL George Mason University Combinational-Circuit](https://reader034.fdocuments.net/reader034/viewer/2022051508/5aae372d7f8b9a5d0a8bd61f/html5/thumbnails/16.jpg)
16 ECE 448 – FPGA and ASIC Design with VHDL
Fixed Logical Shift Right in VHDL
A(3) A(2) A(1) A(0)
‘0’ A(3) A(2) A(1)
SIGNAL A : STD_LOGIC_VECTOR(3 DOWNTO 0); SIGNAL C: STD_LOGIC_VECTOR(3 DOWNTO 0);
A
C = '0' & A(3 downto 1);
C
4
4
A
C >>1
L
![Page 17: ECE 448 Lecture 3 Combinational-Circuit Building …ece.gmu.edu/coursewebpages/ECE/ECE448/S15/viewgraphs/ECE...ECE 448 – FPGA and ASIC Design with VHDL George Mason University Combinational-Circuit](https://reader034.fdocuments.net/reader034/viewer/2022051508/5aae372d7f8b9a5d0a8bd61f/html5/thumbnails/17.jpg)
17 ECE 448 – FPGA and ASIC Design with VHDL
Fixed Arithmetic Shift Right in VHDL
A(3) A(2) A(1) A(0)
A(3) A(2) A(1)
SIGNAL A : STD_LOGIC_VECTOR(3 DOWNTO 0); SIGNAL C: STD_LOGIC_VECTOR(3 DOWNTO 0);
A
C
4
4
A
C >>1
A(3)
A
C = A(3) & A(3 downto 1);
![Page 18: ECE 448 Lecture 3 Combinational-Circuit Building …ece.gmu.edu/coursewebpages/ECE/ECE448/S15/viewgraphs/ECE...ECE 448 – FPGA and ASIC Design with VHDL George Mason University Combinational-Circuit](https://reader034.fdocuments.net/reader034/viewer/2022051508/5aae372d7f8b9a5d0a8bd61f/html5/thumbnails/18.jpg)
18 ECE 448 – FPGA and ASIC Design with VHDL
Fixed Logical Shift Left in VHDL
A(3) A(2) A(1) A(0)
SIGNAL A : STD_LOGIC_VECTOR(3 DOWNTO 0); SIGNAL C: STD_LOGIC_VECTOR(3 DOWNTO 0);
A
C
4
4
A
C <<1
L
A(2) A(1) A(0) ‘0’
C = A(2 downto 0) & '0';
![Page 19: ECE 448 Lecture 3 Combinational-Circuit Building …ece.gmu.edu/coursewebpages/ECE/ECE448/S15/viewgraphs/ECE...ECE 448 – FPGA and ASIC Design with VHDL George Mason University Combinational-Circuit](https://reader034.fdocuments.net/reader034/viewer/2022051508/5aae372d7f8b9a5d0a8bd61f/html5/thumbnails/19.jpg)
19 ECE 448 – FPGA and ASIC Design with VHDL
Fixed Rotation Left in VHDL
A(3) A(2) A(1) A(0)
A(2) A(1) A(0) A(3)
SIGNAL A : STD_LOGIC_VECTOR(3 DOWNTO 0); SIGNAL C: STD_LOGIC_VECTOR(3 DOWNTO 0);
A 4
4
A
C <<< 1
C
C = A(2 downto 0) & A(3);
![Page 20: ECE 448 Lecture 3 Combinational-Circuit Building …ece.gmu.edu/coursewebpages/ECE/ECE448/S15/viewgraphs/ECE...ECE 448 – FPGA and ASIC Design with VHDL George Mason University Combinational-Circuit](https://reader034.fdocuments.net/reader034/viewer/2022051508/5aae372d7f8b9a5d0a8bd61f/html5/thumbnails/20.jpg)
20 ECE 448 – FPGA and ASIC Design with VHDL
Variable Rotators
![Page 21: ECE 448 Lecture 3 Combinational-Circuit Building …ece.gmu.edu/coursewebpages/ECE/ECE448/S15/viewgraphs/ECE...ECE 448 – FPGA and ASIC Design with VHDL George Mason University Combinational-Circuit](https://reader034.fdocuments.net/reader034/viewer/2022051508/5aae372d7f8b9a5d0a8bd61f/html5/thumbnails/21.jpg)
21 ECE 448 – FPGA and ASIC Design with VHDL
8-bit Variable Rotator Left
8
8
3
A
B
C
A <<< B
To be covered during one of the future classes
![Page 22: ECE 448 Lecture 3 Combinational-Circuit Building …ece.gmu.edu/coursewebpages/ECE/ECE448/S15/viewgraphs/ECE...ECE 448 – FPGA and ASIC Design with VHDL George Mason University Combinational-Circuit](https://reader034.fdocuments.net/reader034/viewer/2022051508/5aae372d7f8b9a5d0a8bd61f/html5/thumbnails/22.jpg)
22 ECE 448 – FPGA and ASIC Design with VHDL
Gates
![Page 23: ECE 448 Lecture 3 Combinational-Circuit Building …ece.gmu.edu/coursewebpages/ECE/ECE448/S15/viewgraphs/ECE...ECE 448 – FPGA and ASIC Design with VHDL George Mason University Combinational-Circuit](https://reader034.fdocuments.net/reader034/viewer/2022051508/5aae372d7f8b9a5d0a8bd61f/html5/thumbnails/23.jpg)
23 ECE 448 – FPGA and ASIC Design with VHDL
x 1 x 2
x n
x 1 x 2 … x n + + + x 1 x 2 x 1 x 2 +
x 1 x 2
x n
x 1 x 2 x 1 x 2 ⋅ x 1 x 2 … x n ⋅ ⋅ ⋅
(a) AND gates
(b) OR gates
x x
(c) NOT gate
Basic Gates – AND, OR, NOT
![Page 24: ECE 448 Lecture 3 Combinational-Circuit Building …ece.gmu.edu/coursewebpages/ECE/ECE448/S15/viewgraphs/ECE...ECE 448 – FPGA and ASIC Design with VHDL George Mason University Combinational-Circuit](https://reader034.fdocuments.net/reader034/viewer/2022051508/5aae372d7f8b9a5d0a8bd61f/html5/thumbnails/24.jpg)
24 ECE 448 – FPGA and ASIC Design with VHDL
x 1 x 2
x n
x 1 x 2 … x n + + + x 1 x 2
x 1 x 2 +
x 1 x 2
x n
x 1 x 2
x 1 x 2 ⋅ x 1 x 2 … x n ⋅ ⋅ ⋅
(a) NAND gates
(b) NOR gates
Basic Gates – NAND, NOR
…
…
![Page 25: ECE 448 Lecture 3 Combinational-Circuit Building …ece.gmu.edu/coursewebpages/ECE/ECE448/S15/viewgraphs/ECE...ECE 448 – FPGA and ASIC Design with VHDL George Mason University Combinational-Circuit](https://reader034.fdocuments.net/reader034/viewer/2022051508/5aae372d7f8b9a5d0a8bd61f/html5/thumbnails/25.jpg)
25 ECE 448 – FPGA and ASIC Design with VHDL
x
x 1 x 2
x 1
x 2
x 1 x 2
x 1 x 2
x 1
x 2
x 1 x 2
x 1 x 2 1 x 2 + = (a)
x 1 x 2 + x 1 x 2 = (b)
DeMorgan’s Theorem and other symbols for NAND, NOR
![Page 26: ECE 448 Lecture 3 Combinational-Circuit Building …ece.gmu.edu/coursewebpages/ECE/ECE448/S15/viewgraphs/ECE...ECE 448 – FPGA and ASIC Design with VHDL George Mason University Combinational-Circuit](https://reader034.fdocuments.net/reader034/viewer/2022051508/5aae372d7f8b9a5d0a8bd61f/html5/thumbnails/26.jpg)
26 ECE 448 – FPGA and ASIC Design with VHDL
Basic Gates – XOR
(b) Graphical symbol (a) Truth table
0 0 1 1
0 1 0 1
0 1 1 0
x 1 x 2
x 1 x 2
f x 1 x 2 ⊕ =
f x 1 x 2 ⊕ =
(c) Sum-of-products implementation
f x 1 x 2 ⊕ =
x 1 x 2
![Page 27: ECE 448 Lecture 3 Combinational-Circuit Building …ece.gmu.edu/coursewebpages/ECE/ECE448/S15/viewgraphs/ECE...ECE 448 – FPGA and ASIC Design with VHDL George Mason University Combinational-Circuit](https://reader034.fdocuments.net/reader034/viewer/2022051508/5aae372d7f8b9a5d0a8bd61f/html5/thumbnails/27.jpg)
27 ECE 448 – FPGA and ASIC Design with VHDL
Basic Gates – XNOR
(b) Graphical symbol (a) Truth table
0 0 1 1
0 1 0 1
1 0 0 1
x 1 x 2
x 1 x 2
f x 1 x 2 ⊕ =
f x 1 x 2 ⊕ =
(c) Sum-of-products implementation
f x 1 x 2 ⊕ =
x 1 x 2
x 1 x 2 = .
![Page 28: ECE 448 Lecture 3 Combinational-Circuit Building …ece.gmu.edu/coursewebpages/ECE/ECE448/S15/viewgraphs/ECE...ECE 448 – FPGA and ASIC Design with VHDL George Mason University Combinational-Circuit](https://reader034.fdocuments.net/reader034/viewer/2022051508/5aae372d7f8b9a5d0a8bd61f/html5/thumbnails/28.jpg)
28 ECE 448 – FPGA and ASIC Design with VHDL
Data-flow VHDL: Example
x y
cin s
cout
![Page 29: ECE 448 Lecture 3 Combinational-Circuit Building …ece.gmu.edu/coursewebpages/ECE/ECE448/S15/viewgraphs/ECE...ECE 448 – FPGA and ASIC Design with VHDL George Mason University Combinational-Circuit](https://reader034.fdocuments.net/reader034/viewer/2022051508/5aae372d7f8b9a5d0a8bd61f/html5/thumbnails/29.jpg)
29 ECE 448 – FPGA and ASIC Design with VHDL
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 ;
![Page 30: ECE 448 Lecture 3 Combinational-Circuit Building …ece.gmu.edu/coursewebpages/ECE/ECE448/S15/viewgraphs/ECE...ECE 448 – FPGA and ASIC Design with VHDL George Mason University Combinational-Circuit](https://reader034.fdocuments.net/reader034/viewer/2022051508/5aae372d7f8b9a5d0a8bd61f/html5/thumbnails/30.jpg)
30 ECE 448 – FPGA and ASIC Design with VHDL
Data-flow VHDL: Example (2)
ARCHITECTURE dataflow OF fulladd IS BEGIN
s <= x XOR y XOR cin ; cout <= (x AND y) OR (cin AND x) OR (cin AND y) ;
END dataflow ;
![Page 31: ECE 448 Lecture 3 Combinational-Circuit Building …ece.gmu.edu/coursewebpages/ECE/ECE448/S15/viewgraphs/ECE...ECE 448 – FPGA and ASIC Design with VHDL George Mason University Combinational-Circuit](https://reader034.fdocuments.net/reader034/viewer/2022051508/5aae372d7f8b9a5d0a8bd61f/html5/thumbnails/31.jpg)
31 ECE 448 – FPGA and ASIC Design with VHDL
Logic Operators
• Logic operators
• Logic operators precedence
and or nand nor xor not xnor
not and or nand nor xor xnor
Highest
Lowest
only in VHDL-93
![Page 32: ECE 448 Lecture 3 Combinational-Circuit Building …ece.gmu.edu/coursewebpages/ECE/ECE448/S15/viewgraphs/ECE...ECE 448 – FPGA and ASIC Design with VHDL George Mason University Combinational-Circuit](https://reader034.fdocuments.net/reader034/viewer/2022051508/5aae372d7f8b9a5d0a8bd61f/html5/thumbnails/32.jpg)
32 ECE 448 – FPGA and ASIC Design with VHDL
Wanted: y = ab + cd Incorrect y <= a and b or c and d ; equivalent to y <= ((a and b) or c) and d ; equivalent to y = (ab + c)d Correct y <= (a and b) or (c and d) ;
No Implied Precedence
![Page 33: ECE 448 Lecture 3 Combinational-Circuit Building …ece.gmu.edu/coursewebpages/ECE/ECE448/S15/viewgraphs/ECE...ECE 448 – FPGA and ASIC Design with VHDL George Mason University Combinational-Circuit](https://reader034.fdocuments.net/reader034/viewer/2022051508/5aae372d7f8b9a5d0a8bd61f/html5/thumbnails/33.jpg)
33 ECE 448 – FPGA and ASIC Design with VHDL
Multiplexers
![Page 34: ECE 448 Lecture 3 Combinational-Circuit Building …ece.gmu.edu/coursewebpages/ECE/ECE448/S15/viewgraphs/ECE...ECE 448 – FPGA and ASIC Design with VHDL George Mason University Combinational-Circuit](https://reader034.fdocuments.net/reader034/viewer/2022051508/5aae372d7f8b9a5d0a8bd61f/html5/thumbnails/34.jpg)
34 ECE 448 – FPGA and ASIC Design with VHDL
2-to-1 Multiplexer
(a) Graphical symbol (b) Truth table
0
1
f s
w 0
w 1
f
s
w 0
w 1
0
1
VHDL: f <= w0 WHEN s = '0' ELSE w1 ; or
f <= w1 WHEN s = ‘1' ELSE w0 ;
![Page 35: ECE 448 Lecture 3 Combinational-Circuit Building …ece.gmu.edu/coursewebpages/ECE/ECE448/S15/viewgraphs/ECE...ECE 448 – FPGA and ASIC Design with VHDL George Mason University Combinational-Circuit](https://reader034.fdocuments.net/reader034/viewer/2022051508/5aae372d7f8b9a5d0a8bd61f/html5/thumbnails/35.jpg)
35 ECE 448 – FPGA and ASIC Design with VHDL
VHDL code for a 2-to-1 Multiplexer Entity
LIBRARY ieee ; USE ieee.std_logic_1164.all ; ENTITY mux2to1 IS
PORT ( w0, w1, s : IN STD_LOGIC ; f : OUT STD_LOGIC ) ;
END mux2to1 ; ARCHITECTURE dataflow OF mux2to1 IS BEGIN
f <= w0 WHEN s = '0' ELSE w1 ; END dataflow ;
![Page 36: ECE 448 Lecture 3 Combinational-Circuit Building …ece.gmu.edu/coursewebpages/ECE/ECE448/S15/viewgraphs/ECE...ECE 448 – FPGA and ASIC Design with VHDL George Mason University Combinational-Circuit](https://reader034.fdocuments.net/reader034/viewer/2022051508/5aae372d7f8b9a5d0a8bd61f/html5/thumbnails/36.jpg)
36 ECE 448 – FPGA and ASIC Design with VHDL
Cascade of two multiplexers
s1
w 3
w 1
0
1
s2
w 2
0
1 y
f <= w1 WHEN s1 = ‘1' ELSE w2 WHEN s2 = ‘1’ ELSE w3 ;
VHDL:
![Page 37: ECE 448 Lecture 3 Combinational-Circuit Building …ece.gmu.edu/coursewebpages/ECE/ECE448/S15/viewgraphs/ECE...ECE 448 – FPGA and ASIC Design with VHDL George Mason University Combinational-Circuit](https://reader034.fdocuments.net/reader034/viewer/2022051508/5aae372d7f8b9a5d0a8bd61f/html5/thumbnails/37.jpg)
37 ECE 448 – FPGA and ASIC Design with VHDL
VHDL design entity implementing a cascade of two multiplexers
LIBRARY ieee ; USE ieee.std_logic_1164.all ; ENTITY mux_cascade IS
PORT ( w1, w2, w3: IN STD_LOGIC ; s1, s2 : IN STD_LOGIC ; f : OUT STD_LOGIC ) ;
END mux_cascade ; ARCHITECTURE dataflow OF mux2to1 IS BEGIN
f <= w1 WHEN s1 = ‘1' ELSE w2 WHEN s2 = ‘1’ ELSE w3 ; END dataflow ;
![Page 38: ECE 448 Lecture 3 Combinational-Circuit Building …ece.gmu.edu/coursewebpages/ECE/ECE448/S15/viewgraphs/ECE...ECE 448 – FPGA and ASIC Design with VHDL George Mason University Combinational-Circuit](https://reader034.fdocuments.net/reader034/viewer/2022051508/5aae372d7f8b9a5d0a8bd61f/html5/thumbnails/38.jpg)
38 ECE 448 – FPGA and ASIC Design with VHDL
Operators
• Relational operators
• Logic and relational operators precedence
= /= < <= > >=
not = /= < <= > >= and or nand nor xor xnor
Highest
Lowest
![Page 39: ECE 448 Lecture 3 Combinational-Circuit Building …ece.gmu.edu/coursewebpages/ECE/ECE448/S15/viewgraphs/ECE...ECE 448 – FPGA and ASIC Design with VHDL George Mason University Combinational-Circuit](https://reader034.fdocuments.net/reader034/viewer/2022051508/5aae372d7f8b9a5d0a8bd61f/html5/thumbnails/39.jpg)
39 ECE 448 – FPGA and ASIC Design with VHDL
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 …
Priority of logic and relational operators
![Page 40: ECE 448 Lecture 3 Combinational-Circuit Building …ece.gmu.edu/coursewebpages/ECE/ECE448/S15/viewgraphs/ECE...ECE 448 – FPGA and ASIC Design with VHDL George Mason University Combinational-Circuit](https://reader034.fdocuments.net/reader034/viewer/2022051508/5aae372d7f8b9a5d0a8bd61f/html5/thumbnails/40.jpg)
40 ECE 448 – FPGA and ASIC Design with VHDL
(b) Truth table
f
s 1
w 0
w 1
00
01
s 0
w 2
w 3
10
11
w 0
w 1
0
0
1
1
1
0
1
f s 1
0
s 0
w 2
w 3
(a) Graphic symbol
4-to-1 Multiplexer
WITH s SELECT f <= w0 WHEN "00", w1 WHEN "01", w2 WHEN "10", w3 WHEN OTHERS ;
s
![Page 41: ECE 448 Lecture 3 Combinational-Circuit Building …ece.gmu.edu/coursewebpages/ECE/ECE448/S15/viewgraphs/ECE...ECE 448 – FPGA and ASIC Design with VHDL George Mason University Combinational-Circuit](https://reader034.fdocuments.net/reader034/viewer/2022051508/5aae372d7f8b9a5d0a8bd61f/html5/thumbnails/41.jpg)
41 ECE 448 – FPGA and ASIC Design with VHDL
VHDL code for a 4-to-1 Multiplexer entity
LIBRARY ieee ; USE ieee.std_logic_1164.all ; ENTITY mux4to1 IS
PORT ( w0, w1, w2, w3 : IN STD_LOGIC ; s : IN STD_LOGIC_VECTOR(1 DOWNTO 0) ; f : OUT STD_LOGIC ) ;
END mux4to1 ; ARCHITECTURE dataflow OF mux4to1 IS BEGIN
WITH s SELECT f <= w0 WHEN "00", w1 WHEN "01", w2 WHEN "10", w3 WHEN OTHERS ;
END dataflow ;
![Page 42: ECE 448 Lecture 3 Combinational-Circuit Building …ece.gmu.edu/coursewebpages/ECE/ECE448/S15/viewgraphs/ECE...ECE 448 – FPGA and ASIC Design with VHDL George Mason University Combinational-Circuit](https://reader034.fdocuments.net/reader034/viewer/2022051508/5aae372d7f8b9a5d0a8bd61f/html5/thumbnails/42.jpg)
42 ECE 448 – FPGA and ASIC Design with VHDL
Decoders
![Page 43: ECE 448 Lecture 3 Combinational-Circuit Building …ece.gmu.edu/coursewebpages/ECE/ECE448/S15/viewgraphs/ECE...ECE 448 – FPGA and ASIC Design with VHDL George Mason University Combinational-Circuit](https://reader034.fdocuments.net/reader034/viewer/2022051508/5aae372d7f8b9a5d0a8bd61f/html5/thumbnails/43.jpg)
43 ECE 448 – FPGA and ASIC Design with VHDL
2-to-4 Decoder
0
0
1
1
1
0
1
y 3
w 1
0
w 0
x x
1
1
0
1
1
En
0
0
1
0
0
y 2
0
1
0
0
0
y 1
1
0
0
0
0
y 0
0
0
0
1
0
(a) Truth table
(b) Graphical symbol
w 1
En
y 3
w 0
y 2
y 1
y 0
w
y
Enw <= En & w ; WITH Enw SELECT y <= "0001" WHEN "100", "0010" WHEN "101",
"0100" WHEN "110", "1000" WHEN "111", "0000" WHEN OTHERS ;
![Page 44: ECE 448 Lecture 3 Combinational-Circuit Building …ece.gmu.edu/coursewebpages/ECE/ECE448/S15/viewgraphs/ECE...ECE 448 – FPGA and ASIC Design with VHDL George Mason University Combinational-Circuit](https://reader034.fdocuments.net/reader034/viewer/2022051508/5aae372d7f8b9a5d0a8bd61f/html5/thumbnails/44.jpg)
44 ECE 448 – FPGA and ASIC Design with VHDL
VHDL code for a 2-to-4 Decoder entity LIBRARY ieee ; USE ieee.std_logic_1164.all ; ENTITY dec2to4 IS
PORT ( w : IN STD_LOGIC_VECTOR(1 DOWNTO 0) ; En : IN STD_LOGIC ; y : OUT STD_LOGIC_VECTOR(3 DOWNTO 0) ) ;
END dec2to4 ; ARCHITECTURE dataflow OF dec2to4 IS
SIGNAL Enw : STD_LOGIC_VECTOR(2 DOWNTO 0) ; BEGIN
Enw <= En & w ; WITH Enw SELECT y <= "0001" WHEN "100", "0010" WHEN "101", "0100" WHEN "110", "1000" WHEN "111", "0000" WHEN OTHERS ;
END dataflow ;
![Page 45: ECE 448 Lecture 3 Combinational-Circuit Building …ece.gmu.edu/coursewebpages/ECE/ECE448/S15/viewgraphs/ECE...ECE 448 – FPGA and ASIC Design with VHDL George Mason University Combinational-Circuit](https://reader034.fdocuments.net/reader034/viewer/2022051508/5aae372d7f8b9a5d0a8bd61f/html5/thumbnails/45.jpg)
45 ECE 448 – FPGA and ASIC Design with VHDL
Encoders
![Page 46: ECE 448 Lecture 3 Combinational-Circuit Building …ece.gmu.edu/coursewebpages/ECE/ECE448/S15/viewgraphs/ECE...ECE 448 – FPGA and ASIC Design with VHDL George Mason University Combinational-Circuit](https://reader034.fdocuments.net/reader034/viewer/2022051508/5aae372d7f8b9a5d0a8bd61f/html5/thumbnails/46.jpg)
46 ECE 448 – FPGA and ASIC Design with VHDL
Priority Encoder
w 0
w 3
y 0 y 1
d 0 0 1
0 1 0
w 0 y 1 d
y 0
1 1
0 1
1
1 1
z
1 - -
0
-
w 1
0 1 -
0
-
w 2
0 0 1
0
-
w 3
0 0 0
0
1
z
w 1 w 2 w
y y <= "11" WHEN w(3) = '1' ELSE "10" WHEN w(2) = '1' ELSE "01" WHEN w(1) = '1' ELSE "00" ; z <= '0' WHEN w = "0000" ELSE '1' ;
![Page 47: ECE 448 Lecture 3 Combinational-Circuit Building …ece.gmu.edu/coursewebpages/ECE/ECE448/S15/viewgraphs/ECE...ECE 448 – FPGA and ASIC Design with VHDL George Mason University Combinational-Circuit](https://reader034.fdocuments.net/reader034/viewer/2022051508/5aae372d7f8b9a5d0a8bd61f/html5/thumbnails/47.jpg)
47 ECE 448 – FPGA and ASIC Design with VHDL
VHDL code for a Priority Encoder entity LIBRARY ieee ; USE ieee.std_logic_1164.all ; ENTITY priority IS
PORT ( w : IN STD_LOGIC_VECTOR(3 DOWNTO 0) ; y : OUT STD_LOGIC_VECTOR(1 DOWNTO 0) ; z : OUT STD_LOGIC ) ;
END priority ; ARCHITECTURE dataflow OF priority IS BEGIN
y <= "11" WHEN w(3) = '1' ELSE "10" WHEN w(2) = '1' ELSE "01" WHEN w(1) = '1' ELSE "00" ; z <= '0' WHEN w = "0000" ELSE '1' ;
END dataflow ;
![Page 48: ECE 448 Lecture 3 Combinational-Circuit Building …ece.gmu.edu/coursewebpages/ECE/ECE448/S15/viewgraphs/ECE...ECE 448 – FPGA and ASIC Design with VHDL George Mason University Combinational-Circuit](https://reader034.fdocuments.net/reader034/viewer/2022051508/5aae372d7f8b9a5d0a8bd61f/html5/thumbnails/48.jpg)
48 ECE 448 – FPGA and ASIC Design with VHDL
Adders
![Page 49: ECE 448 Lecture 3 Combinational-Circuit Building …ece.gmu.edu/coursewebpages/ECE/ECE448/S15/viewgraphs/ECE...ECE 448 – FPGA and ASIC Design with VHDL George Mason University Combinational-Circuit](https://reader034.fdocuments.net/reader034/viewer/2022051508/5aae372d7f8b9a5d0a8bd61f/html5/thumbnails/49.jpg)
49 ECE 448 – FPGA and ASIC Design with VHDL
16-bit Unsigned Adder
16 16
X Y
16
Cin Cout S +
![Page 50: ECE 448 Lecture 3 Combinational-Circuit Building …ece.gmu.edu/coursewebpages/ECE/ECE448/S15/viewgraphs/ECE...ECE 448 – FPGA and ASIC Design with VHDL George Mason University Combinational-Circuit](https://reader034.fdocuments.net/reader034/viewer/2022051508/5aae372d7f8b9a5d0a8bd61f/html5/thumbnails/50.jpg)
50 ECE 448 – FPGA and ASIC Design with VHDL
Operations on Unsigned Numbers For operations on unsigned numbers USE ieee.std_logic_unsigned.all and signals of the type STD_LOGIC_VECTOR OR USE ieee.numeric_std.all and signals of the type UNSIGNED and conversion functions: std_logic_vector(), unsigned()
![Page 51: ECE 448 Lecture 3 Combinational-Circuit Building …ece.gmu.edu/coursewebpages/ECE/ECE448/S15/viewgraphs/ECE...ECE 448 – FPGA and ASIC Design with VHDL George Mason University Combinational-Circuit](https://reader034.fdocuments.net/reader034/viewer/2022051508/5aae372d7f8b9a5d0a8bd61f/html5/thumbnails/51.jpg)
51 ECE 448 – FPGA and ASIC Design with VHDL
VHDL code for a 16-bit Unsigned Adder
LIBRARY ieee ; USE ieee.std_logic_1164.all ; USE ieee.std_logic_unsigned.all ; ENTITY adder16 IS
PORT ( Cin : IN STD_LOGIC ; X : IN STD_LOGIC_VECTOR(15 DOWNTO 0) ; Y : IN STD_LOGIC_VECTOR(15 DOWNTO 0) ; S : OUT STD_LOGIC_VECTOR(15 DOWNTO 0) ; Cout : OUT STD_LOGIC ) ;
END adder16 ; ARCHITECTURE dataflow OF adder16 IS
SIGNAL Sum : STD_LOGIC_VECTOR(16 DOWNTO 0) ; BEGIN
Sum <= ('0' & X) + Y + Cin ; S <= Sum(15 DOWNTO 0) ; Cout <= Sum(16) ;
END dataflow ;
![Page 52: ECE 448 Lecture 3 Combinational-Circuit Building …ece.gmu.edu/coursewebpages/ECE/ECE448/S15/viewgraphs/ECE...ECE 448 – FPGA and ASIC Design with VHDL George Mason University Combinational-Circuit](https://reader034.fdocuments.net/reader034/viewer/2022051508/5aae372d7f8b9a5d0a8bd61f/html5/thumbnails/52.jpg)
52 ECE 448 – FPGA and ASIC Design with VHDL
Addition of Unsigned Numbers (1)
LIBRARY ieee ; USE ieee.std_logic_1164.all ; USE ieee.numeric_std.all ; ENTITY adder16 IS
PORT ( Cin : IN STD_LOGIC ; X : IN STD_LOGIC_VECTOR(15 DOWNTO 0) ; Y : IN STD_LOGIC_VECTOR(15 DOWNTO 0) ; S : OUT STD_LOGIC_VECTOR(15 DOWNTO 0) ; Cout : OUT STD_LOGIC ) ;
END adder16 ;
![Page 53: ECE 448 Lecture 3 Combinational-Circuit Building …ece.gmu.edu/coursewebpages/ECE/ECE448/S15/viewgraphs/ECE...ECE 448 – FPGA and ASIC Design with VHDL George Mason University Combinational-Circuit](https://reader034.fdocuments.net/reader034/viewer/2022051508/5aae372d7f8b9a5d0a8bd61f/html5/thumbnails/53.jpg)
53 ECE 448 – FPGA and ASIC Design with VHDL
Addition of Unsigned Numbers (2) ARCHITECTURE dataflow OF adder16 IS SIGNAL Xu : UNSIGNED(15 DOWNTO 0); SIGNAL Yu: UNSIGNED(15 DOWNTO 0);
SIGNAL Su : UNSIGNED(16 DOWNTO 0) ; BEGIN
Xu <= unsigned(X); Yu <= unsigned(Y);
Su <= ('0' & Xu) + Yu + unsigned(std_logic_vector' ('0' & Cin)) ; S <= std_logic_vector(Su(15 DOWNTO 0)) ; Cout <= Su(16) ;
END dataflow ;
![Page 54: ECE 448 Lecture 3 Combinational-Circuit Building …ece.gmu.edu/coursewebpages/ECE/ECE448/S15/viewgraphs/ECE...ECE 448 – FPGA and ASIC Design with VHDL George Mason University Combinational-Circuit](https://reader034.fdocuments.net/reader034/viewer/2022051508/5aae372d7f8b9a5d0a8bd61f/html5/thumbnails/54.jpg)
54 ECE 448 – FPGA and ASIC Design with VHDL
Addition of Unsigned Numbers (3) ARCHITECTURE dataflow OF adder16 IS signal Sum: STD_LOGIC_VECTOR(16 DOWNTO 0) ; BEGIN
Sum <= std_logic_vector( unsigned('0' & X) + unsigned(Y) + unsigned(std_logic_vector' ('0' & Cin)) ) ; S <= Sum(15 downto 0);
Cout <= Sum(16) ; END dataflow ;
![Page 55: ECE 448 Lecture 3 Combinational-Circuit Building …ece.gmu.edu/coursewebpages/ECE/ECE448/S15/viewgraphs/ECE...ECE 448 – FPGA and ASIC Design with VHDL George Mason University Combinational-Circuit](https://reader034.fdocuments.net/reader034/viewer/2022051508/5aae372d7f8b9a5d0a8bd61f/html5/thumbnails/55.jpg)
55 ECE 448 – FPGA and ASIC Design with VHDL
Operations on Signed Numbers
For operations on signed numbers USE ieee.numeric_std.all, signals of the type SIGNED, and conversion functions: std_logic_vector(), signed() OR USE ieee.std_logic_signed.all and signals of the type STD_LOGIC_VECTOR
![Page 56: ECE 448 Lecture 3 Combinational-Circuit Building …ece.gmu.edu/coursewebpages/ECE/ECE448/S15/viewgraphs/ECE...ECE 448 – FPGA and ASIC Design with VHDL George Mason University Combinational-Circuit](https://reader034.fdocuments.net/reader034/viewer/2022051508/5aae372d7f8b9a5d0a8bd61f/html5/thumbnails/56.jpg)
56 ECE 448 – FPGA and ASIC Design with VHDL
Signed and Unsigned Types
Behave exactly like STD_LOGIC_VECTOR plus, they determine whether a given vector should be treated as a signed or unsigned number. Require USE ieee.numeric_std.all;
![Page 57: ECE 448 Lecture 3 Combinational-Circuit Building …ece.gmu.edu/coursewebpages/ECE/ECE448/S15/viewgraphs/ECE...ECE 448 – FPGA and ASIC Design with VHDL George Mason University Combinational-Circuit](https://reader034.fdocuments.net/reader034/viewer/2022051508/5aae372d7f8b9a5d0a8bd61f/html5/thumbnails/57.jpg)
57 ECE 448 – FPGA and ASIC Design with VHDL
Multipliers
![Page 58: ECE 448 Lecture 3 Combinational-Circuit Building …ece.gmu.edu/coursewebpages/ECE/ECE448/S15/viewgraphs/ECE...ECE 448 – FPGA and ASIC Design with VHDL George Mason University Combinational-Circuit](https://reader034.fdocuments.net/reader034/viewer/2022051508/5aae372d7f8b9a5d0a8bd61f/html5/thumbnails/58.jpg)
58 ECE 448 – FPGA and ASIC Design with VHDL
Unsigned vs. Signed Multiplication
1111 1111 x
11100001
15 15 x
225
1111 1111 x
00000001
-1 -1 x
1
Unsigned Signed
![Page 59: ECE 448 Lecture 3 Combinational-Circuit Building …ece.gmu.edu/coursewebpages/ECE/ECE448/S15/viewgraphs/ECE...ECE 448 – FPGA and ASIC Design with VHDL George Mason University Combinational-Circuit](https://reader034.fdocuments.net/reader034/viewer/2022051508/5aae372d7f8b9a5d0a8bd61f/html5/thumbnails/59.jpg)
59 ECE 448 – FPGA and ASIC Design with VHDL
8x8-bit Unsigned Multiplier
8 8
a b
16
c U *
![Page 60: ECE 448 Lecture 3 Combinational-Circuit Building …ece.gmu.edu/coursewebpages/ECE/ECE448/S15/viewgraphs/ECE...ECE 448 – FPGA and ASIC Design with VHDL George Mason University Combinational-Circuit](https://reader034.fdocuments.net/reader034/viewer/2022051508/5aae372d7f8b9a5d0a8bd61f/html5/thumbnails/60.jpg)
60 ECE 448 – FPGA and ASIC Design with VHDL
Multiplication of unsigned numbers
LIBRARY ieee; USE ieee.std_logic_1164.all; USE ieee.std_logic_unsigned.all ; entity multiply is
port( a : in STD_LOGIC_VECTOR(7 downto 0); b : in STD_LOGIC_VECTOR(7 downto 0); c : out STD_LOGIC_VECTOR(15 downto 0) );
end multiply; architecture dataflow of multiply is begin
c <= a * b; end dataflow;
![Page 61: ECE 448 Lecture 3 Combinational-Circuit Building …ece.gmu.edu/coursewebpages/ECE/ECE448/S15/viewgraphs/ECE...ECE 448 – FPGA and ASIC Design with VHDL George Mason University Combinational-Circuit](https://reader034.fdocuments.net/reader034/viewer/2022051508/5aae372d7f8b9a5d0a8bd61f/html5/thumbnails/61.jpg)
61 ECE 448 – FPGA and ASIC Design with VHDL
8x8-bit Signed Multiplier
8 8
a b
16
c S *
![Page 62: ECE 448 Lecture 3 Combinational-Circuit Building …ece.gmu.edu/coursewebpages/ECE/ECE448/S15/viewgraphs/ECE...ECE 448 – FPGA and ASIC Design with VHDL George Mason University Combinational-Circuit](https://reader034.fdocuments.net/reader034/viewer/2022051508/5aae372d7f8b9a5d0a8bd61f/html5/thumbnails/62.jpg)
62 ECE 448 – FPGA and ASIC Design with VHDL
Multiplication of signed numbers
LIBRARY ieee; USE ieee.std_logic_1164.all; USE ieee.std_logic_signed.all ; entity multiply is
port( a : in STD_LOGIC_VECTOR(7 downto 0); b : in STD_LOGIC_VECTOR(7 downto 0); c : out STD_LOGIC_VECTOR(15 downto 0) );
end multiply; architecture dataflow of multiply is begin
c <= a * b; end dataflow;
![Page 63: ECE 448 Lecture 3 Combinational-Circuit Building …ece.gmu.edu/coursewebpages/ECE/ECE448/S15/viewgraphs/ECE...ECE 448 – FPGA and ASIC Design with VHDL George Mason University Combinational-Circuit](https://reader034.fdocuments.net/reader034/viewer/2022051508/5aae372d7f8b9a5d0a8bd61f/html5/thumbnails/63.jpg)
63 ECE 448 – FPGA and ASIC Design with VHDL
8x8-bit Unsigned and Signed Multiplier
8 8
a b
16
cu
16
cs *
![Page 64: ECE 448 Lecture 3 Combinational-Circuit Building …ece.gmu.edu/coursewebpages/ECE/ECE448/S15/viewgraphs/ECE...ECE 448 – FPGA and ASIC Design with VHDL George Mason University Combinational-Circuit](https://reader034.fdocuments.net/reader034/viewer/2022051508/5aae372d7f8b9a5d0a8bd61f/html5/thumbnails/64.jpg)
64 ECE 448 – FPGA and ASIC Design with VHDL
Multiplication of signed and unsigned numbers
LIBRARY ieee; USE ieee.std_logic_1164.all; USE ieee.numeric_std.all ; entity multiply is
port( a : in STD_LOGIC_VECTOR(7 downto 0); b : in STD_LOGIC_VECTOR(7 downto 0); cu : out STD_LOGIC_VECTOR(15 downto 0); cs : out STD_LOGIC_VECTOR(15 downto 0) );
end multiply; architecture dataflow of multiply is begin
-- signed multiplication
cs <= STD_LOGIC_VECTOR(SIGNED(a)*SIGNED(b)); -- unsigned multiplication
cu <= STD_LOGIC_VECTOR(UNSIGNED(a)*UNSIGNED(b)); end dataflow;
![Page 65: ECE 448 Lecture 3 Combinational-Circuit Building …ece.gmu.edu/coursewebpages/ECE/ECE448/S15/viewgraphs/ECE...ECE 448 – FPGA and ASIC Design with VHDL George Mason University Combinational-Circuit](https://reader034.fdocuments.net/reader034/viewer/2022051508/5aae372d7f8b9a5d0a8bd61f/html5/thumbnails/65.jpg)
65 ECE 448 – FPGA and ASIC Design with VHDL
Comparators
![Page 66: ECE 448 Lecture 3 Combinational-Circuit Building …ece.gmu.edu/coursewebpages/ECE/ECE448/S15/viewgraphs/ECE...ECE 448 – FPGA and ASIC Design with VHDL George Mason University Combinational-Circuit](https://reader034.fdocuments.net/reader034/viewer/2022051508/5aae372d7f8b9a5d0a8bd61f/html5/thumbnails/66.jpg)
66 ECE 448 – FPGA and ASIC Design with VHDL
4-bit Number Comparator
4
4
A
B AgtB A > B
AgtB <= '1' WHEN A > B ELSE '0' ;
![Page 67: ECE 448 Lecture 3 Combinational-Circuit Building …ece.gmu.edu/coursewebpages/ECE/ECE448/S15/viewgraphs/ECE...ECE 448 – FPGA and ASIC Design with VHDL George Mason University Combinational-Circuit](https://reader034.fdocuments.net/reader034/viewer/2022051508/5aae372d7f8b9a5d0a8bd61f/html5/thumbnails/67.jpg)
67 ECE 448 – FPGA and ASIC Design with VHDL
VHDL code for a 4-bit Unsigned Number Comparator entity
LIBRARY ieee ; USE ieee.std_logic_1164.all ; USE ieee.std_logic_unsigned.all ; ENTITY compare IS
PORT ( A, B : IN STD_LOGIC_VECTOR(3 DOWNTO 0) ; AgtB : OUT STD_LOGIC ) ;
END compare ; ARCHITECTURE dataflow OF compare IS BEGIN
AgtB <= '1' WHEN A > B ELSE '0' ; END dataflow ;
![Page 68: ECE 448 Lecture 3 Combinational-Circuit Building …ece.gmu.edu/coursewebpages/ECE/ECE448/S15/viewgraphs/ECE...ECE 448 – FPGA and ASIC Design with VHDL George Mason University Combinational-Circuit](https://reader034.fdocuments.net/reader034/viewer/2022051508/5aae372d7f8b9a5d0a8bd61f/html5/thumbnails/68.jpg)
68 ECE 448 – FPGA and ASIC Design with VHDL
VHDL code for a 4-bit Signed Number Comparator entity
LIBRARY ieee ; USE ieee.std_logic_1164.all ; USE ieee.std_logic_signed.all ; ENTITY compare IS
PORT ( A, B : IN STD_LOGIC_VECTOR(3 DOWNTO 0) ; AgtB : OUT STD_LOGIC ) ;
END compare ; ARCHITECTURE dataflow OF compare IS BEGIN
AgtB <= '1' WHEN A > B ELSE '0' ; END dataflow ;
![Page 69: ECE 448 Lecture 3 Combinational-Circuit Building …ece.gmu.edu/coursewebpages/ECE/ECE448/S15/viewgraphs/ECE...ECE 448 – FPGA and ASIC Design with VHDL George Mason University Combinational-Circuit](https://reader034.fdocuments.net/reader034/viewer/2022051508/5aae372d7f8b9a5d0a8bd61f/html5/thumbnails/69.jpg)
69 ECE 448 – FPGA and ASIC Design with VHDL
Buffers
![Page 70: ECE 448 Lecture 3 Combinational-Circuit Building …ece.gmu.edu/coursewebpages/ECE/ECE448/S15/viewgraphs/ECE...ECE 448 – FPGA and ASIC Design with VHDL George Mason University Combinational-Circuit](https://reader034.fdocuments.net/reader034/viewer/2022051508/5aae372d7f8b9a5d0a8bd61f/html5/thumbnails/70.jpg)
70 ECE 448 – FPGA and ASIC Design with VHDL
(b) Equivalent circuit
(c) Truth table
x f
e
(a) A tri-state buffer
0 0 1 1
0 1 0 1
Z Z 0 1
f e x
x f
e = 0
e = 1 x f
Tri-state Buffer
![Page 71: ECE 448 Lecture 3 Combinational-Circuit Building …ece.gmu.edu/coursewebpages/ECE/ECE448/S15/viewgraphs/ECE...ECE 448 – FPGA and ASIC Design with VHDL George Mason University Combinational-Circuit](https://reader034.fdocuments.net/reader034/viewer/2022051508/5aae372d7f8b9a5d0a8bd61f/html5/thumbnails/71.jpg)
71 ECE 448 – FPGA and ASIC Design with VHDL
x f
e
(b)
x f
e
(a)
x f
e
(c)
x f
e
(d)
Four types of Tri-state Buffers
f <= x WHEN (e = '1') ELSE 'Z';
f <= x WHEN (e = '0') ELSE 'Z';
f <= not x WHEN (e = '1') ELSE 'Z';
f <= not x WHEN (e = '0') ELSE 'Z';
![Page 72: ECE 448 Lecture 3 Combinational-Circuit Building …ece.gmu.edu/coursewebpages/ECE/ECE448/S15/viewgraphs/ECE...ECE 448 – FPGA and ASIC Design with VHDL George Mason University Combinational-Circuit](https://reader034.fdocuments.net/reader034/viewer/2022051508/5aae372d7f8b9a5d0a8bd61f/html5/thumbnails/72.jpg)
72 ECE 448 – FPGA and ASIC Design with VHDL
Tri-state Buffer entity (1)
LIBRARY ieee; USE ieee.std_logic_1164.all; ENTITY tri_state IS PORT ( e: IN STD_LOGIC;
x: IN STD_LOGIC; f: OUT STD_LOGIC ); END tri_state;
![Page 73: ECE 448 Lecture 3 Combinational-Circuit Building …ece.gmu.edu/coursewebpages/ECE/ECE448/S15/viewgraphs/ECE...ECE 448 – FPGA and ASIC Design with VHDL George Mason University Combinational-Circuit](https://reader034.fdocuments.net/reader034/viewer/2022051508/5aae372d7f8b9a5d0a8bd61f/html5/thumbnails/73.jpg)
73 ECE 448 – FPGA and ASIC Design with VHDL
Tri-state Buffer entity (2)
ARCHITECTURE dataflow OF tri_state IS BEGIN f <= x WHEN (e = ‘1’) ELSE ‘Z’; END dataflow;
![Page 74: ECE 448 Lecture 3 Combinational-Circuit Building …ece.gmu.edu/coursewebpages/ECE/ECE448/S15/viewgraphs/ECE...ECE 448 – FPGA and ASIC Design with VHDL George Mason University Combinational-Circuit](https://reader034.fdocuments.net/reader034/viewer/2022051508/5aae372d7f8b9a5d0a8bd61f/html5/thumbnails/74.jpg)
74 ECE 448 – FPGA and ASIC Design with VHDL
ROM
![Page 75: ECE 448 Lecture 3 Combinational-Circuit Building …ece.gmu.edu/coursewebpages/ECE/ECE448/S15/viewgraphs/ECE...ECE 448 – FPGA and ASIC Design with VHDL George Mason University Combinational-Circuit](https://reader034.fdocuments.net/reader034/viewer/2022051508/5aae372d7f8b9a5d0a8bd61f/html5/thumbnails/75.jpg)
75 ECE 448 – FPGA and ASIC Design with VHDL
3
16
Addr
C
8x16 ROM Dout
ROM 8x16 example (1)
![Page 76: ECE 448 Lecture 3 Combinational-Circuit Building …ece.gmu.edu/coursewebpages/ECE/ECE448/S15/viewgraphs/ECE...ECE 448 – FPGA and ASIC Design with VHDL George Mason University Combinational-Circuit](https://reader034.fdocuments.net/reader034/viewer/2022051508/5aae372d7f8b9a5d0a8bd61f/html5/thumbnails/76.jpg)
76
ROM 8x16 example (2)
LIBRARY ieee; USE ieee.std_logic_1164.all; USE ieee.numeric_std.all; ENTITY rom IS
PORT ( Addr : IN STD_LOGIC_VECTOR(2 DOWNTO 0); Dout : OUT STD_LOGIC_VECTOR(15 DOWNTO 0) );
END rom;
![Page 77: ECE 448 Lecture 3 Combinational-Circuit Building …ece.gmu.edu/coursewebpages/ECE/ECE448/S15/viewgraphs/ECE...ECE 448 – FPGA and ASIC Design with VHDL George Mason University Combinational-Circuit](https://reader034.fdocuments.net/reader034/viewer/2022051508/5aae372d7f8b9a5d0a8bd61f/html5/thumbnails/77.jpg)
77
ARCHITECTURE dataflow OF rom IS SIGNAL temp: INTEGER RANGE 0 TO 7; TYPE vector_array IS ARRAY (0 to 7) OF STD_LOGIC_VECTOR(15 DOWNTO 0); CONSTANT memory : vector_array :=
( X”800A", X"D459", X"A870", X"7853", X"650D", X"642F", X"F742", X"F548");
BEGIN temp <= to_integer(unsigned(Addr));
Dout <= memory(temp);
END dataflow;
ROM 8x16 example (3)
![Page 78: ECE 448 Lecture 3 Combinational-Circuit Building …ece.gmu.edu/coursewebpages/ECE/ECE448/S15/viewgraphs/ECE...ECE 448 – FPGA and ASIC Design with VHDL George Mason University Combinational-Circuit](https://reader034.fdocuments.net/reader034/viewer/2022051508/5aae372d7f8b9a5d0a8bd61f/html5/thumbnails/78.jpg)
78 ECE 448 – FPGA and ASIC Design with VHDL
Describing Combinational Logic
Using Dataflow Design Style
![Page 79: ECE 448 Lecture 3 Combinational-Circuit Building …ece.gmu.edu/coursewebpages/ECE/ECE448/S15/viewgraphs/ECE...ECE 448 – FPGA and ASIC Design with VHDL George Mason University Combinational-Circuit](https://reader034.fdocuments.net/reader034/viewer/2022051508/5aae372d7f8b9a5d0a8bd61f/html5/thumbnails/79.jpg)
79 ECE 448 – FPGA and ASIC Design with VHDL
MLU Example
![Page 80: ECE 448 Lecture 3 Combinational-Circuit Building …ece.gmu.edu/coursewebpages/ECE/ECE448/S15/viewgraphs/ECE...ECE 448 – FPGA and ASIC Design with VHDL George Mason University Combinational-Circuit](https://reader034.fdocuments.net/reader034/viewer/2022051508/5aae372d7f8b9a5d0a8bd61f/html5/thumbnails/80.jpg)
MLU Block Diagram
B
A
NEG_A
NEG_B
IN0 IN1 IN2 IN3
OUTPUT SEL1 SEL0
MUX_4_1
L0 L1
NEG_Y
Y Y1
A1
B1
MUX_0
MUX_1 MUX_2
MUX_3
0 1
0 1
0 1
![Page 81: ECE 448 Lecture 3 Combinational-Circuit Building …ece.gmu.edu/coursewebpages/ECE/ECE448/S15/viewgraphs/ECE...ECE 448 – FPGA and ASIC Design with VHDL George Mason University Combinational-Circuit](https://reader034.fdocuments.net/reader034/viewer/2022051508/5aae372d7f8b9a5d0a8bd61f/html5/thumbnails/81.jpg)
81 ECE 448 – FPGA and ASIC Design with VHDL
MLU: Entity Declaration
LIBRARY ieee; USE ieee.std_logic_1164.all; ENTITY mlu IS
PORT( NEG_A : IN STD_LOGIC; NEG_B : IN STD_LOGIC; NEG_Y : IN STD_LOGIC; A : IN STD_LOGIC; B : IN STD_LOGIC; L1 : IN STD_LOGIC; L0 : IN STD_LOGIC; Y : OUT STD_LOGIC );
END mlu;
![Page 82: ECE 448 Lecture 3 Combinational-Circuit Building …ece.gmu.edu/coursewebpages/ECE/ECE448/S15/viewgraphs/ECE...ECE 448 – FPGA and ASIC Design with VHDL George Mason University Combinational-Circuit](https://reader034.fdocuments.net/reader034/viewer/2022051508/5aae372d7f8b9a5d0a8bd61f/html5/thumbnails/82.jpg)
82 ECE 448 – FPGA and ASIC Design with VHDL
MLU: Architecture Declarative Section
ARCHITECTURE mlu_dataflow OF mlu IS
SIGNAL A1 : STD_LOGIC; SIGNAL B1 : STD_LOGIC; SIGNAL Y1 : STD_LOGIC; SIGNAL MUX_0 : STD_LOGIC; SIGNAL MUX_1 : STD_LOGIC; SIGNAL MUX_2 : STD_LOGIC; SIGNAL MUX_3 : STD_LOGIC; SIGNAL L: STD_LOGIC_VECTOR(1 DOWNTO 0);
![Page 83: ECE 448 Lecture 3 Combinational-Circuit Building …ece.gmu.edu/coursewebpages/ECE/ECE448/S15/viewgraphs/ECE...ECE 448 – FPGA and ASIC Design with VHDL George Mason University Combinational-Circuit](https://reader034.fdocuments.net/reader034/viewer/2022051508/5aae372d7f8b9a5d0a8bd61f/html5/thumbnails/83.jpg)
83 ECE 448 – FPGA and ASIC Design with VHDL
MLU - Architecture Body BEGIN
A1<= NOT A WHEN (NEG_A='1') ELSE A; B1<= NOT B WHEN (NEG_B='1') ELSE B; Y <= NOT Y1 WHEN (NEG_Y='1') ELSE Y1; MUX_0 <= A1 AND B1; MUX_1 <= A1 OR B1; MUX_2 <= A1 XOR B1; MUX_3 <= A1 XNOR B1;
L <= L1 & L0;
with (L) select Y1 <= MUX_0 WHEN "00",
MUX_1 WHEN "01", MUX_2 WHEN "10", MUX_3 WHEN OTHERS;
END mlu_dataflow;
![Page 84: ECE 448 Lecture 3 Combinational-Circuit Building …ece.gmu.edu/coursewebpages/ECE/ECE448/S15/viewgraphs/ECE...ECE 448 – FPGA and ASIC Design with VHDL George Mason University Combinational-Circuit](https://reader034.fdocuments.net/reader034/viewer/2022051508/5aae372d7f8b9a5d0a8bd61f/html5/thumbnails/84.jpg)
84 ECE 448 – FPGA and ASIC Design with VHDL
Logic Implied Most Often by Conditional and Selected
Concurrent Signal Assignments
![Page 85: ECE 448 Lecture 3 Combinational-Circuit Building …ece.gmu.edu/coursewebpages/ECE/ECE448/S15/viewgraphs/ECE...ECE 448 – FPGA and ASIC Design with VHDL George Mason University Combinational-Circuit](https://reader034.fdocuments.net/reader034/viewer/2022051508/5aae372d7f8b9a5d0a8bd61f/html5/thumbnails/85.jpg)
85 ECE 448 – FPGA and ASIC Design with VHDL
Data-flow VHDL
• concurrent signal assignment (⇐) • conditional concurrent signal assignment (when-else) • selected concurrent signal assignment (with-select-when)
Major instructions
Concurrent statements
![Page 86: ECE 448 Lecture 3 Combinational-Circuit Building …ece.gmu.edu/coursewebpages/ECE/ECE448/S15/viewgraphs/ECE...ECE 448 – FPGA and ASIC Design with VHDL George Mason University Combinational-Circuit](https://reader034.fdocuments.net/reader034/viewer/2022051508/5aae372d7f8b9a5d0a8bd61f/html5/thumbnails/86.jpg)
86 ECE 448 – FPGA and ASIC Design with VHDL
Conditional concurrent signal assignment
target_signal <= value1 when condition1 else value2 when condition2 else . . . valueN-1 when conditionN-1 else valueN;
When - Else
![Page 87: ECE 448 Lecture 3 Combinational-Circuit Building …ece.gmu.edu/coursewebpages/ECE/ECE448/S15/viewgraphs/ECE...ECE 448 – FPGA and ASIC Design with VHDL George Mason University Combinational-Circuit](https://reader034.fdocuments.net/reader034/viewer/2022051508/5aae372d7f8b9a5d0a8bd61f/html5/thumbnails/87.jpg)
87 ECE 448 – FPGA and ASIC Design with VHDL
Most often implied structure
target_signal <= value1 when condition1 else value2 when condition2 else . . . valueN-1 when conditionN-1 else valueN;
When - Else
.… Value N
Value N-1
Condition N-1
Condition 2 Condition 1
Value 2 Value 1
Target Signal
… 0 1
0 1
0 1
![Page 88: ECE 448 Lecture 3 Combinational-Circuit Building …ece.gmu.edu/coursewebpages/ECE/ECE448/S15/viewgraphs/ECE...ECE 448 – FPGA and ASIC Design with VHDL George Mason University Combinational-Circuit](https://reader034.fdocuments.net/reader034/viewer/2022051508/5aae372d7f8b9a5d0a8bd61f/html5/thumbnails/88.jpg)
88 ECE 448 – FPGA and ASIC Design with VHDL
Data-flow VHDL
• concurrent signal assignment (⇐) • conditional concurrent signal assignment (when-else) • selected concurrent signal assignment (with-select-when)
Major instructions
Concurrent statements
![Page 89: ECE 448 Lecture 3 Combinational-Circuit Building …ece.gmu.edu/coursewebpages/ECE/ECE448/S15/viewgraphs/ECE...ECE 448 – FPGA and ASIC Design with VHDL George Mason University Combinational-Circuit](https://reader034.fdocuments.net/reader034/viewer/2022051508/5aae372d7f8b9a5d0a8bd61f/html5/thumbnails/89.jpg)
89 ECE 448 – FPGA and ASIC Design with VHDL
Selected concurrent signal assignment
with choice_expression select target_signal <= expression1 when choices_1, expression2 when choices_2, . . . expressionN when choices_N;
With –Select-When
![Page 90: ECE 448 Lecture 3 Combinational-Circuit Building …ece.gmu.edu/coursewebpages/ECE/ECE448/S15/viewgraphs/ECE...ECE 448 – FPGA and ASIC Design with VHDL George Mason University Combinational-Circuit](https://reader034.fdocuments.net/reader034/viewer/2022051508/5aae372d7f8b9a5d0a8bd61f/html5/thumbnails/90.jpg)
90 ECE 448 – FPGA and ASIC Design with VHDL
Most Often Implied Structure
with choice_expression select target_signal <= expression1 when choices_1, expression2 when choices_2, . . . expressionN when choices_N;
With –Select-When
choices_1
choices_2
choices_N
expression1
target_signal
choice expression
expression2
expressionN
![Page 91: ECE 448 Lecture 3 Combinational-Circuit Building …ece.gmu.edu/coursewebpages/ECE/ECE448/S15/viewgraphs/ECE...ECE 448 – FPGA and ASIC Design with VHDL George Mason University Combinational-Circuit](https://reader034.fdocuments.net/reader034/viewer/2022051508/5aae372d7f8b9a5d0a8bd61f/html5/thumbnails/91.jpg)
91 ECE 448 – FPGA and ASIC Design with VHDL
Allowed formats of choices_k
WHEN value WHEN value_1 | value_2 | .... | value N WHEN OTHERS
![Page 92: ECE 448 Lecture 3 Combinational-Circuit Building …ece.gmu.edu/coursewebpages/ECE/ECE448/S15/viewgraphs/ECE...ECE 448 – FPGA and ASIC Design with VHDL George Mason University Combinational-Circuit](https://reader034.fdocuments.net/reader034/viewer/2022051508/5aae372d7f8b9a5d0a8bd61f/html5/thumbnails/92.jpg)
92 ECE 448 – FPGA and ASIC Design with VHDL
Allowed formats of choice_k - example
WITH sel SELECT y <= a WHEN "000",
c WHEN "001" | "111",
d WHEN OTHERS;
![Page 93: ECE 448 Lecture 3 Combinational-Circuit Building …ece.gmu.edu/coursewebpages/ECE/ECE448/S15/viewgraphs/ECE...ECE 448 – FPGA and ASIC Design with VHDL George Mason University Combinational-Circuit](https://reader034.fdocuments.net/reader034/viewer/2022051508/5aae372d7f8b9a5d0a8bd61f/html5/thumbnails/93.jpg)
93 ECE 448 – FPGA and ASIC Design with VHDL
when-else vs. with-select-when (1)
"when-else" should be used when: 1) there is only one condition (and thus, only one
else), as in the 2-to-1 MUX 2) conditions are independent of each other (e.g.,
they test values of different signals) 3) conditions reflect priority (as in priority
encoder); one with the highest priority need to be tested first.
![Page 94: ECE 448 Lecture 3 Combinational-Circuit Building …ece.gmu.edu/coursewebpages/ECE/ECE448/S15/viewgraphs/ECE...ECE 448 – FPGA and ASIC Design with VHDL George Mason University Combinational-Circuit](https://reader034.fdocuments.net/reader034/viewer/2022051508/5aae372d7f8b9a5d0a8bd61f/html5/thumbnails/94.jpg)
94 ECE 448 – FPGA and ASIC Design with VHDL
when-else vs. with-select-when (2)
"with-select-when" should be used when there is 1) more than one condition 2) conditions are closely related to each other
(e.g., represent different ranges of values of the same signal)
3) all conditions have the same priority (as in the 4-to-1 MUX).