Chapter 3
Chapter 3
Logic
Circuit
m Boolean Inputs
n Boolean Outputs
Design Issues
Modern complex circuits and system involves a number of techniques and tools
Design Hierarchy
Top-Down Design
Computer Aided Design
Hardware Description Languages (HDL)
Logic Synthesis
Beginning Hierarchical Design
To control the complexity of the function mapping inputs to
outputs:
• Decompose the function into smaller pieces called blocks
• Decompose each block’s function into smaller blocks, repeating as
necessary until all blocks are small enough
• Any block not decomposed is called a primitive block
• The collection of all blocks including the decomposed ones is a
hierarchy
Example: 9-input parity tree (see next slide)
• Top Level: 9 inputs, one output
• 2nd Level: Four 3-bit odd parity trees in two levels
• 3rd Level: Two 2-bit exclusive-OR functions
• Primitives: Four 2-input NAND gates
• Design requires 4 X 2 X 4 = 32 2-input NAND gates
Hierarchy for Parity Tree Example
X0
X1
X2
9-Input
X3
X4 odd Z O
X5 function
X6 X0 A0
3-Input
X7
X8 X1 A1 odd B O
function
X A2
(a) Symbol for circuit 2
X 3
A0 A 0
3-Input 3-Input
X4 A1 odd B A odd B Z
O 1 O O
function function
X5 A2 A 2
X6 A0
3-Input
X7 A1 odd B O
function
X8 A2
function blocks
A0
A1 B O
A2
interconnected exclusive-OR
blocks
NANDs
Reusable Functions
Whenever possible, we try to decompose
a complex design into common, reusable
function blocks
These blocks are
• verified and well-documented
• placed in libraries for future use
Top-Down versus Bottom-Up
A top-down design proceeds from an abstract, high-level
specification to a more and more detailed design by
decomposition and successive refinement
A bottom-up design starts with detailed primitive blocks
and combines them into larger and more complex
functional blocks
Design usually proceeds top-down to known building
blocks ranging from complete CPUs to primitive logic
gates or electronic components.
Much of the material in this chapter is devoted to
learning about combinational blocks used in top-down
design.
Computer-Aided Design
Design of complex systems and Integrated circuits by the use of CAD tool.
Functional blocks, level of primitive, libraries of graphics symbols.
Allow the behavior and timing of the hierarchical blocks are verified by logic
simulator to determine the output.
Logic synthesizers provides the physical area information and delay parameters
for optimized design.
Hardware Description Languages
combinational logic.
General directives may be given which specifies that area is to be minimized and
maximize speed.
complements with arbitrary symbols. Determine the Boolean functions for each
gate output.
2. Label the gates that are a function of input variables and previously labeled
gates with different arbitrary symbols. Find the Boolean function for the outputs
of these gates.
3. Repeat the process outlined in step 2 until the outputs of the circuit are obtained
a. 2-level using
0 1 3 2 0 1 3 2
1 1 1 1
K-maps
4 5 7 6 4 5 7 6
X X X X B X X X X B
12 13 15 14 12 13 15 14
W = A + BC + BD A 1
8 9
X
11
X
10
A 1
8 9
X
11
X
10
X = B’C+B’D + BC’D’
D D
Y = CD + C’D’
Z = D’
C C
x w
1 1 1
0 1 3 2 0 1 3 2
1 1 1 1
4 5 7 6 4 5 7 6
X X X X B X X X X B
12 13 15 14 12 13 15 14
A 1 X X A 1 1 X X
8 9 11 10 8 9 11 10
D D
Design Example (continued)
3. Optimization (continued)
W=A+B(C+D)
X=B’(C+D)+BC’D’
Y=(C D)’
Z=D’
Design Example (continued)
4. Logic Diagram
Basic Verification Methods
Manual Logic Analysis
• Find the truth table or Boolean equations for the final circuit
• Compare the final circuit truth table with the specified truth
table, or
• Show that the Boolean equations for the final circuit are equal
to the specified Boolean equations
Simulation
• Simulate the final circuit (or its netlist, possibly written as an
HDL) and the specified truth table, equations, or HDL
description using test input values that fully validate
correctness.
• The obvious test for a combinational circuit is application of all
possible “care” input combinations from the specification
Verification Example: Simulation
Run the simulation of the circuit for 120 ns
INPUTS
A
B
C
D
OUTPUTS
W
X
Y
Z
output. The output must be logic 1 when the binary value of the
NAND gates.
• Design a BCD to Seven Segment Decoder circuit. Use NOR
An-1 Dm-1
Decoder examples
BCD to 7-segment decoder: a
a
b
decoder
b
Binary to ASCII. BCD c
:
code
Address decoder in a memory:
:
Row
Example: 4Mbit DRAM Decoder
1
1
MATRIX OF
22
No. of memory positions: 2 Row MEMORY
Data
2-to-4 line decoder
Table:
A 1 A 0 D 0 D D2 D
1 3
0
D0
A0 0
0 0 1 0 0 0
2-4 line 1
D1 0 1 0 1 0 0
Decoder
2
1 0 0 0 1 0
D2
1 ?
A1 1 1 0 0 0 1
3
D3
Logic expressions:
only one of the inputs is active D0 = A 1 A0
D1 = A 1 A0
minterms
D2 = A 1 A0
D3 = A 1 A0
2-to-4 Line Decoder circuit
A 0
A 1
D0 = A 1 A0
D1 = A 1 A0
D2 = A 1 A0
D3 = A 1 A0
Di=mi
Decoder Expansion
Larger decoders can be realized by
implementing each minterm using a single
AND gate:
• However for large decoders this requires
multiple input AND gates which is not always
feasible.
• Better to use a hierarchical approach: build
larger ones from smaller decoders.
Approach:
• Output AND gates have only 2 inputs and
implement the minterms.
• The output AND gates are driven by two
decoders with their numbers of inputs either
equal or differing by 1.
Decoder Expansion - Example 1
3-to-8-line decoder
• Number of output ANDs = 8 A’1A’0 A2’A1’A0’
• Number of inputs: 3 A0
A2’A1’A0
A’1A0
2-4
Decoder A2’A1A0’
A1’A0
A1
A’1A’0 A2’A1A0
D0 A1A0
A0
A’1A0
2-4 D1 A’2
A2 A2A1’A0’
Decoder
AA0’ A2
A1 D2
A1A0 1-to-2
D3 decoder
A2A1A0
3-to-8 decoder
Further Decoder Expansion of
Example 1
Rule for building large decoders
k-to-2k decoder:
• One needs 2k output AND gates
• If k can be divided by 2:
use two k/2-to-2k/2 decoders
• If k cannot divided by 2:
use a (k+1)/2 and
use a (k-1)/2 decoder.
Previous example: 3-to-8 decoder
(k=3):
• Use a 2-to-4 and a 1-to-2 decoder
Example : build a 4-to-16 decoder
D0
A3’A2’ :
A2 A3’A2
:
2-4 D1
Decoder
D2
A3 A3A2
D14 A3A2A1A0’
D3
D15 A3A2A1A0
Decoder Expansion - Exercise 2
5-to-32-line decoder
• Number of output ANDs = ?
• Number of inputs to decoders driving output
ANDs = ?
• Which decoders to use to drive the output
ANDs?
• Block diagram:
5-to-32-line decoder
A4’A3’ A2’A1’A0’
D0
A2’A1’A0’ D0
A2’A1’A0 A4’A3’ A2’A1’A0
A0 D1
D1
D2
3-8
D3 D2
A1
Decoder
D3
A2 D4
D7
D0
A4’A4’ D7
A3 A3’A2
2-4 D1
Decoder
:
A4 D2
A4A3
:
D30
D3 A2A1A0
A4A3
D31
Decoder Expansion - Example 2
7-to-128-line decoder
• Number of output ANDs = ?
• Number of inputs to decoders driving
output ANDs = ?
• Closest possible split to equal
Decoder with Enable
Extra input EN:
If EN = 1: act as a regular decoder 0
D0
A0
If EN=0, all outputs are 0 2-4
D1
Decoder
D2
A1 1
D3
EN
D0 of ands
A0 0
2-4
D1
Decoder
D2
A1 1
D3
EN
Regular decoder
EN=IN Demux 1
D1
2
D2
1 0
3
D3
A1 A0
Combinational Logic Implementation
- Decoder and OR Gates
2
010 0
B 1 3
F
011 1 4
0 5
100 0 C
Minterms: 101 1
6
• F=m(3,5,6,7) 110 1
Implementation using
111 1 decoder:
Exercise
Implement the functions using a 3-to-8 decoder:
• F2(ABC)=m (0,2,3,5,6,7)
• F3=AB’ + BC
• F4(ABC)= A + B + C’
Answer
• For F2(ABC)=m (0,2,3,5,6,7) implement
= m5 + m4 + m7 + m3
• F4=A+B+C’:
now F4’=A’B’C=m1 Thus F4=m1’ (needs an inverter);otherwise:
F4=m0+m2+m3+m4+m5+m6+m7
Exercise
Implement the function F using a 2-to-4 decoder and two tri-state buffers
F=C(AB+A’B’)
Exercise - solution
Implement the function F using a 2-to-4 decoder and two tri-state buffers
B 0
1 B’C F
A
1
2
0
C 3 BC
Exercise
Can you also implement F using a 2-to-4 decoder with enable input and an OR gate?
F=C(AB+A’B’)
Exercise - solution
1. Using a 2-to-4 decoder with enable input and an OR gate:
A’B’
A 0
1
1 F
2
0
B 3 AB
EN
C
Exercise
Can you also implement F using a 2-to-4 decoder with enable input and an NOR gate?
F=C(AB+A’B’)
Encoders
An encoder is a digital function that
performs the inverse operation of a
decoder.
An encoder has 2n (or fewer) input lines
and n outputs lines.
The output lines generate the binary code
corresponding to the input value.
E.g. Octal to binary encoder
Encoding
D0
A0
D1
m-elements encoder n output
:
n :
≤2 bits
:
:
An-1
Dm-1
m elements encoding
n-bit binary code
decoding
D0
A0
D1
2-to-4 m-elements
:
n bits : n
decoder ≤2
: :
An-1 Dm-1
Encoding
Typically, an encoder converts a code
containing exactly one bit that is 1 to a binary
code corresponding to the position in which the
1 appears: ex. D1=1 output 0001
0
0 D0 0
1 A0 1
1 D1
encoder
2
1
3
: 0
0 :
2 :
0 : 0
An-1
0 Dm-1 n-1
m-1
0
D9 3
A3
9
D8
8
1 2 3 D7 7
6 A2
2
4 5 6
encoder
7 8 9 A1
1
0
A0
D0 0
0
A decimal-to-BCD encoder
• Inputs: 10 bits corresponding to decimal digits 0 through 9, (D 0, …, D9)
• Function: If input bit Di is a 1, then the output (A 3, A2, A1, A0) is the BCD code for
i,
Truth table of the decimal-to-BCD
encoder
D9 D8 D7 D6 D5 D4 D3 D2 D1 D0 A3 A2 A1 A0
0 0 0 0 0 0 0 0 0 1 0 0 0 0
0 0 0 0 0 0 0 0 1 0 0 0 0 1
0 0 0 0 0 0 0 1 0 0 0 0 1 0
0 0 0 0 0 0 1 0 0 0 0 0 1 1
0 0 0 0 0 1 0 0 0 0 0 1 0 0
0 0 0 0 1 0 0 0 0 0 0 1 0 1
0 0 0 1 0 0 0 0 0 0 0 1 1 0
0 0 1 0 0 0 0 0 0 0 0 1 1 1
0 1 0 0 0 0 0 0 0 0 1 0 0 0
From table: 1 0 0 A3
0 = D8
0 + D9
0 0 0 0 0 We 1
made
0 use
0 of1 the fact that
A2 = D4 + D5 + D6 + D7 only one input can be “1” at
A1 = D2 + D3 + D6 + D7 one time
A0 = D1 + D3 + D5 + D7 + D9
Assignments
• Design the following Encoder circuit
processor
A1
D1 1
To
?
D2 2
0 A0
D3 3
V
Priority Encoder Example
Priority encoder with 5 inputs (D4, D3, D2, D1, D0) - highest priority
is given to most significant 1 present - Code outputs A2, A1, A0
and V where V indicates at least one 1 present.
0 0 0 0 0 X X X 0
1
0 0 0 0 1 0 0 0 1
1 0
0 0 0 1 X0
1 0 0 1 1
2 1
4 0 0 1 X X 0 1 0 1
0 1 X X X 0 1 1 1
8
1 X X X X 1 0 0 1
16
Priority Encoder Example (continued)
A2 = D4
D4=
A1 D3 + D4D2D3
A0 =
V=
Priority Encoder Example (continued)
A2 = D4
D4=
A1 D3 + D4D2D3 D4= F1, F1 = (D3 + D2)
A0 = D3D4
+ D1D4
= D3
(D3D2
+ D1) D4 D2
V = D4 + F1 + D1 + D0
Exercise: design a 4 input priority
encoder with active low inputs
Table:
D0 0
1
A1
D1 1 D3 D2 D1 D0 A1 A0 V
?
D2 2
0 A0 1 1 1 1 x x 0
D3 3
V 1 1 1 0 0 0 1
1 1 0 x 0 1 1
1 0 x x 1 0 1
0 x x x 1 1 1
Expressions:
V = (D3.D2.D1.D0)’
Selecting (multiplexers)
Selecting of data or information is a critical
function in digital systems and computers
Circuits that perform selecting have:
• A set of n information inputs from which the selection is
made
• A set of k control (select) lines for making the selection
• A single output
I0 0
I1 1
I2 2
k
n ≤ 2 inputs I3 3 OUT
In-1 k-1 .. 1 0
n-1
Sk-1..S1 S0
k select lines
Multiplexer equivalent
I0
0
I1
1 Out
I2 2
I3 3
1 0
(Ref.: F. Vahid, “Digital Design”, J. Wiley, 2007)
S1 S0
Many uses of multiplexers
In computers to select among signals
To implement command: X
0
Y Z
if A=0 then Z=XY
1
else Z=XY
A
Trip controller in a car to display mileage,
time, speed, etc.
odometer 1 4:1
2
speed 3
Display
1 0
S1 S0
Push button
mileage
Example of a 4-input MUX
4 inputs mux requires 2 select lines:
I0 I0
0 0
I1 I1 Out
1 Out 1
4:1
I2 2 I2 2
I3 3 I3 3
1 0
S1 S0
S1 S0
0 0 I0
0 1 I1
1 0 I2
1 1 I3
4:1 MUX realization
Expression for OUT
S1 S0 OUT
0 0 I0
1 0 I2
m0 m1 m2 m3
k 1 1 I3
2 -1
or OUT = Σ mi Ii
m1
I1
Y
m2 Y
I2
m3
I3
4:1 Quad Multiplexer
Quad refers to the fact that each
input consists of a 4-bit wide signal
(vector)
I0[3:0] 4
0
I1[3:0] 1
4
Out [3:0]
4:1
I2[3:0] 2
I3[3:0] 3
1 0
S1 S0
I0 0
I1 1
4:1
2
I2
3
I3 1 0
0
OUT
S1 S0
1
I4
0
I5 S2
1
4:1
I6 2
3
I7 1 0
Ex: S2S1S0=110 : select I6
S1 S0
Multiplexer-based combinational circuits
realization- Approach 1
A mux can be easily used to implement a
function defined by a truth table (lookup table)
Indeed the output F of a mux is equal to:
k
2 -1
F = Σ mi Ii Example
i=0
value of 0 or 1 0 0 I0 0 m0
3 F= Σm(1,2)
0 1 0
A B
Example: Gray to Binary Code
Design a circuit to Gray Binary
0 0 0 0 0 0
code to a binary code 10 0 0 01
010 01 1
the truth table on the 01 1 10 0
right 1 1 1 101
0 01 1 1 1
table that X = C and the
Y and Z are more complex
Gray to Binary (continued)
Rearrange the table so
that the input combinations Gray Binary
are in counting order ABC xyz
000 000
001 111
010 011
011 100
100 001
101 110
Functions y and z can 110 010
be implemented using 111 101
a dual 8-to-1-line
multiplexer by:
• connecting A, B, and C to the multiplexer select inputs
• placing y and z on the two multiplexer outputs
• connecting their respective truth table values to the inputs
Gray to Binary (continued)
Gray Binary
ABC xyz 0
0
D10
D00
000 000 1
1 D01 D11
001 111
1 D12
010 011 1 D02
A S2 A S2
8-to-1 8-to-1
B S1 B S1
MUX MUX
S0 C S0
C
Multiplexer-based combinational circuits
- Approach 2
A B OUT F
B 0
0 0 I0 0 F
B
0 1 I1 1 1
B
1 0 I2 1 B
1 1 I3 0
A
Exercise 1 (cont)
Implement the function
F(A,B,C)=Σm(0,1,2,5) using a 4:1 mux
A B C F
0 0 0 1 1
0 0 1 1 1 0
0 1 0 1 C C 1 F
4:1
C 2
0 1 1 0
0 3
1 0 0 0 C 1 0
1 0 1 1
A B
1 1 0 0 0
0 1 1 0
Assignments
Design a Binary Multiplier logic circuit which multiplies 4-Bit by
3-Bit Binary numbers.
Design a combinational circuit that accepts a 2-bit number and
generates a 4-bit binary number output equal to the square of the
input number.
Design a combinational circuit that compares two 4-bit unsigned
numbers A and B to see whether they are equal. The circuit has
one output X, so that X=1 if A<B and X=0 if A≥B.
Implement a binary full adder with a dual 4 to 1 line multiplexer
and a single inverter.
Implement the following Boolean function with an 8 to 1 line
multiplexer and a single inverter.
F(A, B, C, D)=m(2,3,5,6,8,9,12,14)