Lecture3 Combinational Logic v3
Lecture3 Combinational Logic v3
ECSE 1104
Digital Circuits and Systems
Presentation Outline
❖ Multiplexers
n to 2n
than 2n outputs if some
Decoder
input codes are unused
Examples of Binary Decoders
Inputs Outputs
0 d0 a1 a0 d0 d1 d2 d3
4 Outputs
2 Inputs
a1 1 2-to-4 1 d1 0 0 1 0 0 0
Truth
a0 0 2 d2 0 1 0 1 0 0
Decoder Tables
3 d3 1 0 0 0 1 0
1 1 0 0 0 1
Inputs Outputs
0 d0
a2 a1 a0 d0 d1 d2 d3 d4 d5 d6 d7
1 d1
0 0 0 1 0 0 0 0 0 0 0
2 d2 8 Outputs 0 0 1 0 1 0 0 0 0 0 0
a2
3 Inputs
2
3-to-8 3 d3 0 1 0 0 0 1 0 0 0 0 0
a1 1
Decoder 4 d4 0 1 1 0 0 0 1 0 0 0 0
a0 0
5 d5 1 0 0 0 0 0 0 1 0 0 0
6 d6 1 0 1 0 0 0 0 0 1 0 0
d7 1 1 0 0 0 0 0 0 0 1 0
7
1 1 1 0 0 0 0 0 0 0 1
Decoder Implementation
Inputs Outputs 𝑎2
a1 a0 d0 d1 d2 d3 3-to-8 Decoder
0 0 1 0 0 0
𝑎1
0 1 0 1 0 0 𝑎0 𝑑0 = 𝑎2′ 𝑎1′ 𝑎0′
1 0 0 0 1 0
1 1 0 0 0 1
𝑑1 = 𝑎2′ 𝑎1′ 𝑎0
2-to-4
𝑎1
Decoder 𝑑2 = 𝑎2′ 𝑎1 𝑎0′
1-to-2 Decoder
0 1 1 0 0 0 1 0 0 0 0
1 0 0 0 0 0 0 1 0 0 0
0 d4
1 Bottom
1 0 1 0 0 0 0 0 1 0 0
1 d5
0 2-to-4
Decoder
2 d6
1 1 0 0 0 0 0 0 0 1 0
EN 3 d7
1 1 1 0 0 0 0 0 0 0 1
Building Larger Decoders
a1 1 0 d0
2-to-4
1 d1
A 4-to-16 a0 0 Decoder
2 d2
0
EN 3 d3
decoder with
enable can be 1 0 d4
2-to-4
1 d5
built using five 0 Decoder
2 d6
0 1
a3 1 EN 3 d7
2-to-4 decoders 2-to-4 1
a2 0
Decoder 2 d8
with enables 1 2-to-4
0
EN EN 3 1 d9
0 Decoder
2 d10
2
EN 3 d11
a
I3 BCD to b
I2 c
❖ BCD to 7-Segment Decoder I1
7-Segment d
e
Called also a decoder, but not a binary decoder I0 Decoder f
g
Accepts as input a BCD decimal digit (0 to 9)
Generates output to the seven LED segments to display the BCD digit
Each segment can be turned on or off separately
BCD to 7-Segment Decoder
Specification: Truth Table
Input: 4-bit BCD (I3, I2, I1, I0) BCD input 7-Segment Output
I3 I2 I1 I0 a b c d e f g
Output: 7-bit (a, b, c, d, e, f, g)
0 0 0 0 1 1 1 1 1 1 0
Display should be OFF for Non-BCD 0 0 0 1 0 1 1 0 0 0 0
input codes. 0 0 1 0 1 1 0 1 1 0 1
0 0 1 1 1 1 1 1 0 0 1
Implementation can use: 0 1 0 0 0 1 1 0 0 1 1
A binary decoder 0 1 0 1 1 0 1 1 0 1 1
0 1 1 0 1 0 1 1 1 1 1
Additional gates
0 1 1 1 1 1 1 0 0 0 0
1 0 0 0 1 1 1 1 1 1 1
1 0 0 1 1 1 1 1 0 1 1
1010 to 1111 0 0 0 0 0 0 0
Implementing a BCD to 7-Segment Decoder
Truth Table
a
I3 I2 I1 I0 a b c d e f g
0
b 0 0 0 0 1 1 1 1 1 1 0
1
2 0 0 0 1 0 1 1 0 0 0 0
c
I3 3 0 0 1 0 1 1 0 1 1 0 1
4-to-10
I2 4 0 0 1 1 1 1 1 1 0 0 1
d
Binary 5 0 1 0 0 0 1 1 0 0 1 1
I1
I0 Decoder 6 e 0 1 0 1 1 0 1 1 0 1 1
7 0 1 1 0 1 0 1 1 1 1 1
8 0 1 1 1 1 1 1 0 0 0 0
9 f 1 0 0 0 1 1 1 1 1 1 1
1 0 0 1 1 1 1 1 0 1 1
𝐼3(𝐼2 + 𝐼1 ) g 1010 – 1111 0 0 0 0 0 0 0
Input > 9
NOR gate is used for 0's
Encoders
❖ An Encoder has 2n binary inputs and n
outputs.
❖ Multiplexers
2n Inputs
d2
Mux
. Y
An n-bit select input S used for control .
.
d2n–1
One output Y n
S
❖ The n-bit select input directs one of the data inputs to the output
Examples of Multiplexers
❖ 2-to-1 Multiplexer Inputs Output
d0 0
if (S == 0) Y = d0 ; S d0 d1 Y
Mux
Y
else Y = d1; 0 0 X 0 = d0
d1 1
0 1 X 1 = d0
Logic expression: 1 X 0 0 = d1
S 1 X 1 1 = d1
𝑌 = 𝑑0 𝑆 ′ + 𝑑1 𝑆
❖ 4-to-1 Multiplexer d0 0 Inputs Output
d1 1 S1 S0 d0 d1 d2 d3 Y
Mux
if (S1S0 == 00) Y = d0 ; 𝑌 0 0 0 X X X 0 = d0
d2 2
else if (S1S0 == 01) Y = d1; 0 0 1 X X X 1 = d0
d3 3
else if (S1S0 == 10) Y = d2; 0 1 X 0 X X 0 = d1
S1S0 0 1 X 1 X X 1 = d1
else Y = d3; 1 0 X X 0 X 0 = d2
1 0 X X 1 X 1 = d2
Logic expression:
1 1 X X X 0 0 = d3
𝑌 = 𝑑0 𝑆1′ 𝑆0′ + 𝑑1 𝑆1′ 𝑆0 + 𝑑2 𝑆1 𝑆0′ + 𝑑3 𝑆1 𝑆2 1 1 X X X 1 1 = d3
Implementing Multiplexers
d0
d0 0
Mux
𝑌 = 𝑑0 𝑆 ′ + 𝑑1 𝑆 Y
d1
d1 1
Enabling
S AND Gates
S
d0
d0 0
d1
d1 1
Mux
𝑥 𝑓 𝑥 𝑓 𝑥 𝑓
inverted c inverted f inverted c, f
c x f c x f c x f
0 0 0 0 0 Z 0 0 1
0 1 1 0 1 Z 0 1 0
1 0 Z 1 0 1 1 0 Z
1 1 Z 1 1 0 1 1 Z
Wired Output
Logic gates with 0 and 1 𝑎 This will result in a
𝑏
outputs cannot have their 𝑓 short circuit that
𝑐
outputs wired together 𝑑 will burn the gates
𝑐1 c1 c2 c3 f
3-state gates can wire 0 0 0 Z
their outputs together 𝑥1 1 0 0 x1
𝑐2 0 1 0 x2
At most one 3-state gate 0 0 1 x3
𝑥2 𝑓
can be enabled at a time 0 1 1 Burn
𝑐3 1 0 1 Burn
Otherwise, conflicting 1 1 0 Burn
𝑥3
outputs will burn the circuit 1 1 1 Burn
Implementing Multiplexers with 3-State Gates
Mux
𝑌
d2 2 3-State
1. A decoder Gates
d3 3
2. Three-state gates d0
S1S0
3-State
d1
Gates Y
d0 0 d0 d2
Mux
Y Y
d1 1 d1 d3
S 0 1 2 3
S S1 1 2-to-4
1-to-2
Decoder S0 0 Decoder
Building Larger Multiplexers
Larger multiplexers can be built hierarchically using smaller ones
d0 0 d0 0
d0 0 d1 1 d1 1
Mux
Mux
d2 d2 2
8-to-1 Mux
d1 1 2
0 d3 3
d3
Mux
3 Y
S0 Y
1 0 d4 4
Mux
d2 0 S1S0 Y d5 5
Mux
S1 1
d3 1 d4 0 d6 6
S2 d7 7
d5 1
Mux
S0
d6 2 S2S1S0
d7 3
A [m–1:0] 0
A [m–1:0] 0 m
m B [m–1:0]
Mux
1
Mux
Y [m–1: 0] m Y [m–1: 0]
B [m–1:0] m C [m–1:0] 2 m
1 m
m D [m–1:0] 3
m
S
S1S0
8-to-1 Mux
used as select 0 0 1 1
0 3
lines to a Mux.
0 1 0 1 F
0 1 1 0 0 4
An 8-to-1 1 0 0 0 0 5
Mux is used 1 0 1 0 1 6
because there 1 1 0 1 1 7 1
0
2
1 1 1 1
are 3 variables
S2 S1 S0 = a b c
Better Solution with a Smaller Multiplexer
❖ Re-implement F(a, b, c) = ∑(1, 2, 6, 7) using a 4-to-1 Mux
❖ We will use the two select lines for variables a and b
❖ Variable c and its complement are used as inputs to the Mux
4-to-1 Mux
0 1 0 1
F = c' c' 1
0 1 1 0 F
1 0 0 0 0 2
F=0
1 0 1 0
1 1 0 1 1 3 1 0
F=1
1 1 1 1
S1 S0 = a b
Implementing Functions: Example 2
Implement F(a, b, c, d) = ∑(1,3,4,11,12,13,14,15) using 8-to-1 Mux
Inputs Output Comment
a b c d F F
0 0 0 0 0 d 0
0 0 0 1 1
F=d
0 0 1 0 0 1
0 0 1 1 1
F=d
2
8-to-1 Mux
0 1 0 0 1
0 1 0 1 0
F = d'
0 3
0 1 1 0 0 F
0 1 1 1 0
F=0 4
1 0 0 0 0 5
1 0 0 1 0
F=0
1 0 1 0 0 1 6
1 0 1 1 1
F=d
0
1 1 0 0 1
72 1
1 1 0 1 1
F=1
1 1 1 0 1
F=1 S2 S1 S0 = a b c
1 1 1 1 1
Next . . .
❖ Decoders
❖ Multiplexers
m m A[m–1:0] 0 m
Mux
A[m-1:0] X [m-1:0] m X [m-1:0]
2×2 1
B[m–1:0]
Crossbar m
m m S
B[m-1:0] Switch Y [m-1:0]
0 m
Mux
Y [m-1:0]
1
S
BINARY CODED HEXADECIMAL 7 SEGMENT
DECODER
Truth Table
Specification:
BCD input 7-Segment Output
Input: 4-bit BCD (I3, I2, I1, I0) I3 I2 I1 I0 a b c d e f g
Output: 7-bit (a, b, c, d, e, f, g) 0 0 0 0 1 1 1 1 1 1 0
0 0 0 1 0 1 1 0 0 0 0
1. Use a 4 to 16 Decoder to implement
0 0 1 0 1 1 0 1 1 0 1
a Hexadecimal Display Decoder that
0 0 1 1 1 1 1 1 0 0 1
will display the letters A b C d E F for 0 1 0 0 0 1 1 0 0 1 1
non-BCD 0 1 0 1 1 0 1 1 0 1 1
2. Using basic logic gates implement 0 1 1 0 1 0 1 1 1 1 1