This preview shows pages 1–7. Sign up to view the full content.
Addition and multiplication
1
Addition and multiplication
•
Arithmetic is the most basic thing you can do with a computer, but it’s
not as easy as you might expect!
•
These next few lectures focus on addition, subtraction, multiplication
and arithmeticlogic units, or ALUs, which are the “heart” of CPUs.
•
ALUs are a good example of many of the issues we’ve seen so far,
including Boolean algebra, circuit analysis, data representation, and
hierarchical, modular design.
This preview has intentionally blurred sections. Sign up to view the full version.
View Full Document Addition and multiplication
2
Binary addition by hand
•
You can add two binary numbers one column at a time starting from the
right, just as you add two decimal numbers.
•
But remember that it’s binary. For example, 1 + 1 = 10 and you have to
carry!
1
1
1
0
Carry in
1
0
1
1
Augend
+
1
1
1
0
Addend
1
1
0
0
1
Sum
The initial carry
in is implicitly 0
most significant
bit
, or
MSB
least significant
bit
, or
LSB
Addition and multiplication
3
Adding two bits
•
We’ll make a hardware adder by copying the human addition algorithm.
•
We start with a
half adder
, which adds two bits and produces a twobit
result: a
sum
(the right bit) and a
carry out
(the left bit).
•
Here are truth tables, equations, circuit and block symbol.
X
Y
C
S
0
0
0
0
0
1
0
1
1
0
0
1
1
1
1
0
0 + 0
= 0
0 + 1
= 1
1
+ 0
= 1
1
+ 1
= 10
C
= XY
S = X’ Y + X Y’
= X
⊕
Y
Be careful! Now we’re using
+
for both arithmetic addition
and the logical OR operation.
This preview has intentionally blurred sections. Sign up to view the full version.
View Full Document Addition and multiplication
4
Adding three bits
•
But what we really need to do is add
three
bits: the augend and addend,
and the
carry in
from the right.
0 + 0 + 0 = 00
0 + 0 + 0 = 01
0 + 1
+ 0 = 01
0 + 1
+ 1
= 10
1
+ 0 + 0 = 01
1
+ 0 + 1
= 10
1
+ 1
+ 0 = 10
1
+ 1
+ 1
= 11
X
Y
C
in
C
out
S
0 0 0 0 0
0 0 1 0 1
0 1 0 0 1
0 1 1 1 0
1 0 0 0 1
1 0 1 1 0
1 1 0 1 0
1 1 1 1 1
(These are the
same functions
from the decoder
and mux examples.)
1
1
1
0
1
0
1
1
+
1
1
1
0
1
1
0
0
1
Addition and multiplication
5
Full adder equations
•
A
full adder
circuit takes three bits of input, and produces a twobit
output consisting of a sum and a carry out.
•
Using Boolean algebra, we get the equations shown here.
–
XOR operations simplify the equations a bit.
–
We used algebra because you can’t easily derive XORs from Kmaps.
S
=
Σ
m(1,2,4,7)
= X’ Y’ C
in
+
X’ Y C
in
’
+
X Y’ C
in
’
+
X Y C
in
= X’ (Y’ C
in
+ Y C
in
’) + X (Y’ C
in
’ + Y C
in
)
= X’ (Y
⊕
C
in
) + X (Y
⊕
C
in
)’
= X
⊕
Y
⊕
C
in
C
out
=
Σ
m(3,5,6,7)
= X’ Y C
in
+ X Y’ C
in
+ X Y C
in
’ + X Y C
in
= (X’ Y + X Y’) C
in
+ XY(C
in
’ + C
in
)
= (X
⊕
Y) C
in
+ XY
X
Y
C
in
C
out
S
0 0 0 0 0
0 0 1 0 1
0 1 0 0 1
0 1 1 1 0
1 0 0 0 1
1 0 1 1 0
1 1 0 1 0
1 1 1 1 1
This preview has intentionally blurred sections. Sign up to view the full version.
View Full Document
6
Full adder circuit
•
These things are called half adders and full adders because you can
build a full adder by putting together two half adders!
S
This is the end of the preview. Sign up
to
access the rest of the document.
This note was uploaded on 10/19/2011 for the course CS 231 taught by Professor  during the Spring '08 term at University of Illinois at Urbana–Champaign.
 Spring '08
 

Click to edit the document details