09 MUX Page 1 ECEn/CS 224 Multiplexers Decoders ROMs (LUTs)
09 MUX Page 1
ECEn/CS 224
MultiplexersDecoders
ROMs (LUTs)
09 MUX Page 2
ECEn/CS 224
A Problem Statement
Design a circuit which will select
between two inputs (A and B) and pass
the selected one to the output (Q).
The desired circuit is called a multiplexer or MUX for short
09 MUX Page 3
ECEn/CS 224
Multiplexers
q = s’a + sb
0
1
0
1
a
b
s
q
a
b
s
q
s a b q
0 0 0 00 0 1 00 1 0 10 1 1 11 0 0 01 0 1 11 1 0 01 1 1 1
Preferred symbol
09 MUX Page 4
ECEn/CS 224
0
1
a
b
1
q0
1
a
b
0
q
Data Steering
0
1
a
b
s
q
Key idea: select wire selects one of the inputs and passes it out to the output.
09 MUX Page 5
ECEn/CS 224
A 4:1 MUX
4:1MUX
I0
I1
I2
I3
Z
A B
DataInputs
Control Inputs
Output
Z = A’B’I0 + A’BI1 + AB’I2 + ABI3
09 MUX Page 6
ECEn/CS 224
A General MUX
n:1MUX
I0
I1
…
In-1
Z
sk-1 …. s0
n DataInputs
log2(n) Control Inputs
Output
09 MUX Page 7
ECEn/CS 224
Implementing Logic with MUX Blocks
09 MUX Page 8
ECEn/CS 224
Example 1
A B C F0 0 0 00 0 1 00 1 0 00 1 1 01 0 0 01 0 1 11 1 0 11 1 1 1
A=0 part of the truth table … when A=0, F=0
A=1 part of the truth table … when A=1, F=B+C
0
1
0
B+C
A
F
09 MUX Page 9
ECEn/CS 224
Example 2
B A C F0 0 0 00 0 1 00 1 0 00 1 1 11 0 0 01 0 1 01 1 0 11 1 1 1
B=0 part of the truth table … when B=0, F=AC
B=1 part of the truth table … when B=1, F=A
0
1
AC
A
B
F
09 MUX Page 10
ECEn/CS 224
Example 3C A B F0 0 0 00 0 1 00 1 0 00 1 1 11 0 0 01 0 1 01 1 0 11 1 1 1
C=0 part of the truth table … when C=0, F=AB
C=1 part of the truth table … when C=1, F=A
0
1
AB
A
C
F
All 3 of these examples are the same truth table…
09 MUX Page 11
ECEn/CS 224
Using a Bigger MUX
A B C F0 0 0 00 0 1 00 1 0 10 1 1 01 0 0 11 0 1 11 1 0 01 1 1 1
AB=00 part of the truth table … when AB=00, F=0
AB
FAB=01 part of the truth table … when AB=01, F=C’AB=10 part of the truth table … when AB=10, F=1AB=11 part of the truth table … when AB=11, F=C
00
01
10
11
0C’1C
Can easily re-order truth table to use different MUX control inputs
09 MUX Page 12
ECEn/CS 224
Another 4:1 MUX Example
A B F0 0 10 1 11 0 01 1 1
AB
F00
01
10
11
1101
This shows that a large enough MUX can directly implement a truth table…
09 MUX Page 13
ECEn/CS 224
MUX for Logic - Alternate Method
AB
F00
01
10
11
0C’1C
F = A’BC’ + AC + AB’
AB=00 F = 10C’ + 0C + 01 = 0AB=01 F = 11C’ + 0C + 00 = C’AB=10 F = 00C’ + 1C + 11 = 1AB=11 F = 01C’ + 1C + 10 = C
Method: evaluate the function for each select input combination…
09 MUX Page 14
ECEn/CS 224
MUXes In A Microprocessor
• They are each 16-bits wide– A 16-bit wide MUX is
simply 16 1-bit wide MUXes
• All with common s inputs
MDR
Memory
MAR
Logic
R0 … R7
PC
zext
zext
+
sext
IR
@+1
Control Logic
N Z P
…
16
16
16
16
1616
1616
16
16
1616 3
3
3
1 1 1
[8:0][5:0]
[7:0]
[8:0]
2
[4:0] 16
16
16
16
16
16
DR
DR
SR2 SR1
selMM
enaMM
enaPC
selPC
ldPC
regWE
regWEldMARldMDR
enaMemOut
regWE
enaALU
ldIR
aluControl
selALUMux
MARMUX PCMUX
ALU
09 MUX Page 15
ECEn/CS 224
Select control lines
bit 0
bit 0
bit 0
16-bit 3:1 MUX Example
00
01
10
11
bit 0
BusA
BusB
BusC
09 MUX Page 16
ECEn/CS 224
BusCBusB
They all use the same select control lines…One bit from each bus goes to each MUX
The result is a 16-bit bus
s1s0
00
01
10
11
bit 0
00
01
10
11
00
01
10
11bi
t 1
bit 1
5
…
BusA
16-bit 3:1 MUX Example
Output
09 MUX Page 17
ECEn/CS 224
Decoders
09 MUX Page 18
ECEn/CS 224
2:4 Decoder
A B Q0 Q1 Q2 Q3
0 0 1 0 0 00 1 0 1 0 01 0 0 0 1 01 1 0 0 0 1
2:4Decode
AB
Q0Q1Q2Q3
Q0 = A’B’ m0 Q1 = A’B m1 Q2 = AB’ m2Q3 = AB m3
A decoder is a minterm generator…
09 MUX Page 19
ECEn/CS 224
3:8 Decoder
A B C Q0 Q1 Q2 Q3 Q4 Q5 Q6 Q7
0 0 0 1 0 0 0 0 0 0 00 0 1 0 1 0 0 0 0 0 00 1 0 0 0 1 0 0 0 0 00 1 1 0 0 0 1 0 0 0 01 0 0 0 0 0 0 1 0 0 01 0 1 0 0 0 0 0 1 0 01 1 0 0 0 0 0 0 0 1 01 1 1 0 0 0 0 0 0 0 1
Q0 = A’B’C’ m0 Q1 = A’B’C m1 … …Q7 = ABC m7
3:8Decoder
09 MUX Page 20
ECEn/CS 224
Implementing Logic With Decoders2:4
Decode F = m(0, 2)
2:4Decode F = m(0, 3)
2:4Decode F = M(1, 2)
Historically, some decoders have come with inverted outputs…
09 MUX Page 21
ECEn/CS 224
Uses of Decoders
• Decode 3-bit op-code into a set of 8 signals
op0op1op2
AddSubAndXorNotLoadStoreJump
3:8Decoder
09 MUX Page 22
ECEn/CS 224
ROM: Read-Only Memory
• Can read values from it• Cannot write to it
8 x 1ROM
Add
ress
In
DataOut
Address Data0 11 02 13 04 05 16 17 0
Address Data0 01 72 23 144 265 06 187 22
8 x 5ROM
09 MUX Page 23
ECEn/CS 224
Each minterm of each function can be specified
Read Only Memory (ROM)
3 InputsLines
ABC
F0 F1 F2 F3 F4
5 Outputs Lines
ROM8 wordsx 5 bits
When you program a ROM,you are specifying these
A B C F0 F1 F2 F3 F4
0 0 0 0 0 0 0 10 0 1 0 0 1 1 00 1 0 0 0 1 1 00 1 1 1 0 1 0 11 0 0 0 0 1 1 01 0 1 0 0 1 0 11 1 0 1 0 1 0 11 1 1 1 1 1 1 0
09 MUX Page 24
ECEn/CS 224
ROM – View #1
• An addressable memory– Send in address
(addrn)– Receive data stored
at that location (wn)– Can have multi-bit
data
addr0
addr1
addr2
w4
w3
w2
w1
w0
8 x 5ROM
09 MUX Page 25
ECEn/CS 224
• A hardware implementation of a truth tableROM – View #2
8 x 1ROM
A B C F0 0 0 00 0 1 00 1 0 00 1 1 11 0 0 01 0 1 01 1 0 11 1 1 1
CB
BA
F
09 MUX Page 26
ECEn/CS 224
ROM – Two Different Views
• Both views are accurate
09 MUX Page 27
ECEn/CS 224
ROM Internal Structure
...n InputLines
n:2n
decoder
...
m Output Lines
.
.
.Memory Array
2n words x m bits
09 MUX Page 28
ECEn/CS 224
ROM Memory Array
ABC
m0=A’B’C’m1=A’B’Cm2=A’BC’m3=A’BCm4=AB’C’m5=AB’Cm6=ABC’m7=ABC
F0 F1 F2 F3 F4
F0 = m1 + m4 + m7F1 = m0 + m1 + m2 + m5 …
3:8Decoder
A diode – a one-way ‘resistor’
Resistors – pull outputsdown to GND if no rowwires drive them high0V 0V 0V 0V 0V
09 MUX Page 29
ECEn/CS 224
ROM Technologies: Not Always Diode-Based
• Program Only Once– Mask programmable– Fusible Link
• Re-Programmable– EPROM (ultraviolet erase)– EE-PROM (electrically erase)– Flash memory
Beyond the scope of this class
09 MUX Page 30
ECEn/CS 224
Using a ROM For Logic
F = AB + A’BC’G = A’B’C + C’H = AB’C’ + ABC’ + A’B’C
A B C F G H0 0 00 0 10 1 00 1 11 0 01 0 11 1 01 1 1
09 MUX Page 31
ECEn/CS 224
Using a ROM For Logic
F = AB + A’BC’G = A’B’C + C’H = AB’C’ + ABC’ + A’B’C
A B C F G H0 0 0 00 0 1 00 1 0 10 1 1 01 0 0 01 0 1 01 1 0 11 1 1 1
09 MUX Page 32
ECEn/CS 224
F = AB + A’BC’G = A’B’C + C’H = AB’C’ + ABC’ + A’B’C
Using a ROM For Logic
A B C F G H0 0 0 0 1 00 0 1 0 1 10 1 0 1 1 00 1 1 0 0 01 0 0 0 1 11 0 1 0 0 01 1 0 1 1 11 1 1 1 0 0
Just fill out the truth table
CAD tools usually do the rest…