04_Chapter 4 - Modular Comb Logic_2
-
Upload
tho-maftuhin -
Category
Documents
-
view
216 -
download
0
Transcript of 04_Chapter 4 - Modular Comb Logic_2
-
8/12/2019 04_Chapter 4 - Modular Comb Logic_2
1/158
Chapter 4
Modular Combinational Logic
-
8/12/2019 04_Chapter 4 - Modular Comb Logic_2
2/158
Decoders
-
8/12/2019 04_Chapter 4 - Modular Comb Logic_2
3/158
Decoders
n to 2ndecoder
n inputs
2noutputs
For each input, one and only one outputwill be active.
Uses:
Minterm generator
Wordline (memory) circuit
Code conversion
Routing data
-
8/12/2019 04_Chapter 4 - Modular Comb Logic_2
4/158
2 to 4 Decoder Example
-
8/12/2019 04_Chapter 4 - Modular Comb Logic_2
5/158
2 to 4 DecoderTruth Table
2 to 4 decoder
X1 X0 Y3 Y2 Y1 Y0
0 0 0 0 0 1
0 1 0 0 1 0
1 0 0 1 0 0
1 1 1 0 0 0
-
8/12/2019 04_Chapter 4 - Modular Comb Logic_2
6/158
2 to 4 Decoder Equations
0 1 0
1 1 0
2 1 0
3 1 0
Y X X
Y X X
Y X X
Y X X
-
8/12/2019 04_Chapter 4 - Modular Comb Logic_2
7/158
-
8/12/2019 04_Chapter 4 - Modular Comb Logic_2
8/158
2 to 4 Decoder: Block Symbol
SymbolCircuit
-
8/12/2019 04_Chapter 4 - Modular Comb Logic_2
9/158
3 to 8 Decoder Example
-
8/12/2019 04_Chapter 4 - Modular Comb Logic_2
10/158
3 to 8 DecoderTruth Table
x2 x1 x0 y7 y6 y5 y4 y3 y2 y1 y0
0 0 0 0 0 0 0 0 0 0 1
0 0 1 0 0 0 0 0 0 1 0
0 1 0 0 0 0 0 0 1 0 0
0 1 1 0 0 0 0 1 0 0 0
1 0 0 0 0 0 1 0 0 0 0
1 0 1 0 0 1 0 0 0 0 0
1 1 0 0 1 0 0 0 0 0 0
1 1 1 1 0 0 0 0 0 0 0
-
8/12/2019 04_Chapter 4 - Modular Comb Logic_2
11/158
3 to 8 Decoder Equations
0 2 1 0
1 2 1 0
2 2 1 0
3 2 1 0
Y X X X
Y X X X
Y X X X
Y X X X
4 2 1 0
5 2 1 0
6 2 1 0
7 2 1 0
Y X X X
Y X X X
Y X X X
Y X X X
-
8/12/2019 04_Chapter 4 - Modular Comb Logic_2
12/158
3 to 8 Decoder: Circuit
-
8/12/2019 04_Chapter 4 - Modular Comb Logic_2
13/158
3 to 8 Decoder: Block Symbol
Symbol
Circuit
-
8/12/2019 04_Chapter 4 - Modular Comb Logic_2
14/158
-
8/12/2019 04_Chapter 4 - Modular Comb Logic_2
15/158
Example
Using only a 3x8 decoder and two-input OR gates, design a logiccircuit which implements thefollowing Boolean equation
, , 2, 4,5F a b c m
-
8/12/2019 04_Chapter 4 - Modular Comb Logic_2
16/158
Solution
m2
m4m5
-
8/12/2019 04_Chapter 4 - Modular Comb Logic_2
17/158
2 to 4 Decoder with Enable
-
8/12/2019 04_Chapter 4 - Modular Comb Logic_2
18/158
2x4 Decoder with Enable
Enable is abbreviated as EN
EN is called a Control Signal
Control Signals can be Active High Signal
EN = 1 Turns ON Decoder
Active Low Signal
EN=0 Turns ON Decoder
-
8/12/2019 04_Chapter 4 - Modular Comb Logic_2
19/158
2 x 4 Decoder with Active High Enable
Truth Table
En x1 x0 y3 y2 y1 y0
0 0 0 0 0 0 0
0 0 1 0 0 0 0
0 1 0 0 0 0 0
0 1 1 0 0 0 0
1 0 0 0 0 0 1
1 0 1 0 0 1 0
1 1 0 0 1 0 0
1 1 1 1 0 0 0
-
8/12/2019 04_Chapter 4 - Modular Comb Logic_2
20/158
2 to 4 Decoder with Enable Equations
0 1 0
1 1 0
2 1 0
3 1 0
n
n
n
n
Y E X X
Y E X X
Y E X X
Y E X X
-
8/12/2019 04_Chapter 4 - Modular Comb Logic_2
21/158
2 to 4 Decoder with Enable Circuit
-
8/12/2019 04_Chapter 4 - Modular Comb Logic_2
22/158
2 to 4 Decoder with Enable Symbol
-
8/12/2019 04_Chapter 4 - Modular Comb Logic_2
23/158
2 x 4 Decoder with Active High Enable
Truth Table (Short hand notation)
En x1 x0 y3 y2 y1 y0
0 d d 0 0 0 0
1 0 0 0 0 0 1
1 0 1 0 0 1 0
1 1 0 0 1 0 0
1 1 1 1 0 0 0
d = dont care
En has highest priority.If En=0, we dont care about x1 or x0 because Y=0
-
8/12/2019 04_Chapter 4 - Modular Comb Logic_2
24/158
2 x 4 Decoder with Active LowEnable
Truth Table (Short hand notation)
EnL x1 x0 y3 y2 y1 y0
1 d d 0 0 0 0
0 0 0 0 0 0 1
0 0 1 0 0 1 0
0 1 0 0 1 0 0
0 1 1 1 0 0 0
d = dont care
En has highest priority.If En=1, we dont care about x1 or x0 because Y=0
-
8/12/2019 04_Chapter 4 - Modular Comb Logic_2
25/158
2 to 4 Decoder with Active Low Enable
Circuit
-
8/12/2019 04_Chapter 4 - Modular Comb Logic_2
26/158
Design Example
-
8/12/2019 04_Chapter 4 - Modular Comb Logic_2
27/158
Example
Design a 3x8 decoder using only2x4 decoders and NOT gates.
-
8/12/2019 04_Chapter 4 - Modular Comb Logic_2
28/158
Solution
On when A=1
On when A=0
-
8/12/2019 04_Chapter 4 - Modular Comb Logic_2
29/158
Encoders
-
8/12/2019 04_Chapter 4 - Modular Comb Logic_2
30/158
Encoders
Opposite of a decoder
2n to n encoder
2n
inputs n outputs
For each input, the circuit willproduce an encoded output
-
8/12/2019 04_Chapter 4 - Modular Comb Logic_2
31/158
Example: 4to 2 Binary Encoder
Truth Table
X3 X2 X1 X0 Y1 Y0
0 0 0 1 0 0
0 0 1 0 0 1
0 1 0 0 1 0
1 0 0 0 1 1
Assume only one input high at a time!!
-
8/12/2019 04_Chapter 4 - Modular Comb Logic_2
32/158
4 to 2 Encoder Equations
0 1 3
1 2 3
Y X X
Y X X
-
8/12/2019 04_Chapter 4 - Modular Comb Logic_2
33/158
Problems with initial design
Q: How do we tell the differencebetween an input of all 0s (i.e.X=0) and X=1?
A: Add another output (IA) thatindicates that the input is valid.Lets make IA active low.
0 1 2 3IA X X X X
-
8/12/2019 04_Chapter 4 - Modular Comb Logic_2
34/158
Problems with initial design
If IA = 1 => all lines are 0
If IA = 0 => at least one line is 1
Q: What happens if more than one inputis high at the same time?
A: Design a priority encoder that willencode the input with the highest priority.
Lets set X3 with the highest priority,followed by X2, X1, and X0
-
8/12/2019 04_Chapter 4 - Modular Comb Logic_2
35/158
Example: 4to 2 Priority Binary Encoder
Truth Table
X3 X2 X1 X0 Y1 Y0
0 0 0 1 0 0
0 0 1 d 0 1
0 1 d d 1 0
1 d d d 1 1
-
8/12/2019 04_Chapter 4 - Modular Comb Logic_2
36/158
Solution
x3x2x1x0 00 01 11 10
00
01
11
10
Y1
x3x2x1x0 00 01 11 10
00
01
11
10
Y0
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1 2 3Y X X 0 1 2 3Y X X X
-
8/12/2019 04_Chapter 4 - Modular Comb Logic_2
37/158
4 to 2 Priority Encoder Equations
0 1 2 3
1 2 3
Y X X X
Y X X
0 1 2 3IA X X X X
-
8/12/2019 04_Chapter 4 - Modular Comb Logic_2
38/158
Multiplexer/Data Selectors
-
8/12/2019 04_Chapter 4 - Modular Comb Logic_2
39/158
Multiplexer(MUX)/Data Selector
N to 1 multiplexer
n data input lines
Log2(n) control inputs
One output
This circuit will connect theselected input to the output. The
selected input is specified by adecoding of the control inputs.
-
8/12/2019 04_Chapter 4 - Modular Comb Logic_2
40/158
Example: 4to 1 MUX Truth Table
D3 D2 D1 D0 A B F
d d d D0 0 0 D0
d d D1 d 0 1 D1
d D2 d d 1 0 D2
D3 d d d 1 1 D3
d = dont care / Di = data on input i
Data InputsControlInputs
Output
-
8/12/2019 04_Chapter 4 - Modular Comb Logic_2
41/158
4 to 1 MUX Equation
0 1 2 3F D AB D AB D AB D AB 3
0
i i
i
F D m
Ds are the DATA inputs, AB are control inputs and calledthe select lines.
-
8/12/2019 04_Chapter 4 - Modular Comb Logic_2
42/158
4 to 1 MUX Circuit
2x4 Decoder Only a single AND gate willbe ON at a time.
Output
Control Inputs Data Inputs
-
8/12/2019 04_Chapter 4 - Modular Comb Logic_2
43/158
4 to 1 MUX Symbol
Data
Inputs
ControlInputs
Output
-
8/12/2019 04_Chapter 4 - Modular Comb Logic_2
44/158
Data and Control Paths
Logic
Data PathInputs
Data PathOutputs
Control PathInputs
Control PathOutputs
-
8/12/2019 04_Chapter 4 - Modular Comb Logic_2
45/158
MUX Applications
-
8/12/2019 04_Chapter 4 - Modular Comb Logic_2
46/158
Example
Using a 4x1 MUX, design a logiccircuit which implements:
Y a b We have,
Y
0 1 2 3Y D AB D AB D AB D AB
-
8/12/2019 04_Chapter 4 - Modular Comb Logic_2
47/158
Example
Using a 4x1 MUX, design a logiccircuit which implements:
Y a b
a b Y Dn
0 0 0 D0
0 1 1 D1
1 0 1 D2
1 1 0 D3
0 1 1 0Y AB AB AB AB AB AB
-
8/12/2019 04_Chapter 4 - Modular Comb Logic_2
48/158
Solution
-
8/12/2019 04_Chapter 4 - Modular Comb Logic_2
49/158
Multibit Multiplexers
-
8/12/2019 04_Chapter 4 - Modular Comb Logic_2
50/158
Multi-bit Multiplexers
J-bit nx1 mux
sel
d0d1
dn-1
d2 FJ bitsdeep
log2n
J bitsdeep
0
j
i i
i
F j D j m
j=0 to 3This is just J separatenx1 multiplexers
-
8/12/2019 04_Chapter 4 - Modular Comb Logic_2
51/158
Example 4-bit 4x1 MUX
A B
D0[3..0]
D1[3..0]
D3[3..0]
D2[3..0]F[3..0] 4 bits
deep
D0[3..0]
D1[3..0]
D2[3..0]
D3[3..0]
A B
F[3..0]
3
0
i i
i
F j D j m
j=0 to 3This is just 4 separate 4x1 muxes
-
8/12/2019 04_Chapter 4 - Modular Comb Logic_2
52/158
Example
4-bit 4x1 MUX
0 1 2 30 0 0 0 0F D AB D AB D AB D AB
0 1 2 31 1 1 1 1F D AB D AB D AB D AB
0 1 2 32 2 2 2 2F D AB D AB D AB D AB
0 1 2 33 3 3 3 3F D AB D AB D AB D AB
Bit 0
Bit 3
Bit 2
Bit 1
-
8/12/2019 04_Chapter 4 - Modular Comb Logic_2
53/158
Example 4 bit 4x1 MUX
For the jth output, we have
D0[j]
D1[j]D2[j]
D3[j]
A
B
F[j]
-
8/12/2019 04_Chapter 4 - Modular Comb Logic_2
54/158
Example 4 bit 4x1 MUX
For the bit 0 output, we have
D0[0]
D1[0]D2[0]
D3[0]
A
B
F[0]
-
8/12/2019 04_Chapter 4 - Modular Comb Logic_2
55/158
Example 4 bit 4x1 MUX
For the bit 1 output, we have
D0[1]
D1[1]D2[1]
D3[1]
A
B
F[1]
-
8/12/2019 04_Chapter 4 - Modular Comb Logic_2
56/158
Example 4 bit 4x1 MUX
For the bit 2 output, we have
D0[2]
D1[2]D2[2]
D3[2]
A
B
F[2]
-
8/12/2019 04_Chapter 4 - Modular Comb Logic_2
57/158
Example 4 bit 4x1 MUX
For the bit 3 output, we have
D0[3]
D1[3]D2[3]
D3[3]
A
B
F[3]
-
8/12/2019 04_Chapter 4 - Modular Comb Logic_2
58/158
Example 4 bit 4x1 Mux
F[0]
F[1]
F[2]
F[3]
Complete Circuit
Bit 0
Bit 1
Bit 2
Bit 3
-
8/12/2019 04_Chapter 4 - Modular Comb Logic_2
59/158
Example 4 bit 4x1 MUX
Symbol
-
8/12/2019 04_Chapter 4 - Modular Comb Logic_2
60/158
Design Example
Using a 4bit 4x1 MUX, design a 8bit
4x1 MUX
-
8/12/2019 04_Chapter 4 - Modular Comb Logic_2
61/158
Solution
-
8/12/2019 04_Chapter 4 - Modular Comb Logic_2
62/158
DeMultiplexers/Data Distributors
-
8/12/2019 04_Chapter 4 - Modular Comb Logic_2
63/158
Demultiplexer/Data Distributor
Opposite of a multiplexer
1 to N demultiplexer 1 data input
N data outputs Log2(n) control inputs
This circuit will connect a datainput to one and only one output.The selected output is specified by adecoding of the control inputs.
-
8/12/2019 04_Chapter 4 - Modular Comb Logic_2
64/158
Example: 1to 4 DeMUX Truth Table
D A B F3 F2 F1 F0
D 0 0 0 0 0 D
D 0 1 0 0 D 0
D 1 0 0 D 0 0
D 1 1 D 0 0 0
d = dont care / Di = data on input i
-
8/12/2019 04_Chapter 4 - Modular Comb Logic_2
65/158
1 to 4 DeMUX Equations
3 3F DAB Dm
j jF Dm
D is the DATA inputs, AB are control inputs and calledthe select lines.
1 1F DAB Dm
2 2F DAB Dm
0 0F DAB Dm
-
8/12/2019 04_Chapter 4 - Modular Comb Logic_2
66/158
1 to 4 DEMUX Circuit
Only 1 AND gate willbe ON
2x4 DecoderOnly oneF will beactive
-
8/12/2019 04_Chapter 4 - Modular Comb Logic_2
67/158
1 to 4 DEMUX Symbol
DataInput
Selected
Lines Outputs
-
8/12/2019 04_Chapter 4 - Modular Comb Logic_2
68/158
Example
Design a 3x8 decoder using only2x4 decoders and NOT gates.
-
8/12/2019 04_Chapter 4 - Modular Comb Logic_2
69/158
Solution
On when A=1
On when A=0
TUGAS
-
8/12/2019 04_Chapter 4 - Modular Comb Logic_2
70/158
1. Desain sirkuit dengan decoder dan gerbang eksternal untukfungsi boolean berikut :
F1 = XY + XYZ, F2 = Y + ZF1 = XY + XYZ, F2 = XZ + Y
F1 = XYZ + XZ, F2 = XYZ + XY, F3 = XYZ + XY
F1 = XYZ + YZ, F2 = XYZ + XY, F3 = XYZ + XY
2. Implementasikan fungsi boolean berikut dengan 4x1multiplexer
F(A,B,C) = (1,2,4,7)
F(X,Y,Z) = (0,3,5,7)
F(A,B,C) = (2,4,5,6)
3. Implementasikan fungsi boolean berikut dengan 8x1multiplexer
F(A,B,C,D) = (0,2,4,7,8,10,13,15)F(W,X,Y,Z) = (0,1,3,5,6,8,10,12)
F(A,B,C,D) = (1,4,7,9,11,13,14,15)
-
8/12/2019 04_Chapter 4 - Modular Comb Logic_2
71/158
Basic Arithmetic Elements
Half Adder
-
8/12/2019 04_Chapter 4 - Modular Comb Logic_2
72/158
Half Adder-Truth Table
S=A+B (arithmetic sum)
A B S1 S0
0 0 0 0
0 1 0 1
1 0 0 1
1 1 1 0
0S a b
1S ab
-
8/12/2019 04_Chapter 4 - Modular Comb Logic_2
73/158
Half Adder Circuit
-
8/12/2019 04_Chapter 4 - Modular Comb Logic_2
74/158
Full Adder-Truth Table
S=A+B+C (arithmetic sum)
A B C S1 S0
0 0 0 0 0
0 0 1 0 1
0 1 0 0 1
0 1 1 1 0
0S a b c 1S ab ac bc
A B C S1 S0
1 0 0 0 1
1 0 1 1 0
1 1 0 1 0
1 1 1 1 1
-
8/12/2019 04_Chapter 4 - Modular Comb Logic_2
75/158
Full Adder
0S a b c
1S ab ac bc You can show!!!
1S ab c a b
-
8/12/2019 04_Chapter 4 - Modular Comb Logic_2
76/158
Synthesis
(0)S A B C
Logic Equation
Logic Circuit
-
8/12/2019 04_Chapter 4 - Modular Comb Logic_2
77/158
Synthesis
(1)S AB C A B Logic Equation
Logic Circuit
Synthesis
-
8/12/2019 04_Chapter 4 - Modular Comb Logic_2
78/158
17
AND2 18
OR2
19 coutOUTPUT
16
AND2
VCC14 Cin INPUT
VCC13 B INPUT
10
XOR
11
XOR
15 sumOUTPUT
VCC12 A INPUT
Synthesis
Full Adder Circuit
S(0)
S(1)
C
AB
S(0)S(1)
Simulation
-
8/12/2019 04_Chapter 4 - Modular Comb Logic_2
79/158
Verification
S(0)S(1)
We verify the circuit via a simulation
Logic SimulationInputs
OutputsS 00 01 01 10 01 01 01 11
-
8/12/2019 04_Chapter 4 - Modular Comb Logic_2
80/158
17
AND2 18
OR2
19 coutOUTPUT
16
AND2
VCC14 Cin INPUT
VCC13 B INPUT
10
XOR
11
XOR
15 sumOUTPUT
VCC12 A
INPUT
Verification Summary
S(0)
S(1)
C
AB
S(0)
S(1)
Simulation
Circuit
D t ti
-
8/12/2019 04_Chapter 4 - Modular Comb Logic_2
81/158
Documentation
17
AND2 18
OR2
19 coutOUTPUT
16
AND2
VCC14 Cin INPUT
VCC13 B INPUT
10
XOR
11
XOR
15 sumOUTPUT
VCC12 A
INPUT
S(0)
S(1)
C
AB
FullAdder
C
ABS(0)
S(1)
Block Diagram
-
8/12/2019 04_Chapter 4 - Modular Comb Logic_2
82/158
Ripple Carry Adder
-
8/12/2019 04_Chapter 4 - Modular Comb Logic_2
83/158
Conceptualization
4-bit adder (worst case)
1111
111111110
111
For the worst case we need to add
three bits to generate a single output bitwith a possible carry out.
Can we use our single bit adder for this?
-
8/12/2019 04_Chapter 4 - Modular Comb Logic_2
84/158
Ripple Carry Adder
We can cascade several full addersto create a ripple carry adder
The circuit gets its name becausethe carry bit ripples from one bitposition to the next
-
8/12/2019 04_Chapter 4 - Modular Comb Logic_2
85/158
Conceptualization
FullAdderC
A
B S(0)
S(1)
FullAdder
C
AB
S(0)
S(1)
First, lets look at two bits
A(0)
B(0)
B(1)
A(1)
Sum(0)
Sum(1)
What about the carry?
-
8/12/2019 04_Chapter 4 - Modular Comb Logic_2
86/158
Conceptualization
FullAdderC
A
B S(0)
S(1)
FullAdder
C
AB
S(0)
S(1)
Lets connect the two full adders
A(0)
B(0)
B(1)
A(1)
S(0)
S(1)
Set carry in for first bit to 0. Why?
Cout
Cin
0
-
8/12/2019 04_Chapter 4 - Modular Comb Logic_2
87/158
Analysis
FullAdderC
A
B S(0)
S(1)
FullAdder
C
AB
S(0)
S(1)
Lets test this for a few cases:
0
0
0
0
0
0
0
0
0
0
00
00000
Correct!!!
Rule of thumb: Always test simple cases first!!
-
8/12/2019 04_Chapter 4 - Modular Comb Logic_2
88/158
Analysis
FullAdderC
A
B S(0)
S(1)
FullAdder
C
AB
S(0)
S(1)
Lets test this for the a few cases
0
1
1
1
1
1
1
0
1
1
11
11110
Correct!!!
-
8/12/2019 04_Chapter 4 - Modular Comb Logic_2
89/158
Analysis
FullAdderC
A
B S(0)
S(1)
FullAdder
C
AB
S(0)
S(1)
Lets test this for the a few cases
1
1
0
0
0
1
1
1
0
0
01
01010
Correct!!!
-
8/12/2019 04_Chapter 4 - Modular Comb Logic_2
90/158
Four Bit Ripple Adder
Carry in
Carry out
-
8/12/2019 04_Chapter 4 - Modular Comb Logic_2
91/158
Logic Simulation
-
8/12/2019 04_Chapter 4 - Modular Comb Logic_2
92/158
8-bit Ripple Carry Adder
Use two 4-bit adders
-
8/12/2019 04_Chapter 4 - Modular Comb Logic_2
93/158
16-bit Ripple Carry Adder
Use two 8-bit adders
-
8/12/2019 04_Chapter 4 - Modular Comb Logic_2
94/158
-
8/12/2019 04_Chapter 4 - Modular Comb Logic_2
95/158
Subtraction Circuit
Calculate 2s complement of B
Add B to A
ADDER
INV
A
B
S
1
Cin
A
B
1S A B A B A B
B
1
1S A B
-
8/12/2019 04_Chapter 4 - Modular Comb Logic_2
96/158
Add/Sub Circuit
-
8/12/2019 04_Chapter 4 - Modular Comb Logic_2
97/158
Add/Sub Circuit Module
Add/SubModule
A
B
S
Add
A
B
Add
S
-
8/12/2019 04_Chapter 4 - Modular Comb Logic_2
98/158
Function Table for Add/Sub Module
Add Functional
Result0 S=A+B
1 S=A-B
Add is a control input. It is active low. This meansthat the module will compute A+B when Add=0. Itwill compute A-B when Add=1.
-
8/12/2019 04_Chapter 4 - Modular Comb Logic_2
99/158
Add/Sub Circuit
Design using Modules
-
8/12/2019 04_Chapter 4 - Modular Comb Logic_2
100/158
Add/Sub Circuit
ADDER
INV
2x1
MUX
A
B
S
B
B
A
S Cin
A
Add
-
8/12/2019 04_Chapter 4 - Modular Comb Logic_2
101/158
Add/Sub Circuit
ADDER
INV
2x1
MUX
A
B
S
B
B
AS Cin
A
Add
Add operation. Add=0
0 0
S A B
-
8/12/2019 04_Chapter 4 - Modular Comb Logic_2
102/158
Add/Sub Circuit
ADDER
INV
2x1
MUX
A
B
S
B
B
AS Cin
A
Add
Sub operation. Add=1
1 1
1S A B
B
-
8/12/2019 04_Chapter 4 - Modular Comb Logic_2
103/158
Overflow/Underflow Detection
-
8/12/2019 04_Chapter 4 - Modular Comb Logic_2
104/158
Numerical Overflow/Underflow
2s complement number
We have S=A+B
Range of sum
Overflow occurs if
Underflow occurs if
1 12 2 1n nS
12 1nS
12
nS
-
8/12/2019 04_Chapter 4 - Modular Comb Logic_2
105/158
Example: Overflow
Let n=4, Range is
Let A=$7, B=$7, thenS=$7+$7=$E, but $E=%1110 = -2,so Overflowhas occurred.
8 7S
3 3
2 2 1S
-
8/12/2019 04_Chapter 4 - Modular Comb Logic_2
106/158
Example: Overflow
Lets examine this more closely
-8,-7,-6,-5,-4,-3,-2,-1,0,1,2,3,4,5,6,7
+7
So, overflow is the same as wrap around.
8,9,A,B,C,D,E,F,0,1,2,3,4,5,6,7
-
8/12/2019 04_Chapter 4 - Modular Comb Logic_2
107/158
Example: Underflow
Let n=4, let A=-7 and B=-7,
in 2s complement, A=B=$9,S=$9+$9=$12=$02
so underflowhas occurred.
-
8/12/2019 04_Chapter 4 - Modular Comb Logic_2
108/158
Example: Underflow
Lets examine this more closely
-8,-7,-6,-5,-4,-3,-2,-1,0,1,2,3,4,5,6,7
+6
So, underflow is the same as wrap around.
+1
-
8/12/2019 04_Chapter 4 - Modular Comb Logic_2
109/158
Overflow/Underflow Detection
How do we detect overflow andunderflow?
First adding a positive to a negative
number is always OK. 4 bit example: 7 + (-8) = -1
Lets examine the sum of the MSBs todetermine overflow and underflow.
Set V=1, if overflow/underflow occurs
-
8/12/2019 04_Chapter 4 - Modular Comb Logic_2
110/158
Examination of MSB
b a cin S Co V Explanation
0 0 0 0 0 0 A+B < 2n-1 (OK)
0 0 1 1 0 1 A+B>2n-1
-1 (overflow)
0 1 0 1 0 0 -A+B (OK)
0 1 1 0 1 0 -A+B (OK)
1 0 0 1 0 0 A-B (OK)
1 0 1 0 1 0 A-B (OK)
1 1 0 0 1 1 -A-B< -2n-1 (underflow)
1 1 1 1 1 0 -A-B > -2n-1 (OK)
a,b are the MSBs of A and B. cin is carry in; cout=carry out
-
8/12/2019 04_Chapter 4 - Modular Comb Logic_2
111/158
Overflow/Underflow Detection
We find
1 1 , 1 1 1 , 1n n in n n n in nV a b c a b c
-
8/12/2019 04_Chapter 4 - Modular Comb Logic_2
112/158
Overflow/Underflow Detection
, 1 , 1in n out nV c c
You can also use
That is, if for the MSB carry_in isnot equal to carry_out, overflow or
underflow has occurred.
-
8/12/2019 04_Chapter 4 - Modular Comb Logic_2
113/158
Comparators
C
-
8/12/2019 04_Chapter 4 - Modular Comb Logic_2
114/158
Equal Comparator
Design a logic circuit which willcompute
F0 = (A = B)
-
8/12/2019 04_Chapter 4 - Modular Comb Logic_2
115/158
-
8/12/2019 04_Chapter 4 - Modular Comb Logic_2
116/158
2-bit Equal Comparator Truth Table
b1 b0 a1 a0 F0
1 0 0 0 0
1 0 0 1 0
1 0 1 0 11 0 1 1 0
1 1 0 0 0
1 1 0 1 0
1 1 1 0 0
1 1 1 1 1
-
8/12/2019 04_Chapter 4 - Modular Comb Logic_2
117/158
N bit E l C t
-
8/12/2019 04_Chapter 4 - Modular Comb Logic_2
118/158
N-bit Equal Comparator
0 1 1 1 1 0 0n nF a b a b a b
N t E l C t
-
8/12/2019 04_Chapter 4 - Modular Comb Logic_2
119/158
Not Equal Comparator
Design a logic circuit which willcompute
F = (A B)
F = (A = B)i.e. Just invert our Equal Comparator circuit
M it d C t
-
8/12/2019 04_Chapter 4 - Modular Comb Logic_2
120/158
Magnitude Comparator
Design a logic circuit which willcompute
F2 = (A>B)
F1 = (A
-
8/12/2019 04_Chapter 4 - Modular Comb Logic_2
121/158
Truth Table
b1 b0 a1 a0 F2 F1
0 0 0 0 0 0
0 0 0 1 1 0
0 0 1 0 1 00 0 1 1 1 0
0 1 0 0 0 1
0 1 0 1 0 0
0 1 1 0 1 0
0 1 1 1 1 0
2-bit Magnitude (unsigned) Comparator
T th T bl
-
8/12/2019 04_Chapter 4 - Modular Comb Logic_2
122/158
Truth Table
b1 b0 a1 a0 F2 F1
1 0 0 0 0 1
1 0 0 1 0 1
1 0 1 0 0 01 0 1 1 1 0
1 1 0 0 0 1
1 1 0 1 0 1
1 1 1 0 0 1
1 1 1 1 0 0
Y h
-
8/12/2019 04_Chapter 4 - Modular Comb Logic_2
123/158
You can show
2 1 1 0 1 0 1 0 0F a b a b b a a b
1 1 1 1 0 0 0 1 0F a b a a b a b b
-
8/12/2019 04_Chapter 4 - Modular Comb Logic_2
124/158
Arithmetic Logic Units (ALUs)
Arithmetic Logic Unit (ALU)
-
8/12/2019 04_Chapter 4 - Modular Comb Logic_2
125/158
Arithmetic Logic Unit (ALU)
ALU
A[n-1,,0]
B[n-1..0]
F
S[m-1..0]
A,B are data inputs of n bits each in depth
S is a control input. We have 2m
operationsF is the output
Example
-
8/12/2019 04_Chapter 4 - Modular Comb Logic_2
126/158
Example
Let n=4,m=3 We have A[3..0] and B[3..0]
With m=3, we have 23= 8 operations
Lets look at a possible function table
Function Table
-
8/12/2019 04_Chapter 4 - Modular Comb Logic_2
127/158
Function Table
s2 s1 s0 Function
0 0 0 F=AB
0 0 1 F=A+B (logical OR)
0 1 0 F=NOT A0 1 1 F=A XOR B
1 0 0 F=A+B (Arithmetic)
1 0 1 F=A-B1 1 0 F=A + 1
1 1 1 F=A - 1
Design using a Truth Table
-
8/12/2019 04_Chapter 4 - Modular Comb Logic_2
128/158
Design using a Truth Table
How large is the truth table? 2n from data inputs A and B
Example: n=8, we have 16 data inputs A[7..0] and B[7..0]
3 control inputs Total of 2n+3 inputs
N=8, we have 19 inputs
Our truth table will have 192(361) rows and 8 outputs
Too complex. Lets explore anotheralternative using a system or modularapproach
Design using Modules
-
8/12/2019 04_Chapter 4 - Modular Comb Logic_2
129/158
Design using Modules
Note:
For S2=0, we have logic operations
For S2=1, we have arithmetic
operations So, lets use S2 to control a 2x1 MUX
to select between logic and arithmeticoperations, so our top level design
would look like:
ALU Design
-
8/12/2019 04_Chapter 4 - Modular Comb Logic_2
130/158
ALU Design
Logic
Module
Arithmetic
Module
2x1
MUX
S[2]
A B
A
A
B
F
A
BF
S[1..0]
S[1..0]
B
F F
ALU Design S2=0
-
8/12/2019 04_Chapter 4 - Modular Comb Logic_2
131/158
ALU Design S2=0
Logic
Module
Arithmetic
Module
2x1MUX
S[2]
A B
A
A
B
F
A
BF
S[1..0]
S[1..0]
B
F F
With S2=0, F is the output fromthe logic module
ALU Design S2=1
-
8/12/2019 04_Chapter 4 - Modular Comb Logic_2
132/158
ALU Design S2=1
Logic
Module
Arithmetic
Module
2x1MUX
S[2]
A B
A
A
B
F
A
BF
S[1..0]
S[1..0]
B
F F
With S2=1, F is the output fromthe arithmetic module
-
8/12/2019 04_Chapter 4 - Modular Comb Logic_2
133/158
Logic Module Design
Function Table for Logic Module
-
8/12/2019 04_Chapter 4 - Modular Comb Logic_2
134/158
Function Table for Logic Module
S2=0
s2 s1 s0 Function
0 0 0 F=AB0 0 1 F=A+B (logical OR)
0 1 0 F=NOT A
0 1 1 F=A XOR B
We can use a 4x1 mux toimplement this module
Logic Module Design
-
8/12/2019 04_Chapter 4 - Modular Comb Logic_2
135/158
Logic Module Design
OR
NOT
XOR
AND
A
B
C
D
4
X
1F
S[1..0]
S1 S0
A
A
B
F
A
B
F
A
B
F
A F
B
Logic Module Design
-
8/12/2019 04_Chapter 4 - Modular Comb Logic_2
136/158
Logic Module Design
OR
NOT
XOR
AND
A
B
C
D
4
X
1F
S[1..0]
S1 S0
A
A
B
F
A
B
F
A
B
F
A F
B
AND OperationS[1..0]=00
0 0
F=AB
Logic Module Design
-
8/12/2019 04_Chapter 4 - Modular Comb Logic_2
137/158
Logic Module Design
OR
NOT
XOR
AND
A
B
C
D
4
X
1F
S[1..0]
S1 S0
A
A
B
F
A
B
F
A
B
F
A F
B
OR OperationS[1..0]=01
0 1
F=A+B
Logic Module Design
-
8/12/2019 04_Chapter 4 - Modular Comb Logic_2
138/158
Logic Module Design
OR
NOT
XOR
AND
A
B
C
D
4
X
1F
S[1..0]
S1 S0
A
A
B
F
A
B
F
A
B
F
A F
B
NOT OperationS[1..0]=10
1 0
F=A
Logic Module Design
-
8/12/2019 04_Chapter 4 - Modular Comb Logic_2
139/158
Logic Module Design
OR
NOT
XOR
AND
A
B
C
D
4
X
1F
S[1..0]
S1 S0
A
A
B
F
A
B
F
A
B
F
A F
B
XOR OperationS[1..0]=11
1 1
F=A XOR B
-
8/12/2019 04_Chapter 4 - Modular Comb Logic_2
140/158
What do these logic modules
look like?
AND Module
-
8/12/2019 04_Chapter 4 - Modular Comb Logic_2
141/158
AND Module
ANDA
B
F
OR Module
-
8/12/2019 04_Chapter 4 - Modular Comb Logic_2
142/158
OR Module
OR
A
B
F
NOT Module
-
8/12/2019 04_Chapter 4 - Modular Comb Logic_2
143/158
NOT Module
NOTA F
XOR Module
-
8/12/2019 04_Chapter 4 - Modular Comb Logic_2
144/158
XOR Module
XOR
A
B
-
8/12/2019 04_Chapter 4 - Modular Comb Logic_2
145/158
Arithmetic Module
Lets use our ADD/SUB Module
Add/Sub Circuit Module
-
8/12/2019 04_Chapter 4 - Modular Comb Logic_2
146/158
Add/Sub Circuit Module
Add/SubModule
A
B
S
Add
A
B
Add
S
Function Table for Arithmetic Ops
-
8/12/2019 04_Chapter 4 - Modular Comb Logic_2
147/158
Function Table for Arithmetic Ops
s2 s1 s0 Function
1 0 0 F=A+B (Arithmetic)
1 0 1 F=A-B
1 1 0 F=A + 11 1 1 F=A - 1
Note:S0 can be use to indicate Addition or Subtraction.S1 can be use to indicate the B data input
Arithmetic Module Design
-
8/12/2019 04_Chapter 4 - Modular Comb Logic_2
148/158
Arithmetic Module Design
Add/SubModule
S0
A
B
Add
S
S
2
X
1
A
B
FVDD
S1
B
A
S
Arithmetic Module Design
-
8/12/2019 04_Chapter 4 - Modular Comb Logic_2
149/158
Arithmetic Module Design
Add/SubModule
S0
A
B
Add
S
S
2
X
1
A
B
FVDD
S1
B
A
S
00
F=A+B
S[1..0]=00
Arithmetic Module Design
-
8/12/2019 04_Chapter 4 - Modular Comb Logic_2
150/158
Arithmetic Module Design
Add/SubModule
S0
A
B
Add
S
S
2
X
1
A
B
FVDD
S1
B
A
S
10
F=A-B
S[1..0]=01
Arithmetic Module Design
-
8/12/2019 04_Chapter 4 - Modular Comb Logic_2
151/158
Arithmetic Module Design
Add/Sub
Module
S0
A
B
Add
S
S
2
X
1
A
B
FVDD
S1
B
A
S
01
F=A+1
S[1..0]=10
Arithmetic Module Design
-
8/12/2019 04_Chapter 4 - Modular Comb Logic_2
152/158
t et c odu e es g
Add/Sub
Module
S0
A
B
Add
S
S
2
X
1
A
B
FVDD
S1
B
A
S
11
F=A-1
S[1..0]=11
-
8/12/2019 04_Chapter 4 - Modular Comb Logic_2
153/158
Overall Design
We have
ALU Design
-
8/12/2019 04_Chapter 4 - Modular Comb Logic_2
154/158
g
Logic
Module
Arithmetic
Module
2x1
MUX
S[2]
A B
A
A
B
F
A
BF
S[1..0]
S[1..0]
B
F F
Logic Module Design
-
8/12/2019 04_Chapter 4 - Modular Comb Logic_2
155/158
g g
OR
NOT
XOR
AND
A
B
C
D
4
X
1F
S[1..0]
S1 S0
A
A
BF
A
B
F
A
B
F
A F
B
Arithmetic Module Design
-
8/12/2019 04_Chapter 4 - Modular Comb Logic_2
156/158
g
Add/Sub
Module
S0
A
B
Add
S
S
2
X
1
A
B
FVDD
S1
B
A
S
Total Design
-
8/12/2019 04_Chapter 4 - Modular Comb Logic_2
157/158
g
OR
NOT
XOR
AND
A
B
C
D
4X1
F
S[1..0]
Add/SubModule
A
S
S0
A
B
Add
S
B
S
F2X1
S2
S
2X1
A
B
FVDD
S1 S0
S1
A B
A
B
F
A
BF
A
B
F
A F
Logic Module
Arithmetic Module
-
8/12/2019 04_Chapter 4 - Modular Comb Logic_2
158/158
End of Chapter 4