Professional Documents
Culture Documents
EE101 Lecture 9
EE101 Lecture 9
Lecture 9:
Implementing Logic Functions w/
Decoder, Multiplexers, and
Memories
3-to-8 Decoder
D0
D1
D2
3-bit binary
Z (LSB) 1 output for each
D3
number Y combination of the
D4
X (MSB) input number
D5
D6
D7
© Mark Redekopp, All rights reserved
Decoders
• A decoder is a building block that:
– Takes a binary number as input
– Decodes that binary number and activates the corresponding
output
– Put in 6=110, Output 6 activates (‘1’)
– Put in 5=101, Output 5 activates (‘1’)
D0 0
D1 0
D2 0
0 Z (LSB)
1 Y
D3 0
1 X (MSB)
D4 0
D5 0 Only that
D6 1 numbered output is
Binary #6
D7 0 activated
© Mark Redekopp, All rights reserved
Decoders
• A decoder is a building block that:
– Takes a binary number as input
– Decodes that binary number and activates the corresponding
output
– Put in 6=110, Output 6 activates (‘1’)
– Put in 5=101, Output 5 activates (‘1’)
D0 0
D1 0
D2 0
1 Z (LSB)
0 Y
D3 0
D4 0 Only that
1 X (MSB)
D5 1 numbered output is
D6 0 activated
Binary #5
D7 0
© Mark Redekopp, All rights reserved
Decoder Sizes
• A decoder w/ an n-bit input has 2n outputs
– 1 output for every combination of the n-bit input
Y0 1
Y1 0
Y2
0 A0 0
0 Y
D0
0 Y3 0
D1
0 0 A1
Y4
D2
1 0 A2 (MSB) 0
1 X (MSB)
0
D3
0 Y5
Y6
0
n inputs 2n outputs Y7 0
(2) (4)
n inputs 2n outputs
(3) (8)
2-to-4 3-to-8
Decoder Decoder
© Mark Redekopp, All rights reserved
Building Decoders
Checker O0
for 000
Checker O1
for 001
Checker O2
for 010
Checker O3
for 011
3-bit Checker
number O4
for 100
[A2:A0]
Checker O5
for 101
Checker O6
for 110
Checker O7
for 111
1 1 0 0 0 1
y D0
D0 = X’•Y’ y
x
1 1 0 0 0 1
y D0
D0 = X’•Y’ y
x
y D1
D1 = X’•Y x
x
1 1 0 0 0 1
y D0
D0 = X’•Y’ y
x
y D1
D1 = X’•Y x
x
y
D2
D2 = X•Y’ x
y
D3
D3 = X•Y x
1 1 0 0 0 1
y D0
D0 = X’•Y’ = m0 y
x
y D1
D1 = X’•Y = m1 Notice output n is x
x
just minterm, mn y
D2
D2 = X•Y’ = m2 x
y
D3
D3 = X•Y = m3 x
D2
minterm generators, O Z (LSB) F
D3
just OR together the N Y
D4
appropriate minterms M X (MSB)
D5
D6
D7
D2
variables M,N,O to the O Z (LSB) F
D3
inputs of the decoder to N Y
D4
produce the minterms M X (MSB)
D5
D6
D7
D2
variables M,N,O to the O Z (LSB) F
D3
inputs of the decoder to N Y
D4
produce the minterms M X (MSB)
D5
• OR together where D6
F=1 D7
• OR together where D6
1
F=1 D7
0
• OR together where D6
0
F=1 D7
0
X[2:0] Z[2:0]
3-bit Unsigned
3 Decrementer 3
0 1 0 1 0 0 1 0 0 1 0 1 1 1 1
1 3 7 5 1 3 7 5 1 3 7 5
1 0 0 1 1 1 0 1 1 0 1 0 0 0 0
X2 X1 X0 Z2 Z1 Z0
0 0 0 1 1 1 Y0
Y1
0 0 1 0 0 0
0 1 0 0 0 1 Y2
A0
0 1 1 0 1 0 Y3
A1
1 0 0 0 1 1 Y4
A2
1 0 1 1 0 0 Y5
1 1 0 1 0 1 Y6
1 1 1 1 1 0 Y7
D2
O Z (LSB) F
D3
N Y
D4
M X (MSB)
D5
D6
D7
• F = ΣMNO(1,2,3,4,6) D1
D2
• Requires 5-input OR
O Z (LSB) F
D3
N Y
gate…too big! M X (MSB)
D4
D5
Implement F another D6
way… D7
F’ before
• F’ = ΣMNO(0,5,7) D0
inversion…F
after
• Requires a 3-input OR D1
D2
gate O Z (LSB)
D3
F
• OR becomes NOR D6
D7
X Y Z X Y Z
0 0 0 Hold Y 0 0 0
0 1 1 constant 0 1 0
1 0 1 1 0 0
1 1 1 1 1 1
OR AND
X Y Z X Y Z
0 0 0 Hold Y 0 0 0
0 1 1 constant 0 1 0
1 0 1 1 0 0
1 1 1 1 1 1
OR AND
Input Output
OSEL0
OSEL1
OSEL2
OSEL3
ISEL0
ISEL1
ISEL2
ISEL3
Channel Channel
Select Select
© Mark Redekopp, All rights reserved
Application: Steering Logic
• 4-input music channels (ICHx)
– Select one input channel (use ISELx inputs)
– Route to one output channel (use OSELx inputs)
011010101001101 ICH 0
OCH 0
101010110101010 ICH 1
OCH 1
ICH 2
101001010101111
OCH 2
ICH 3
001010101001011
OCH 3
O SEL1
O SEL2
O SEL3
O SEL0
ISEL3
ISEL1
ISEL2
ISEL0
0 1
IN0
if(s==0)
Y Y = IN0
S else
Y = IN1
IN1
© Mark Redekopp, All rights reserved
Multiplexers
• Along with adders, multiplexers are most used building
block
• 2n data inputs, n select bits, 1 output
• A multiplexer (“mux” for short) selects one data input and
passes it to the output
4-to-1 Mux
D0
D1
2n data inputs Y 1 output
D2
D3 S0
S1
n select bits
© Mark Redekopp, All rights reserved
Multiplexers
0 D0
1 D1
2 Y 1
Thus, D2 is selected 1 D2 (D2)
and passed to the
output 0 D3 S0
S1
10
1
Select bits = 102 = 210.
0 D0
1 D1
Y 0
0 D2 (D2)
0 D3 S0
S1
10
00
1
Select bits = 002 = 010.
0 1
I1 I1 I1
1 S0 1
S1S0 = 01 0 S1
1
I1
Y
I2 0
1 S0
0 S1
I3 0
1 S0
© Mark Redekopp, All rights reserved
0 S1
Building a Mux
• To build a mux
– Decode the select bits and include the corresponding
data input.
– Finally OR all the first level outputs together.
I0 1 0
S0
1 S1
I1
I1
1 S0
S1S0 = 11 1 S1 I3
Y
I2 0
1 S0
1 S1
0
I3 I3
1 S0 1
F(1,y,z) =
IN0
Y
if(s==0)
S
Y = IN0
else
Y = IN1
IN1
2
Thus, I0 is selected 1 I0
and passed to the Y 1 Y
output I1 S
0 (I0)
s
1-bit wide 2-to-1
mux
I0 I1
1
Select bits = 0
© Mark Redekopp, All rights reserved
3-bit Prime Number Function
X Y Z P X Y Z P F
0 0 0 0 0 0 0 0
0 0 1 0 0 0 1 0 x
OFF-set 0 1
0 1 0 1 0 1 0 1
0 1 1 1 0 1 1 1 y 0 1
1 0 0 0 1 0 0 0 ON-set z 0 1
1 0 1 1 1 0 1 1
1 1 0 0 1 1 0 0 0 0 1 1 0 1 0 1
1 1 1 1 1 1 1 1
Primes between Truth Table
0-7
if(z==0)
z
z output 0
I0
I1
else
0 1
output 1
1
© Mark Redekopp, All rights reserved
Example
0 0 0
0 1 0
0
1 0 1
I0
G
1 1 1 Y
I1 S
0 0 0
0 1 1 X
1
1 0 1
1 1 0
0 0
0 0
D0
1 0
D1
0 1 G
0 1 D2
Y
1 1
D3
0 0 S0
S1
1 0
1 1
x y
0 1
1 1
1 0
0 D0
variables to the select 0 0 0 0
function 1 0 0 1 1 D4
Y F
X Y Z F Z X Y F F
0 0 0 0 0 0
z 0 1
0 1 1 0 1 0
0 x 0 1
0 1 0 0 1 0 0
1 1 0 y 0 1
1 1 1
0 0 0 0 0 1 0 0 0 0 1 1 1 1
0 1 1 0 1 1 F
1 1 1 0 1
1 0 0 z 1
0
1 1 1 1 1 1
0 1
© Mark Redekopp, All rights reserved
Implementing Logic Functions
• We can use muxes to implement any
arbitrary logic function
• Fundamental method
– if function has n-input variables, need a mux
w/ n-selects
– requires no additional logic; only the mux
• By adding extra logic in front of the mux
inputs we can use a smaller mux…
Variable/Decision 0 1 0 1
0
0 1
0 1
• Edge = Variable 0 1 1 0
1
1 0 True
value (T / F) 1 0 0 1
False
0 1 BDD for F
0
1 0 1 1 1 1 X
1 1 0 0
1
0 0
1
Y
1 1 1 1 1 1
Z
0 1
© Mark Redekopp, All rights reserved
BDD’s, Muxes, Shannon’s Thm.
X 0 1 X
• Every node in the BDD
Y 0 1 0 1 Y
is just a 2-to-1 mux
– View it in the opposite Z 0 1 0 1 0 1 0 1 Z
direction (bottom to top) 0 0 1 0 1 1 0 1
If X=1, 1 1
choose the 1 (True) path 1 0 0 Z 0
1
1
1 1 Z 0 1
0 1 1 0
© Mark Redekopp, All rights reserved
Using a LookUp-Table to implement a function
columns A2
1 1 0 1 0
read out 4 1 1 0 1
columns 1 A2
1 1 0 1 0
read out 4 1 1 0 1
1 0
– Rows x Columns
1
…
An-1 2 0 0
• n rows and m columns =>
.
n x m ROM .
Z A0 0 A0
X Y Z F 0 1 0 1
Y A1 1 A1
0 0 0 1 1 0 1 0
X A2 1 A2
0 0 1 0 2 1 2 1
X,Y,Z inputs
0 1 0 1 3 1 “look up” 3 1
the correct
0 1 1 1
4 0 answer 4 0
1 0 0 0
5 0 5 0
1 0 1 0
6 0 6 0
1 1 0 0
1 1 1 1 7 1 7 1
Arbitrary D0 D0
Logic
Function F 0
Ci A0 1 A0
X Y Ci Co S 0 0 0 0 0 0
Y A1 0 A1
0 0 0 0 0 1 0 1 1 0 1
X A2 1 A2
0 0 1 0 1 2 0 1 2 0 1
0 1 0 0 1 3 1 0 3 1 0
0 1 1 1 0
4 0 1 4 0 1
1 0 0 0 1
5 1 0 5 1 0
1 0 1 1 0
6 1 0 6 1 0
1 1 0 1 0
1 1 1 1 1 7 1 1 7 1 1
Full Adder D1 D0 D1 D0
1+0+1 = 10
Co S 1 0
...
Example:
X3X2X1X0=0010
Y3Y2Y1Y0=0001
P=X*Y=2*1=2
= 0010
© Mark Redekopp, All rights reserved
Implementing Functions w/ ROM’s
• To implement a function w/ n-variables
and m outputs
• Use a ROM w/ 2n rows and m columns
• Just place the output truth table values in
the ROM