Académique Documents
Professionnel Documents
Culture Documents
Blocks
CS31
Pascal Van Hentenryck
CS031 Lecture 5 1
Overview
ALU
• This is the brawn of the
computer
ROM
• Useful for implementing the
control
CS031 Lecture 5 2
The Big Picture
compiler
computer
control
input
datapath
Programming Language
Assembly Language
Machine Language
Sequential Circuit
Combinational Circuit
Binary Value
Voltage
CS031 Lecture 5 4
Two Building Blocks
Decoders
• n inputs / 2n outputs
• Given the inputs, select a unique
output
• Particularly useful for implementing
memories
Multiplexers (selectors)
• 2n data inputs / n selection inputs / 1
output
• The output is the data input selected
by the selection input
• Particularly useful for implementing
ALU and various other pieces of the
machine
CS031 Lecture 5 5
Decoders
Turn binary “coded” quantities into one
unit vector for every possible value.
do
x d1
y d2
d3
CS031 Lecture 5 6
Decoders
Turn binary “coded” quantities into one
unit vector for every possible value.
x y d0 d1 d2 d3
0 0 1 0 0 0
0 1 0 1 0 0
1 0 0 0 1 0
1 1 0 0 0 1
The decoder
• assign d2*x+y to 1
• all the others to zero
CS031 Lecture 5 7
Decoders
Turn binary “coded” quantities into one
unit vector for every possible value.
x y d0 d1 d2 d3
0 0 1 0 0 0
0 1 0 1 0 0
1 0 0 0 1 0
1 1 0 0 0 1
CS031 Lecture 5 8
More Decoders
• Decoders can be in any size
m input n output
m by n
decoder
• n is always 2m
• two types of decoders: a single output 1
or a single output is 0
CS031 Lecture 5 9
Multiplexers
Choose a particular input to pass through as
specified by values on the selection (or address)
lines.
I0
output
I1
I2
I3
x y
selector
CS031 Lecture 5 10
Multiplexers
Choose a particular input to pass through as
specified by values on the selection (or address)
lines.
S1 S2 O
0 0 I0
0 1 I1
1 0 I2
1 1 I3
CS031 Lecture 5 11
Multiplexers
Choose a particular input to pass through as
specified by values on the selection (or address)
lines.
CS031 Lecture 5 12
Multiplexers
Choose a particular input to pass through as
specified by values on the selection (or address)
lines.
CS031 Lecture 5 13
1-bit ALU
1-bit ALU with and and or
operation
result
CS031 Lecture 5 14
1-bit ALU
CS031 Lecture 5 15
32-bit ALU
CS031 Lecture 5 16
32-bit ALU
Operation
CarryIn
a0
Alu0
b0
a1
Alu1
b1
a31 Alu31
b31
CS031 Lecture 5 17
32-bit ALU
Include subtraction
• Add the negative version of b
CS031 Lecture 5 18
1-bit ALU (Revisited)
CS031 Lecture 5 19
32-bit ALU
CS031 Lecture 5 20
ALU (Absolutely Lazy Unit)
A B
Binv Cin
O1
O0
function
R
Possible Modes
Operation 0: R = A + B
Operation 1: R = A – B
Operation 2: R = A and B
Operation 3: R = A or B
CS031 Lecture 4 21
Controlling the ALU
O1 O0 Binv Cin
A+B 0 0 0 0
A–B 0 1 1 1
A^B 1 0 0 x
AvB 1 1 0 x
CS031 Lecture 5 22
Implementing a Logic Function
Specific Circuit
• when there is a lot of structure (the
Karnaugh map, remember?)
ROM
• when there is almost no structure
PLA
• in between
CS031 Lecture 5 23
Read Only Memory (ROM)
Map addresses to fixed values
a1 a2 a3 O
0 0 0 V1
0 0 1 V2
0 1 0 V3
0 1 1 V4
1 0 0 V5
1 0 1 V6
1 1 0 V7
1 1 1 V8
CS031 Lecture 5 24
Modern ROMs
1
input 1
loc.output 1
input 2
“Pulldown
input 3
loc.output 2
Output
CS031 Lecture 5 25
Modern ROMs
Modern ROMs are organized around
• a decoder
• a multiplexer
• an array of pulldowns
n address
bits
2n x2m
decoder array of
pulldowns
m address
bits multiplexe r
Output
CS031 Lecture 5 26
Example (stupid, I agree)
Assume that I need a ROM to store the prime
numbers from 0 to 63.
CS031 Lecture 5 27
Storing Primes
Put a pulldown where you want a 0.
0 1 2 3 4 5 6 7
0
decoder 3
4
A2
A5A4 A3 A1 multiplexer
A0
Address
Output
If you want more than one bit of output, just use
more ROM circuits in parallel with different stored
functions.
CS031 Lecture 5 28
Not Chaining Adders
Can we speed this up?
FAFAFAFA0x y y x y x y x S S S S C
0 0 2 2 2 2 1 1 0 1 2 3
0 S0
x0
y0 FA
S1
x1 FA
y1
S2
x2 FA
y2
S3
x3 FA
y3 C
CS031 Lecture 5 29