|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Adder |
|
|
|
|
|
|
|
In order to construct a
CPU, we need to perform arithmetic and logical operations. |
|
|
Basic arithmetic
operator: addition |
|
|
|
What's involved in adding
binary numbers? |
|
|
|
carry |
0 |
1 |
1 |
0 |
|
|
decimal |
|
|
|
0 |
0 |
1 |
1 |
|
3 |
|
|
|
|
0 |
1 |
1 |
0 |
|
6 |
|
|
|
|
|
result |
1 |
0 |
0 |
1 |
|
9 |
|
|
|
|
In each column: |
|
|
|
|
|
input: add 2 bits, along
with a carry bit from the previous result |
|
|
|
|
output: 1 bit result, 1
bit carry |
|
|
|
|
Half-adder |
|
|
|
|
|
adds 2 bits (x, y), generates sum (s) and carry (c) |
|
|
|
|
|
(note that previous carry
is being ignored) |
|
|
|
|
|
|
|
|
|
Truth table |
|
Boolean expressions: |
|
|
|
x |
y |
s |
c |
|
|
|
|
0 |
0 |
0 |
0 |
|
s = \xy + x\y = x XOR y |
|
|
0 |
1 |
1 |
0 |
|
c = xy |
|
|
|
|
1 |
0 |
1 |
0 |
|
|
|
|
1 |
1 |
0 |
1 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|