Addition and Subtraction
Philipp Koehn 4 September 2019
Philipp Koehn Computer Systems Fundamentals: Addition and Subtraction 4 September 2019
Addition and Subtraction Philipp Koehn 4 September 2019 Philipp - - PowerPoint PPT Presentation
Addition and Subtraction Philipp Koehn 4 September 2019 Philipp Koehn Computer Systems Fundamentals: Addition and Subtraction 4 September 2019 1 addition Philipp Koehn Computer Systems Fundamentals: Addition and Subtraction 4 September
Philipp Koehn 4 September 2019
Philipp Koehn Computer Systems Fundamentals: Addition and Subtraction 4 September 2019
1
Philipp Koehn Computer Systems Fundamentals: Addition and Subtraction 4 September 2019
2
Adding two 1-Bit numbers
A B A+B 1 1 1 1 1 1 10
Philipp Koehn Computer Systems Fundamentals: Addition and Subtraction 4 September 2019
3
A B A+B 1 1 1 1 1 1
A B A+B carry 1 1 1 1 1
Philipp Koehn Computer Systems Fundamentals: Addition and Subtraction 4 September 2019
4
Philipp Koehn Computer Systems Fundamentals: Addition and Subtraction 4 September 2019
5
A B OUT0 1 1 1 1 1 1
NAND AND OR
A B OUT0
A B OUTC 1 1 1 1 1
A B
AND
OUTC
Philipp Koehn Computer Systems Fundamentals: Addition and Subtraction 4 September 2019
6
AND
NAND AND OR
Philipp Koehn Computer Systems Fundamentals: Addition and Subtraction 4 September 2019
7
011 +11
Philipp Koehn Computer Systems Fundamentals: Addition and Subtraction 4 September 2019
8
011 +11
1+1 = 0, carry the 1
Philipp Koehn Computer Systems Fundamentals: Addition and Subtraction 4 September 2019
9
011 +11
1+1+1 = 1, carry the 1
Philipp Koehn Computer Systems Fundamentals: Addition and Subtraction 4 September 2019
10
011 +11
copy carry bit
Philipp Koehn Computer Systems Fundamentals: Addition and Subtraction 4 September 2019
11
AND
NAND AND OR
Our adder cannot handle carry as input yet
Philipp Koehn Computer Systems Fundamentals: Addition and Subtraction 4 September 2019
12
AND
NAND AND OR
1-BIT HALF ADDER
Philipp Koehn Computer Systems Fundamentals: Addition and Subtraction 4 September 2019
13
1-BIT HALF ADDER A B S C
Philipp Koehn Computer Systems Fundamentals: Addition and Subtraction 4 September 2019
14
1-BIT HALF ADDER A B S C
1-BIT HALF ADDER A B S C
Philipp Koehn Computer Systems Fundamentals: Addition and Subtraction 4 September 2019
15
1-BIT HALF ADDER A B S C
1-BIT HALF ADDER A B S C OR
Philipp Koehn Computer Systems Fundamentals: Addition and Subtraction 4 September 2019
16
1-BIT HALF ADDER A B S C
1-BIT HALF ADDER A B S C OR
1-BIT FULL ADDER
Philipp Koehn Computer Systems Fundamentals: Addition and Subtraction 4 September 2019
17
011 +11
Philipp Koehn Computer Systems Fundamentals: Addition and Subtraction 4 September 2019
18
011 +11
1-BIT FULL ADDER A B S CO CI
Philipp Koehn Computer Systems Fundamentals: Addition and Subtraction 4 September 2019
19
011 +11
1-BIT FULL ADDER A B S CO CI
1-BIT FULL ADDER A B S CO CI
Philipp Koehn Computer Systems Fundamentals: Addition and Subtraction 4 September 2019
20
and so
...
1-BIT FULL ADDER A B S CO CI
1-BIT FULL ADDER A B S CO CI
1-BIT FULL ADDER A B S CO CI
Philipp Koehn Computer Systems Fundamentals: Addition and Subtraction 4 September 2019
21
Philipp Koehn Computer Systems Fundamentals: Addition and Subtraction 4 September 2019
22
0253
Philipp Koehn Computer Systems Fundamentals: Addition and Subtraction 4 September 2019
23
0999
Philipp Koehn Computer Systems Fundamentals: Addition and Subtraction 4 September 2019
24
00253 +0823
01076 +0001
Philipp Koehn Computer Systems Fundamentals: Addition and Subtraction 4 September 2019
25
Original problem 00253
0011111101
Inverse of subtrahend 00823 0001001111 Addition 00253 +0823
0011111101 +001001111
Corrections +0001
+000000001
Philipp Koehn Computer Systems Fundamentals: Addition and Subtraction 4 September 2019
26
Philipp Koehn Computer Systems Fundamentals: Addition and Subtraction 4 September 2019
27
Philipp Koehn Computer Systems Fundamentals: Addition and Subtraction 4 September 2019
28
Trick: add one as carry in
Philipp Koehn Computer Systems Fundamentals: Addition and Subtraction 4 September 2019
29
mm...
Philipp Koehn Computer Systems Fundamentals: Addition and Subtraction 4 September 2019
30
Philipp Koehn Computer Systems Fundamentals: Addition and Subtraction 4 September 2019
31
⇒ Combined adder and subtractor
A, B, and subtraction flag SUB
– if SUB=0: A+B – if SUB=1: A-B
Philipp Koehn Computer Systems Fundamentals: Addition and Subtraction 4 September 2019
32
mm...
Philipp Koehn Computer Systems Fundamentals: Addition and Subtraction 4 September 2019
33
SUB X OUT 1 1 1 1 1 1
XOR
Philipp Koehn Computer Systems Fundamentals: Addition and Subtraction 4 September 2019
34
Philipp Koehn Computer Systems Fundamentals: Addition and Subtraction 4 September 2019