www.nand2tetris.org
Counting systems
quantity decimal binary 3
quantity decimal binary 3
quantity decimal binary 3
quantity decimal binary 3----bit register
bit register
bit register
bit register
0
0
000
1
1
001
2
10
010
3
11
011
4
100
100
5
101
101
6
110
110
7
111
111
Binary addition
!
0 0 0 1
1 0 0 1
0 1 0 1
0
1 1 1 0
++++
1 1 1 1
1 0 1 1
0 1 1 1
1
0 0 1 0
Building an Adder chip
#
+ #
#
,
-.
/
o ut
a
1 6
1 6 -b it
ad d e r
b
1 6
Half adder
(designed to add 2 bits)
0 #
(
h a lf
a d d e r
a
s um
b
c arry
a
b
sum
carry
0 0
0
0
0 1
1
0
1 0
1
0
Full adder
(designed to add 3 bits)
a
b
c
sum
carry
0 0 0
0
0
0 0 1
1
0
0 1 0
1
0
0 1 1
0
1
1 0 0
1
0
1 0 1
0
1
1 1 0
0
1
1 1 1
1
1
fu ll
a d d e r
a
s um
b
n
-bit Adder
(designed to add two 16-bit numbers)
0 #
!
o ut
a
1 6
1 6 -b it
ad d e r
b
1 6
1 6
... 1 0 1 1
a
…
0 0 1 0
b
…
1
1 0
1
out
The ALU
(of the Hack platform)
16 bits
16 bits