Professional Documents
Culture Documents
EEE241
Combinational Logic
1
Combinational Logic
Outline
Combinational Circuits
Analysis
Design
Binary Adder/Subtractor
Multiplier
Comparator
Encoder/Decoder
Multiplexers/Demultiplexers
2
Combinational Circuits
Recall
Single/multiple inputs Single output
Many realistic problems use multiple outputs
Named as combinational circuits
Combinational circuit
Output depends only on input(s)
3
Combinational Circuits
What happens if we add memory to the circuit?
4
Combinational Circuit Analysis
Determine the function of circuit
Instead of developing the circuit based on the function
Circuit analysis
Determine the output functions as algebraic expressions
Determine the truth table of the outputs
What is the output function of this circuit?
5
Combinational Circuit Analysis
Analysis steps
1. Label all gate outputs with symbols
2. Determine Boolean function at the output of each gate
3. Express functions in terms of input variables + simplify
6
Combinational Circuit Analysis
Substitution
T1 ( xy )
T2 ( xT1 )
T3 ( yT1 )
F (T2T3 ) (( xT1 )( yT1 ))
xT1 yT1 x( xy ) y ( xy )
x( x y) y ( x y)
xx xy xy yy
xy xy x y
7
Combinational Circuit Analysis:
Example
What are the outputs F1 and F2 of the following circuit?
Here
T2 = ABC
T1 = A+B+C
F2 = AB + AC + BC
T3 = F 2 ’ T 1
F1 = T 3 + T 2
8
Combinational Circuit Analysis:
Example
Analysis by truth table
9
Combinational Circuit Design
Design procedure
1. Determine the number of inputs and outputs
2. Assign symbols
3. Derive the truth table
4. Obtain simplified functions for each output
5. Draw the logic diagram
Issues to consider
Number of gates
Gate inputs
Propagation delay
Number of interconnections
10
Combinational Circuit Design: Example
11
Combinational Circuit Design: Example
12
Combinational Circuit Design: Example
Step 4: Simplification
z = D’
y = CD+C’D’
= CD+(C+D)’
x = B’C+B’D+BC’D’
= B’(C+D)+BC’D’
= B’(C+D)+B(C+D)’
w = A+BC+BD
= A+B(C+D)
13
Binary Adders
Addition is important function in computer system
14
Binary Half Adder
Specification
Design a circuit that adds two bits and generates the sum and a carry
Input/Output
Two inputs: x, y
Two outputs: S (sum), C (carry)
Functionality
15
Binary Half Adder
16
Full Adder
Half adder works only for a single bit
When multiple bits are involved, carry bits should be considered
Solution Full adder
Specifications
A circuit that adds three bits and
generates a sum and a carry
Input/output
Three inputs: x, y, Cin
Two outputs: S (Sum), Cout (Carry)
Truth table
17
Full Adder
Derive and minimize Boolean expressions
18
Full Adder
Circuit
19
Full Adder from Half Adders
Observations
Three inputs x, y, z can be added in two steps
x+y+z = (x+y) + z
What about the carry?
Carry can occur when adding x+y and when adding z
20
Binary n-bit Adder
How can we build an n-bit adder from full adders?
One adder for each bit (n total)
Connect carry to next adder’s input
Output: sequence of sums and a final carry
4-bit adder circuit (Ripple Carry Adder)
21
Full Adder from Half Adders
22
Ripple Carry Adder
How long does it take to complete an addition?
Carry needs to propagate through circuit – a problem
Let’s look at S3
Inputs A3 and B3 are available immediately.
However, C3 is available only after C2 is available.
C2 has to wait for C1, etc.
24
Carry-Lookahead Adder
Full adder: Si = AiBiCi , Ci+1 = Ai.Bi + (AiBi).Ci
Create new signals
Gi = Ai.Bi carry generate for stage i
Pi = Ai Bi carry propagate for stage I
25
Carry-Lookahead Adder
27
4-bit Adder with Carry Lookahead
Complete adder
Same number of stages
for each bit
Drawback?
Increasing complexity of
lookahead logic for more
bits
28
Subtraction
Do we need subtractors?
Actually not
Subtraction can be done using adders
N – M = N + (2’s complement of M)
How do we determine 2’s complement?
1’s complement and adds 1
29
Subtraction
30
Binary Subtractor
Adder/Subtractor circuit
31
Overflow
n-bit addition can generate (n+1)-bit number
Called “overflow”
Needs to be detected by computer system
How to begin?
Truth table
Can we use existing circuit?
Binary adder
Almost works for
decimal addition
34
BCD Adder (Truth Table)
35
BCD Adder (Truth Table)
36
BCD Adder
37
BCD Adder
38
BCD Adder
39
Multiplier
Product is 1 when both inputs are 1
Which gate can be used?
AND
2-bit multiplier
41
Multiplier
4-bit x 3-bit multiplier
J=3, K=4
42
Magnitude Comparator
Need to compare two numbers: A and B
A>B, A<B, A=B
Which gate?
XNOR (Equivalence)
Functionality (4-bits)
If difference in first digit: A3B3′
If difference in second digit: x3A2B2′
Conditional that A3 = B3 (x3 =1 if : A3=B3 )
Similar for all other digits
For A > B
(A > B) = A3B3′ + x3A2B2′ + x3x2A1B1′ + x3x2x1A0B0′
44
Magnitude Comparator
Case 2: A < B
swap A and B for A > B
Functionality
(A = B) = x3x2x1x0
(A > B) = A3B3′ + x3A2B2′ +
x3x2A1B1′ + x3x2x1A0B0′
(A < B) = A3′B3+ x3A2′B2 +
x3x2A1′B1 + x3x2x1A0′B0
Encoders (Enc)
Decoders (Dec)
Multiplexers (Mux)
De-multiplexers (DeMux)
Tri-state logic
46
Motivation – ALU Design
ALU – Arithmetic and Logic Unit
Add, Subtract, AND, OR
47
Motivation – CPU Design
Instruction Management
48
Decoder
Selects one output based on a binary input
Converts n-bit code into 2n outputs, only one being active
at a time
Selects output x if input is binary representation of x
Applications
Binary-to-octal decoder
Memory address selection
Selection of any kind
49
Decoder
Example: 3-to-8-line decoder
50
Decoder: Circuit
When is output 0 chosen?
If x’ y’ z’
51
Advanced Decoder
Sometimes, you need to activate circuits
Reason: Take output only when required
Solution: Use enable pins
Decoder with enable
Generates output only when active-low enable is high
Example:
2-to-4-line decoder with enable
NAND implementation
52
Advanced Decoder
Enable bit allows construction of large decoders using
smaller ones
Example: Construct a 4-to-16 decoder only using 3-to-8
decoders
Active-high enable
53
Decoders: Example
Design a full adder using a 3-to-8-line decoder
Truth table
54
Encoders
Translates 2n input lines into n output lines
Input: 2n lines
Output: n bits
Output is binary coding of input that is 1
55
Encoders
x = D 4 + D5 + D 6 + D 7
y = D 2 + D3 + D 6 + D 7 How many OR gates are required?
56
Encoders: Problems
Only one input can be active at a time
Simultaneous active inputs result in undefined output
When all inputs are zero x = D4 + D5 + D6 + D7
Equal to the case when D0 is 1
y = D2 + D3 + D6 + D7
z = D1 + D3 + D5 + D7
Example
If D3 and D6 are active simultaneously, what is the
output?
111
57
Priority Encoder
Simple encoder, with additional functionality
If multiple inputs are 1, give priority to one of them
58
Priority Encoder
Valid bit V = D0 + D1 + D2 + D3
59
Priority Encoder
Circuit diagram
x = D 2 + D3
y = D 3 + D 1 D2’
V = D0 + D 1 + D 2 + D 3
60
Multiplexer (MUX)
Selects from 1 of many inputs and directs it to the output
Input
2n lines
Output
1 line
61
Multiplexer (MUX)
Example
2-to-1 MUX
How to design?
4-to-1 MUX
Selection code directs input
62
4-to-1 MUX
63
Multiplexer (MUX)
A MUX only selects one bit
(output)
How to select multiple bits
(outputs)?
Example: What if you want to
choose one of two 4-bit
numbers?
Solution: Use multiple MUX
64
Use MUXes for Boolean Functions
MUXes can also be used to implement the Boolean
function
Use MUX to implement the following function
Concept
MUX is a decoder + OR gate
Use the selector to direct correct value to output
65
Use MUXes for Boolean Functions
Example
F(x,y,z) = (1,2,6,7)
Truth table
66
Use MUXes for Boolean Functions
67
Use MUXes for Boolean Functions
Example
F(x,y,z) = (1,3,4,11,12,13,14,15)
68
Use MUXes for Boolean Functions
69
Demultiplexer (DeMUX)
Receives information from 1 input and directs it to one of
2n possible outputs
Input
Data bit
n selection lines
Output
2n lines
Expressions
S(x,y,z) = Σ(1,2,4,7); C(x,y,z) = Σ(3,5,6,7)
71
Use MUXes for Boolean Functions
72
Three-State (Tri-state) Gates
What is the truth table for F ?
Three state:
0 or 1 Boolean value
“High impedance”, Z state
High impedance acts as if gate were disconnected
73
Multiplexer with Tri-state Gates
2-to-1 MUX
74