Picker Engineering Program Smith College

advertisement
Binary Addition
CSC 103
September 17, 2007
Recap: Binary Numbers
• Physical representation
– Transistor
– Concept of “on” and “off” for physical
manufacturing of computers  T/F…
• Abstract representation
– Logic: NOT, AND, OR
– Truth tables
• ANY Boolean expression can be built
with transistors – wired as AND, OR or
NOT
Recap: Transistors
=0
=0
or
=1
=1
=1
=1
or
=0
Logic Functions: NOT
• The ‘NOT’ function
A A’
0 1
1 0
Recap Logic Gate: AND Function
(=1)
1
(=1)
0
0
0
1
0
0
Logic Gate: OR Function
1
0
1
0
1
0
1
Onto Addition and
the Adder Circuit...
Binary Addition
• Add
•
•
•
•
0+0=
0+1=
1+0=
1+1=
• Add these numbers
c:
1000111
0100110
s:
1011010
0111001
Binary Addition: Half Adder
• We need a circuit to add two bits
– Either bit can be ‘0’ or ‘1’
• The function in the truth table is
– Sum = A’B + AB’  Exclusive-OR function
– Carry = AB
The Half-Adder and Exclusive OR Gate
• A’B + AB’ = Exclusive OR
– Typically abbreviated to XOR
– Simulator uses EOR
A
B’
A’
B
A
B
A
B
A
0
0
1
1
B
0
1
0
1
|
|
|
|
|
S
0
1
1
0
C
0
0
0
1
Recap Logic Gates: Symbols
AB, AB
A+B
XOR
A, A’
Summary:
The Half-Adder and Exclusive OR Gate
• Exclusive OR
– Typically abbreviated to XOR
– Simulator uses EOR
A
B
Binary Addition: Half Adder
Half-Adder  Full-Adder
The Full Adder
• A full adder is a circuit with three inputs
(including a ‘carry-in’) and two outputs
(the sum and carry-out)
– What is the third input?
– Exercise: Add 111+ 101
(carry)
111
101
( ‘A’ )
( ‘B’ )
(sum)
• For adding two numbers, we need three inputs
The Full Adder
• Cascade two half-adders to get a full
adder
A
B
Cin
HW: Cascade 2 Full Adders for a 2-Bit Adder
A2A1
+ B2B1


B2 A2
Cout2
Full Adder
S2
11
+1 0
B1 A1
Cin2 = Cout1
Full Adder
S1
Cin1
Summary
• Binary addition
– Concept of ‘sum’ and ‘carry’
– Half adder and full adder circuits
– Cascading circuits to make larger ones
Download