Upload
others
View
2
Download
0
Embed Size (px)
Citation preview
1
Year3014
1
2
After aseries ofdemotions
2
3
Sous-Chef3
Sous-Chef3
Assistant
4
ISSIcarus
4
5
UnfortunateAccident
5
6
PhaseMatter Array
6
7
7
Dark MatterCephalopod
8
Killing8
9
TheCaptain
9
10
ScienceOfficer
10
11
Engineer11
12
and, ofcourse
12
13
TheComputer
13
14
I’mstranded!
14
15
All IHave
15
16
PowerSupply
16
17
A Bucket ofNAND gates
17
18
andthisbook
18
19
I am...19
20
Lost In Space
20
Ryan Davis, Seattle.rbLet’s Build a Computer!
@the_zenspiderGoGaRuCo 3014
Let’s Build a Computer!
21
Ryan Davis, Seattle.rbLet’s Build a Computer!
@the_zenspiderGoGaRuCo 3014
Setting ExpectationsHighly Technical Talk
(I hope) Highly Approachable Talk
200 Slides ≅ 6 ⅔ spm
I have to go incredibly fast.
Not my field of expertise at all. I’m terrified.22
Ryan Davis, Seattle.rbLet’s Build a Computer!
@the_zenspiderGoGaRuCo 3014
Nand to Tetris
23
Ryan Davis, Seattle.rbLet’s Build a Computer!
@the_zenspiderGoGaRuCo 3014
I !
this book24
♥
Ryan Davis, Seattle.rbLet’s Build a Computer!
@the_zenspiderGoGaRuCo 3014 25
High Level Language & OS
Virtual Machine
Assembly Language
Machine Language
Hardware Platform
Chips & Logic Gates
Physics
Ryan Davis, Seattle.rbLet’s Build a Computer!
@the_zenspiderGoGaRuCo 3014 25
High Level Language & OS
Virtual Machine
Assembly Language
Machine Language
Hardware Platform
Chips & Logic Gates
Physics
High Level Language & OS
Virtual Machine
Assembly Language
Machine Language
Hardware Platform
Chips & Logic Gates
Physics
Ryan Davis, Seattle.rbLet’s Build a Computer!
@the_zenspiderGoGaRuCo 3014 26statement of the system’s abstraction—namely, the various services that it isexpected to deliver. Having presented the what, each chapter proceeds to discuss howthe abstraction can be implemented, leading to a (proposed) Implementation section.The next section is always Perspective, in which we highlight noteworthy issues leftout from the chapter. Each chapter ends with a Project section that provides step-by-step building instructions, testing materials, and software tools for actually buildingand unit-testing the system described in the chapter.
Projects
The computer system described in the book is for real—it can actually be built, andit works! A reader who takes the time and effort to gradually build this computer willgain a level of intimate understanding unmatched by mere reading. Hence, the bookis geared toward active readers who are willing to roll up their sleeves and build acomputer from the ground up.
Each chapter includes a complete description of a stand-alone hardware or soft-ware development project. The four projects that construct the computer platformare built using a simple Hardware Description Language (HDL) and simulated on ahardware simulator supplied with the book. Five of the subsequent software projects
c3
c10
c7
c9
c6
c5
c11
c1
c2
c12
c8
c4
Typicalsoftwarehierarchy
Typicalhardwareplatform
High-Level Language / Applications (∞)
Operating System
Compiler
Virtual Machine
Assembler
Computer Architecture
Machine Language
ALU Memory Elements
Boolean Arithmetic
Boolean Logic
Sequential Logic
Figure P.1 Book and proposed course map, with chapter numbers in circles.
xii Preface
From “Elements of Computing Systems”
Ryan Davis, Seattle.rbLet’s Build a Computer!
@the_zenspiderGoGaRuCo 3014 26statement of the system’s abstraction—namely, the various services that it isexpected to deliver. Having presented the what, each chapter proceeds to discuss howthe abstraction can be implemented, leading to a (proposed) Implementation section.The next section is always Perspective, in which we highlight noteworthy issues leftout from the chapter. Each chapter ends with a Project section that provides step-by-step building instructions, testing materials, and software tools for actually buildingand unit-testing the system described in the chapter.
Projects
The computer system described in the book is for real—it can actually be built, andit works! A reader who takes the time and effort to gradually build this computer willgain a level of intimate understanding unmatched by mere reading. Hence, the bookis geared toward active readers who are willing to roll up their sleeves and build acomputer from the ground up.
Each chapter includes a complete description of a stand-alone hardware or soft-ware development project. The four projects that construct the computer platformare built using a simple Hardware Description Language (HDL) and simulated on ahardware simulator supplied with the book. Five of the subsequent software projects
c3
c10
c7
c9
c6
c5
c11
c1
c2
c12
c8
c4
Typicalsoftwarehierarchy
Typicalhardwareplatform
High-Level Language / Applications (∞)
Operating System
Compiler
Virtual Machine
Assembler
Computer Architecture
Machine Language
ALU Memory Elements
Boolean Arithmetic
Boolean Logic
Sequential Logic
Figure P.1 Book and proposed course map, with chapter numbers in circles.
xii Preface
From “Elements of Computing Systems”
Ryan Davis, Seattle.rbLet’s Build a Computer!
@the_zenspiderGoGaRuCo 3014 26statement of the system’s abstraction—namely, the various services that it isexpected to deliver. Having presented the what, each chapter proceeds to discuss howthe abstraction can be implemented, leading to a (proposed) Implementation section.The next section is always Perspective, in which we highlight noteworthy issues leftout from the chapter. Each chapter ends with a Project section that provides step-by-step building instructions, testing materials, and software tools for actually buildingand unit-testing the system described in the chapter.
Projects
The computer system described in the book is for real—it can actually be built, andit works! A reader who takes the time and effort to gradually build this computer willgain a level of intimate understanding unmatched by mere reading. Hence, the bookis geared toward active readers who are willing to roll up their sleeves and build acomputer from the ground up.
Each chapter includes a complete description of a stand-alone hardware or soft-ware development project. The four projects that construct the computer platformare built using a simple Hardware Description Language (HDL) and simulated on ahardware simulator supplied with the book. Five of the subsequent software projects
c3
c10
c7
c9
c6
c5
c11
c1
c2
c12
c8
c4
Typicalsoftwarehierarchy
Typicalhardwareplatform
High-Level Language / Applications (∞)
Operating System
Compiler
Virtual Machine
Assembler
Computer Architecture
Machine Language
ALU Memory Elements
Boolean Arithmetic
Boolean Logic
Sequential Logic
Figure P.1 Book and proposed course map, with chapter numbers in circles.
xii Preface
From “Elements of Computing Systems”
Ryan Davis, Seattle.rbLet’s Build a Computer!
@the_zenspiderGoGaRuCo 3014
Complexity builds from Simplicity
27
Boolean Logic
Boolean Arithmetic
Sequential Logic
Computer Logic
Ryan Davis, Seattle.rbLet’s Build a Computer!
@the_zenspiderGoGaRuCo 3014
Very Important:
28
Ryan Davis, Seattle.rbLet’s Build a Computer!
@the_zenspiderGoGaRuCo 3014
This is NOT comic sans!
29
Ryan Davis, Seattle.rbLet’s Build a Computer!
@the_zenspiderGoGaRuCo 3014
This is NOT comic sans!
29
ttttt
Ryan Davis, Seattle.rbLet’s Build a Computer!
@the_zenspiderGoGaRuCo 3014
This is NOT comic sans!
29
ttttt Hand-drawn font called Sketchnote!
Ryan Davis, Seattle.rbLet’s Build a Computer!
@the_zenspiderGoGaRuCo 3014
Boolean Logic
30
Ryan Davis, Seattle.rbLet’s Build a Computer!
@the_zenspiderGoGaRuCo 3014 31
NAND
Ryan Davis, Seattle.rbLet’s Build a Computer!
@the_zenspiderGoGaRuCo 3014
WTF is a
Nand?!?32
Ryan Davis, Seattle.rbLet’s Build a Computer!
@the_zenspiderGoGaRuCo 3014
Not-And
33
NAND
Ryan Davis, Seattle.rbLet’s Build a Computer!
@the_zenspiderGoGaRuCo 3014
Not-And
33
NAND
Not
Ryan Davis, Seattle.rbLet’s Build a Computer!
@the_zenspiderGoGaRuCo 3014
Not-And
33
NAND
And
Not
Ryan Davis, Seattle.rbLet’s Build a Computer!
@the_zenspiderGoGaRuCo 3014
Nand34
NAND
a b nand
T T F
T F T
F T T
F F T
Ryan Davis, Seattle.rbLet’s Build a Computer!
@the_zenspiderGoGaRuCo 3014
Rubydef nand a, b ! (a && b) end
35
Ryan Davis, Seattle.rbLet’s Build a Computer!
@the_zenspiderGoGaRuCo 3014
Rubyclass Object def ⅋⅋ other ! (self && other) end end
36
Ryan Davis, Seattle.rbLet’s Build a Computer!
@the_zenspiderGoGaRuCo 3014
Rubyclass Object def ⅋⅋ other ! (self && other) end end
36
So Cool!
Ryan Davis, Seattle.rbLet’s Build a Computer!
@the_zenspiderGoGaRuCo 3014
Universal Gates
37
NAND
NOR
Ryan Davis, Seattle.rbLet’s Build a Computer!
@the_zenspiderGoGaRuCo 3014
Complexity builds from Simplicity
38
Nand
Not
And
Or
Xor / Mux / Dmux
Ryan Davis, Seattle.rbLet’s Build a Computer!
@the_zenspiderGoGaRuCo 3014 39
NOT
Ryan Davis, Seattle.rbLet’s Build a Computer!
@the_zenspiderGoGaRuCo 3014
Only using ?
40
NAND
Ryan Davis, Seattle.rbLet’s Build a Computer!
@the_zenspiderGoGaRuCo 3014
not41
a not
T F
F T
NOT
Ryan Davis, Seattle.rbLet’s Build a Computer!
@the_zenspiderGoGaRuCo 3014
Nand →
Not?42
NAND
a b nand
T T F
T F T
F T T
F F T
Ryan Davis, Seattle.rbLet’s Build a Computer!
@the_zenspiderGoGaRuCo 3014
Nand →
Not43
a b nand
T T F
T F T
F T T
F F T
NAND
Ryan Davis, Seattle.rbLet’s Build a Computer!
@the_zenspiderGoGaRuCo 3014
Not44
NAND
a b nand
T T F
F F T
Ryan Davis, Seattle.rbLet’s Build a Computer!
@the_zenspiderGoGaRuCo 3014 45
AND
Ryan Davis, Seattle.rbLet’s Build a Computer!
@the_zenspiderGoGaRuCo 3014
Only using & ?
46
NOT NAND
Ryan Davis, Seattle.rbLet’s Build a Computer!
@the_zenspiderGoGaRuCo 3014
and47
a b and
T T T
T F F
F T F
F F F
AND
Ryan Davis, Seattle.rbLet’s Build a Computer!
@the_zenspiderGoGaRuCo 3014
nand →
and?48
NAND
a b nand
T T F
T F T
F T T
F F T
Ryan Davis, Seattle.rbLet’s Build a Computer!
@the_zenspiderGoGaRuCo 3014
and =
not nand
49
NAND
a b nand
T T F
T F T
F T T
F F T
Ryan Davis, Seattle.rbLet’s Build a Computer!
@the_zenspiderGoGaRuCo 3014
and =
not not and
50
NAND
a b nand
T T F
T F T
F T T
F F T
Ryan Davis, Seattle.rbLet’s Build a Computer!
@the_zenspiderGoGaRuCo 3014
and =
not not and
51
NAND
a b nand
T T F
T F T
F T T
F F T
Ryan Davis, Seattle.rbLet’s Build a Computer!
@the_zenspiderGoGaRuCo 3014
NAND NOT nand-not
52
a b and
T T T
T F F
F T F
F F F
Ryan Davis, Seattle.rbLet’s Build a Computer!
@the_zenspiderGoGaRuCo 3014
NAND NAND
and53
a b and
T T T
T F F
F T F
F F F
Ryan Davis, Seattle.rbLet’s Build a Computer!
@the_zenspiderGoGaRuCo 3014 54
OR
Ryan Davis, Seattle.rbLet’s Build a Computer!
@the_zenspiderGoGaRuCo 3014
Only using , , & ?
55
NOT
NAND
AND
Ryan Davis, Seattle.rbLet’s Build a Computer!
@the_zenspiderGoGaRuCo 3014
or56
OR
a b or
T T T
T F T
F T T
F F F
Ryan Davis, Seattle.rbLet’s Build a Computer!
@the_zenspiderGoGaRuCo 3014
De Morgan’s Law!
57
Ryan Davis, Seattle.rbLet’s Build a Computer!
@the_zenspiderGoGaRuCo 3014
Venn Diagrams??!!
58
Ryan Davis, Seattle.rbLet’s Build a Computer!
@the_zenspiderGoGaRuCo 3014http://en.wikipedia.org/wiki/Venn_diagram
Venn Diagrams??!!
58
Ryan Davis, Seattle.rbLet’s Build a Computer!
@the_zenspiderGoGaRuCo 3014
Venn Diagrams!
59
Ryan Davis, Seattle.rbLet’s Build a Computer!
@the_zenspiderGoGaRuCo 3014
Venn Diagrams!
59
http://thisisindexed.com/
Ryan Davis, Seattle.rbLet’s Build a Computer!
@the_zenspiderGoGaRuCo 3014
Venn Diagrams!
60
A B
Ryan Davis, Seattle.rbLet’s Build a Computer!
@the_zenspiderGoGaRuCo 3014
A | B
61
A B
Ryan Davis, Seattle.rbLet’s Build a Computer!
@the_zenspiderGoGaRuCo 3014
A B
!(A | B)
62
Ryan Davis, Seattle.rbLet’s Build a Computer!
@the_zenspiderGoGaRuCo 3014
!(A | B)
63
A B
Ryan Davis, Seattle.rbLet’s Build a Computer!
@the_zenspiderGoGaRuCo 3014
(!A & !B)
64
A B
Ryan Davis, Seattle.rbLet’s Build a Computer!
@the_zenspiderGoGaRuCo 3014
!(!A & !B)
65
A B
Ryan Davis, Seattle.rbLet’s Build a Computer!
@the_zenspiderGoGaRuCo 3014
!(!A & !B) = A | B
66
A B
Ryan Davis, Seattle.rbLet’s Build a Computer!
@the_zenspiderGoGaRuCo 3014
a | b67
OR
a b or
T T T
T F T
F T T
F F F
Ryan Davis, Seattle.rbLet’s Build a Computer!
@the_zenspiderGoGaRuCo 3014
!(!a & !b)
68
a b or
T T T
T F T
F T T
F F F
NOT
NOT
AND NOT
Ryan Davis, Seattle.rbLet’s Build a Computer!
@the_zenspiderGoGaRuCo 3014
not(and( not(a), not(b)))
69
a b or
T T T
T F T
F T T
F F F
NOT
NOT
AND NOT
Ryan Davis, Seattle.rbLet’s Build a Computer!
@the_zenspiderGoGaRuCo 3014
not(and( not(a), not(b)))
70
a b or
T T T
T F T
F T T
F F F
NOT
NOT
AND NOT
Ryan Davis, Seattle.rbLet’s Build a Computer!
@the_zenspiderGoGaRuCo 3014
NAND
NOT
NOT nand( not(a), not(b))
71
a b or
T T T
T F T
F T T
F F F
Ryan Davis, Seattle.rbLet’s Build a Computer!
@the_zenspiderGoGaRuCo 3014
NAND
NOT
NOT nand( not(a), not(b))
72
a b or
T T T
T F T
F T T
F F F
Ryan Davis, Seattle.rbLet’s Build a Computer!
@the_zenspiderGoGaRuCo 3014
nand( nand(a,a), nand(b,b))
73
a b or
T T T
T F T
F T T
F F F
NANDNAND
NAND
Ryan Davis, Seattle.rbLet’s Build a Computer!
@the_zenspiderGoGaRuCo 3014 74
XOR
Ryan Davis, Seattle.rbLet’s Build a Computer!
@the_zenspiderGoGaRuCo 3014
Only using , ,
& ?75
NOT NAND
ANDOR
Ryan Davis, Seattle.rbLet’s Build a Computer!
@the_zenspiderGoGaRuCo 3014
a b xor
T T F
T F T
F T T
F F F
xor76
XOR
Ryan Davis, Seattle.rbLet’s Build a Computer!
@the_zenspiderGoGaRuCo 3014
a b xor
T T F
T F T
F T T
F F F
!
a & !b | !a & b
77
AND
ANDOR
Ryan Davis, Seattle.rbLet’s Build a Computer!
@the_zenspiderGoGaRuCo 3014
a b xor
T T F
T F T
F T T
F F F
!
a & !b | !a & b
77
AND
ANDOR
Ryan Davis, Seattle.rbLet’s Build a Computer!
@the_zenspiderGoGaRuCo 3014
AND
ANDOR
NAND
NAND
a b xor
T T F
T F T
F T T
F F F
!
a & !b | !a & b
78
Ryan Davis, Seattle.rbLet’s Build a Computer!
@the_zenspiderGoGaRuCo 3014
AND
ANDOR
NAND
NAND
a b xor
T T F
T F T
F T T
F F F
!
a & !b | !a & b
78
Ryan Davis, Seattle.rbLet’s Build a Computer!
@the_zenspiderGoGaRuCo 3014
a b xor
T T F
T F T
F T T
F F F
!
a & !b | !a & b
79
OR
NAND
NAND
NAND NAND
NAND NAND
Ryan Davis, Seattle.rbLet’s Build a Computer!
@the_zenspiderGoGaRuCo 3014
a b xor
T T F
T F T
F T T
F F F
!
a & !b | !a & b
79
OR
NAND
NAND
NAND NAND
NAND NAND
Ryan Davis, Seattle.rbLet’s Build a Computer!
@the_zenspiderGoGaRuCo 3014
a b xor
T T F
T F T
F T T
F F F
!
a & !b | !a & b
80
NAND
NAND
NAND NAND
NAND NAND
NAND
NAND
NAND
Ryan Davis, Seattle.rbLet’s Build a Computer!
@the_zenspiderGoGaRuCo 3014
NAND
NAND
NAND NAND
NAND NAND
NAND
NAND
NAND
a b xor
T T F
T F T
F T T
F F F
!
a & !b | !a & b
81
Ryan Davis, Seattle.rbLet’s Build a Computer!
@the_zenspiderGoGaRuCo 3014
NAND
NAND
NAND
NAND
NAND
a b xor
T T F
T F T
F T T
F F F
!
a & !b | !a & b
82
Ryan Davis, Seattle.rbLet’s Build a Computer!
@the_zenspiderGoGaRuCo 3014
NAND
NAND
NAND
NAND
NAND
a b xor
T T F
T F T
F T T
F F F
!
a & !b | !a & b
83
Ryan Davis, Seattle.rbLet’s Build a Computer!
@the_zenspiderGoGaRuCo 3014
xor84
a b xor
T T F
T F T
F T T
F F F
NAND
NAND
NAND
NAND
Ryan Davis, Seattle.rbLet’s Build a Computer!
@the_zenspiderGoGaRuCo 3014
mux
85
Ryan Davis, Seattle.rbLet’s Build a Computer!
@the_zenspiderGoGaRuCo 3014
Muxes are Easy!mux = if sel then b else a end
86
Ryan Davis, Seattle.rbLet’s Build a Computer!
@the_zenspiderGoGaRuCo 3014
Muxes are Easy!mux = if sel then b else a end
86
Just an if
stateme
nt!
Ryan Davis, Seattle.rbLet’s Build a Computer!
@the_zenspiderGoGaRuCo 3014
mux87
mux
sel a b xorT T T TT T F FT F T TT F F FF T T TF T F TF F T FF F F F
Ryan Davis, Seattle.rbLet’s Build a Computer!
@the_zenspiderGoGaRuCo 3014
mux88
sel a b xorT T T TT T F FT F T TT F F FF T T TF T F TF F T FF F F F
mux
Ryan Davis, Seattle.rbLet’s Build a Computer!
@the_zenspiderGoGaRuCo 3014
mux89
sel a b xorT T T TT T F FT F T TT F F FF T T TF T F TF F T FF F F F
mux
Ryan Davis, Seattle.rbLet’s Build a Computer!
@the_zenspiderGoGaRuCo 3014
mux90
AND
AND
OR
sel a b xorT T T TT T F FT F T TT F F FF T T TF T F TF F T FF F F F
Ryan Davis, Seattle.rbLet’s Build a Computer!
@the_zenspiderGoGaRuCo 3014
mux91
NAND
NAND
NAND
sel a b xorT T T TT T F FT F T TT F F FF T T TF T F TF F T FF F F F
Ryan Davis, Seattle.rbLet’s Build a Computer!
@the_zenspiderGoGaRuCo 3014 92
dmux
Ryan Davis, Seattle.rbLet’s Build a Computer!
@the_zenspiderGoGaRuCo 3014
DMuxes are easy, kindaif sel then a = in else b = in end
93
Ryan Davis, Seattle.rbLet’s Build a Computer!
@the_zenspiderGoGaRuCo 3014
dmux
dmux94
sel in a b
T T T F
T F F F
F T F T
F F F F
Ryan Davis, Seattle.rbLet’s Build a Computer!
@the_zenspiderGoGaRuCo 3014
AND
AND
dmux95
sel in a b
T T T F
T F F F
F T F T
F F F F
Ryan Davis, Seattle.rbLet’s Build a Computer!
@the_zenspiderGoGaRuCo 3014
dmux96
NAND NAND
NAND NAND
sel in a b
T T T F
T F F F
F T F T
F F F F
Ryan Davis, Seattle.rbLet’s Build a Computer!
@the_zenspiderGoGaRuCo 3014
N-way Gates
97
Ryan Davis, Seattle.rbLet’s Build a Computer!
@the_zenspiderGoGaRuCo 3014
or8way
98
Ryan Davis, Seattle.rbLet’s Build a Computer!
@the_zenspiderGoGaRuCo 3014
or8waydef or8way a,b,c,d,e,f,g,h a || b || c || d || e || f || g || h end
99
Ryan Davis, Seattle.rbLet’s Build a Computer!
@the_zenspiderGoGaRuCo 3014 100
OR
OR
OR
OR
OR
OR
OR
Ryan Davis, Seattle.rbLet’s Build a Computer!
@the_zenspiderGoGaRuCo 3014 100
OR
OR
OR
OR
OR
OR
OR
ab
c
d
e
f
g
h
inpu
ts
Ryan Davis, Seattle.rbLet’s Build a Computer!
@the_zenspiderGoGaRuCo 3014 100
OR
OR
OR
OR
OR
OR
OR
ab
c
d
e
f
g
h 1 output
inpu
ts
Ryan Davis, Seattle.rbLet’s Build a Computer!
@the_zenspiderGoGaRuCo 3014 100
OR
OR
OR
OR
OR
OR
OR
ab
c
d
e
f
g
h 1 output
1
2
3
4
5
6
inpu
tsdepth/tim
e
Ryan Davis, Seattle.rbLet’s Build a Computer!
@the_zenspiderGoGaRuCo 3014 101
OR
OR
OR
OR
OR
OR
OR
Ryan Davis, Seattle.rbLet’s Build a Computer!
@the_zenspiderGoGaRuCo 3014 101
OR
OR
OR
OR
OR
OR
OR
ab
cd
ef
gh
inpu
ts
Ryan Davis, Seattle.rbLet’s Build a Computer!
@the_zenspiderGoGaRuCo 3014 101
OR
OR
OR
OR
OR
OR
OR
ab
cd
ef
gh
1 output
inpu
ts
Ryan Davis, Seattle.rbLet’s Build a Computer!
@the_zenspiderGoGaRuCo 3014 101
OR
OR
OR
OR
OR
OR
OR
ab
cd
ef
gh
1 output
inpu
ts1
2
depth/time
Ryan Davis, Seattle.rbLet’s Build a Computer!
@the_zenspiderGoGaRuCo 3014
Muxes
102
Ryan Davis, Seattle.rbLet’s Build a Computer!
@the_zenspiderGoGaRuCo 3014
mux4way
mux4way
103
2 bit selector
Ryan Davis, Seattle.rbLet’s Build a Computer!
@the_zenspiderGoGaRuCo 3014
mux8way
3 bit selector
mux8way
104
Ryan Davis, Seattle.rbLet’s Build a Computer!
@the_zenspiderGoGaRuCo 3014
dmux4way
dmux4way
105
2 bit selector
Ryan Davis, Seattle.rbLet’s Build a Computer!
@the_zenspiderGoGaRuCo 3014
dmux8way
dmux8way
3 bit selector
Ryan Davis, Seattle.rbLet’s Build a Computer!
@the_zenspiderGoGaRuCo 3014
“Trivial”107
Ryan Davis, Seattle.rbLet’s Build a Computer!
@the_zenspiderGoGaRuCo 3014
Exercise for the
“Reader”108
Ryan Davis, Seattle.rbLet’s Build a Computer!
@the_zenspiderGoGaRuCo 3014
Just Remember
109
Ryan Davis, Seattle.rbLet’s Build a Computer!
@the_zenspiderGoGaRuCo 3014
Complexity builds from Simplicity
110
Ryan Davis, Seattle.rbLet’s Build a Computer!
@the_zenspiderGoGaRuCo 3014
16 Bit Logic & More
111
Ryan Davis, Seattle.rbLet’s Build a Computer!
@the_zenspiderGoGaRuCo 3014 112
NOT
NOT
NOT
NOT
NOT
NOT
NOT
NOT
NOT
NOT
NOT
NOT
NOT
NOT
NOT
NOT
Ryan Davis, Seattle.rbLet’s Build a Computer!
@the_zenspiderGoGaRuCo 3014 113
AND
AND
AND
AND
AND
AND
AND
AND
AND
AND
AND
AND
AND
AND
AND
AND
Ryan Davis, Seattle.rbLet’s Build a Computer!
@the_zenspiderGoGaRuCo 3014 114
OR
OR
OR
OR
OR
OR
OR
OR
OR
OR
OR
OR
OR
OR
OR
OR
Ryan Davis, Seattle.rbLet’s Build a Computer!
@the_zenspiderGoGaRuCo 3014 115
mux
mux
mux
mux
mux
mux
mux
mux
mux
mux
mux
mux
mux
mux
mux
mux
Ryan Davis, Seattle.rbLet’s Build a Computer!
@the_zenspiderGoGaRuCo 3014
“Trivial”116
Ryan Davis, Seattle.rbLet’s Build a Computer!
@the_zenspiderGoGaRuCo 3014
Exercise for the Reader
117
Ryan Davis, Seattle.rbLet’s Build a Computer!
@the_zenspiderGoGaRuCo 3014
Boolean Arithmetic
118
Ryan Davis, Seattle.rbLet’s Build a Computer!
@the_zenspiderGoGaRuCo 3014
Adders!
119
Ryan Davis, Seattle.rbLet’s Build a Computer!
@the_zenspiderGoGaRuCo 3014
Not these Adders
120
https://www.flickr.com/photos/79818573@N04/14226945188
Ryan Davis, Seattle.rbLet’s Build a Computer!
@the_zenspiderGoGaRuCo 3014
Nor Black Adder
121
Ryan Davis, Seattle.rbLet’s Build a Computer!
@the_zenspiderGoGaRuCo 3014
Just Good, Simple,
Arithmetic!122
Ryan Davis, Seattle.rbLet’s Build a Computer!
@the_zenspiderGoGaRuCo 3014
Adders, Elementary-School Style
123
11 +012
Ryan Davis, Seattle.rbLet’s Build a Computer!
@the_zenspiderGoGaRuCo 3014
Adders, Elementary-School Style
123
11 +01
A
2
Ryan Davis, Seattle.rbLet’s Build a Computer!
@the_zenspiderGoGaRuCo 3014
Adders, Elementary-School Style
123
11 +01
A
B2
Ryan Davis, Seattle.rbLet’s Build a Computer!
@the_zenspiderGoGaRuCo 3014
Adders, Elementary-School Style
123
11 +01
A
B
02
Ryan Davis, Seattle.rbLet’s Build a Computer!
@the_zenspiderGoGaRuCo 3014
Adders, Elementary-School Style
123
11 +01
A
B
Sum0
2
Ryan Davis, Seattle.rbLet’s Build a Computer!
@the_zenspiderGoGaRuCo 3014
Adders, Elementary-School Style
123
11 +01
1
A
B
Sum0
2
Ryan Davis, Seattle.rbLet’s Build a Computer!
@the_zenspiderGoGaRuCo 3014
Adders, Elementary-School Style
123
11 +01
1
A
B
Sum
Carry
02
Ryan Davis, Seattle.rbLet’s Build a Computer!
@the_zenspiderGoGaRuCo 3014
Adders, Elementary-School Style
123
11 +01
1
A
B
Sum
Carry
002
Ryan Davis, Seattle.rbLet’s Build a Computer!
@the_zenspiderGoGaRuCo 3014
Adders, Elementary-School Style
123
11 +01
11
A
B
Sum
Carry
002
Ryan Davis, Seattle.rbLet’s Build a Computer!
@the_zenspiderGoGaRuCo 3014
Adders, Elementary-School Style
123
11 +01
11
A
B
Sum
Carry
1 002
Ryan Davis, Seattle.rbLet’s Build a Computer!
@the_zenspiderGoGaRuCo 3014
Adders
124
11 +01
11
A
B
Sum
Carry
1 00
half adder
2
Ryan Davis, Seattle.rbLet’s Build a Computer!
@the_zenspiderGoGaRuCo 3014
11 +01
Adders
125
11
A
B
Sum
Cin
1 00
Carry
full adder
2
Ryan Davis, Seattle.rbLet’s Build a Computer!
@the_zenspiderGoGaRuCo 3014
Half Adder
126
AND
XOR Sum
Carry
A
B
Ryan Davis, Seattle.rbLet’s Build a Computer!
@the_zenspiderGoGaRuCo 3014
Full Adder
127
XOR XOR
AND
AND
OR
Sum
Carry
A
B
Cin
Ryan Davis, Seattle.rbLet’s Build a Computer!
@the_zenspiderGoGaRuCo 3014
16-bit Adder
128
Ryan Davis, Seattle.rbLet’s Build a Computer!
@the_zenspiderGoGaRuCo 3014
add16
129
FullAdder
FullAdder
FullAdder
FullAdder
FullAdder
FullAdder
FullAdder
FullAdder
FullAdder
FullAdder
FullAdder
FullAdder
FullAdder
FullAdder
FullAdder
FullAdder
0
x0
y0
x1
y1
s13
s14
s15
x2
y2
...
…
Ryan Davis, Seattle.rbLet’s Build a Computer!
@the_zenspiderGoGaRuCo 3014
But Ryan!130
Ryan Davis, Seattle.rbLet’s Build a Computer!
@the_zenspiderGoGaRuCo 3014
Doesn’t this have the same problem as or8way?
131
Ryan Davis, Seattle.rbLet’s Build a Computer!
@the_zenspiderGoGaRuCo 3014
Why, Yes!132
Ryan Davis, Seattle.rbLet’s Build a Computer!
@the_zenspiderGoGaRuCo 3014
Yes, it does!
133
Ryan Davis, Seattle.rbLet’s Build a Computer!
@the_zenspiderGoGaRuCo 3014
What they don’t teach you in grade school…
134
Ryan Davis, Seattle.rbLet’s Build a Computer!
@the_zenspiderGoGaRuCo 3014
Full Adder
135
XOR XOR
AND
AND
OR
Sum
Carry
A
B
Cin
Ryan Davis, Seattle.rbLet’s Build a Computer!
@the_zenspiderGoGaRuCo 3014
XOR XOR
AND
AND
OR
Sum
Carry
A
B
Cin
Full Adder?
136
Ryan Davis, Seattle.rbLet’s Build a Computer!
@the_zenspiderGoGaRuCo 3014
XOR XOR
AND
Sum
A
B
Cin
Propagate
Generate
OR
Partial Full Adder
137
Ryan Davis, Seattle.rbLet’s Build a Computer!
@the_zenspiderGoGaRuCo 3014
S0S1S2S3P0P1P2P3
G0G1G2G3PFA
CLA
C0
A0 B0
PFA
A1 B1
PFA
A2 B2
PFA
A3 B3
C4
Add4
138
Ryan Davis, Seattle.rbLet’s Build a Computer!
@the_zenspiderGoGaRuCo 3014
Add16
139
S0-3S4-7S8-11S12-15P0P1P2P3
G0G1G2G3add4
CLA
C0
A0-3 B0-3
add4
A4-7 B4-7
add4
A8-11 B8-11
add4
A12-15 B12-15
C4
Ryan Davis, Seattle.rbLet’s Build a Computer!
@the_zenspiderGoGaRuCo 3014
Carry Lookahead Monster
140
cla2 (1
of 1)
c1x1
p3x1
p1x1g2x1
c3x1c2x1
p0x1g0x1
p2x1c0x1
c4x1
g3x1g1x1
Ryan Davis, Seattle.rbLet’s Build a Computer!
@the_zenspiderGoGaRuCo 3014
Slightly Less Scary? (define (cla g0 g1 g2 g3 p0 p1 p2 p3 cin c1 c2 c3 pout gout) (let-values ([(w1c0 w1c1 w1c2) (wires w 3)] [(w2c1 w2c2) (wires w 2)] [(w3c2) (w)] [(w1g w2g w3g) (wires w 3)]) (append (list (comment (comment-cla))) (And p0 cin w1c0) (Or g0 w1c0 c1) ! (And p1 g0 w1c1) (and3 p1 p0 cin w2c1) (or3 g1 w1c1 w2c1 c2) ! (And p2 g1 w1c2) (and3 p2 p1 g0 w2c2) (and4 p2 p1 p0 cin w3c2) (or4 g2 w1c2 w2c2 w3c2 c3) ! (And p3 g2 w1g) (and3 p3 p2 g1 w2g) (and4 p3 p2 p1 g0 w3g) ! (or4 g3 w1g w2g w3g gout) (and4 p3 p2 p1 p0 pout))))
141
Ryan Davis, Seattle.rbLet’s Build a Computer!
@the_zenspiderGoGaRuCo 3014
Slightly Less Scary? (define (cla g0 g1 g2 g3 p0 p1 p2 p3 cin c1 c2 c3 pout gout) (let-values ([(w1c0 w1c1 w1c2) (wires w 3)] [(w2c1 w2c2) (wires w 2)] [(w3c2) (w)] [(w1g w2g w3g) (wires w 3)]) (append (list (comment (comment-cla))) (And p0 cin w1c0) (Or g0 w1c0 c1) ! (And p1 g0 w1c1) (and3 p1 p0 cin w2c1) (or3 g1 w1c1 w2c1 c2) ! (And p2 g1 w1c2) (and3 p2 p1 g0 w2c2) (and4 p2 p1 p0 cin w3c2) (or4 g2 w1c2 w2c2 w3c2 c3) ! (And p3 g2 w1g) (and3 p3 p2 g1 w2g) (and4 p3 p2 p1 g0 w3g) ! (or4 g3 w1g w2g w3g gout) (and4 p3 p2 p1 p0 pout))))
141
No, not really.
Ryan Davis, Seattle.rbLet’s Build a Computer!
@the_zenspiderGoGaRuCo 3014
Least Scary, Most Abstract
142
Ci = Gi + PiCi-1 Gi = AiBi Pi = Ai + Bi
Ryan Davis, Seattle.rbLet’s Build a Computer!
@the_zenspiderGoGaRuCo 3014
Least Scary, Most Abstract
142
Ci = Gi + PiCi-1 Gi = AiBi Pi = Ai + Bi
Ryan Davis, Seattle.rbLet’s Build a Computer!
@the_zenspiderGoGaRuCo 3014
Least Scary, Most Concrete
143
C1 = G0 + P0C0 C2 = G1 + P1G0 + P1P0C0 C3 = G2 + P2G1 + P2P1G0 + P2P1P0C0 C4 = G3 + P3P2G1 + P3P2P1G0 + P3P2P1P0C0
Ryan Davis, Seattle.rbLet’s Build a Computer!
@the_zenspiderGoGaRuCo 3014
Least Scary, Most Concrete
143
C1 = G0 + P0C0 C2 = G1 + P1G0 + P1P0C0 C3 = G2 + P2G1 + P2P1G0 + P2P1P0C0 C4 = G3 + P3P2G1 + P3P2P1G0 + P3P2P1P0C0
I can handle that…
Ryan Davis, Seattle.rbLet’s Build a Computer!
@the_zenspiderGoGaRuCo 3014
Just Details
144
Ryan Davis, Seattle.rbLet’s Build a Computer!
@the_zenspiderGoGaRuCo 3014
Incrementers
145
Ryan Davis, Seattle.rbLet’s Build a Computer!
@the_zenspiderGoGaRuCo 3014
Inc16
146
Half Adder
Half Adder
Half Adder
Half Adder
Half Adder
Half Adder
Half Adder
Half Adder
Half Adder
Half Adder
Half Adder
Half Adder
Half Adder
Half Adder
Half Adder
Half Adder
1
i1
i2
i3
i4
o15
o14
o13
o12…
…
Ryan Davis, Seattle.rbLet’s Build a Computer!
@the_zenspiderGoGaRuCo 3014
Faster, but Scarier
147
����������
����������
����������
����������
����������
����������
����������� ���������
�����������������
����
��� ��������
������ ������ ����� ������ ������ ������ ����� ����� �����
����� ����� ����� ���� ����� ����� �����
������������ ��
�� ���������
�
������
http://www.righto.com/2013/11/the-z-80s-16-bit-incrementdecrement.html
Ryan Davis, Seattle.rbLet’s Build a Computer!
@the_zenspiderGoGaRuCo 3014
ALU
148
Ryan Davis, Seattle.rbLet’s Build a Computer!
@the_zenspiderGoGaRuCo 3014
Arithmetic Logic Unit
149
f(x,y)ALU
zx zynx ny f no
zr ng
x
y
out
Ryan Davis, Seattle.rbLet’s Build a Computer!
@the_zenspiderGoGaRuCo 3014
Arithmetic Logic Unit
149
f(x,y)ALU
zx zynx ny f no
zr ng
x
y
out
Ryan Davis, Seattle.rbLet’s Build a Computer!
@the_zenspiderGoGaRuCo 3014
Arithmetic Logic Unit
149
f(x,y)ALU
zx zynx ny f no
zr ng
x
y
out
Ryan Davis, Seattle.rbLet’s Build a Computer!
@the_zenspiderGoGaRuCo 3014
Arithmetic Logic Unit
149
f(x,y)ALU
zx zynx ny f no
zr ng
x
y
out
Ryan Davis, Seattle.rbLet’s Build a Computer!
@the_zenspiderGoGaRuCo 3014
Arithmetic Logic Unit
149
f(x,y)ALU
zx zynx ny f no
zr ng
x
y
out
Ryan Davis, Seattle.rbLet’s Build a Computer!
@the_zenspiderGoGaRuCo 3014
Arithmetic Logic UnitIN x[16], y[16], // 16-bit inputs zx, // zero the x input? nx, // negate the x input? zy, // zero the y input? ny, // negate the y input? f, // compute out = x+y (f=1) else x&y no; // negate the out output? !OUT out[16], // 16-bit output zr, // 1 if (out == 0), 0 otherwise ng; // 1 if (out < 0), 0 otherwise
150
Ryan Davis, Seattle.rbLet’s Build a Computer!
@the_zenspiderGoGaRuCo 3014
Arithmetic Logic UnitIN x[16], y[16], // 16-bit inputs zx, // zero the x input? nx, // negate the x input? zy, // zero the y input? ny, // negate the y input? f, // compute out = x+y (f=1) else x&y no; // negate the out output? !OUT out[16], // 16-bit output zr, // 1 if (out == 0), 0 otherwise ng; // 1 if (out < 0), 0 otherwise
150
YUCK!
Ryan Davis, Seattle.rbLet’s Build a Computer!
@the_zenspiderGoGaRuCo 3014 151
Arithmetic Logic UnitMux16(a=x, b=false, sel=zx, out=x2); Mux16(a=y, b=false, sel=zy, out=y2); !Not16(in=x2, out=notx2); // if (zx==1) set x = 0 Not16(in=y2, out=noty2); // if (zy==1) set y = 0 !Mux16(a=x2, b=notx2, sel=nx, out=x3); // if (nx==1) set x = ~x Mux16(a=y2, b=noty2, sel=ny, out=y3); // if (ny==1) set y = ~y !Add16(a=x3, b=y3, out=add16); // if (f==1) set out = x + y And16(a=x3, b=y3, out=and16); // if (f==0) set out = x & y Mux16(a=and16, b=add16, sel=f, out=out1); !Not16(in=out1, out=notout); Mux16(a=out1, b=notout, sel=no, out=out, // if (no==1) set out = ~out out[0..7]=out2a, out[8..15]=out2b, out[15]=ng); // if (out<0) set ng = 1 !Or8Way(in=out2a, out=outa); Or8Way(in=out2b, out=outb); Or(a=outa, b=outb, out=nzr); !Not(in=nzr, out=zr); // if (out==0) set zr = 1
Ryan Davis, Seattle.rbLet’s Build a Computer!
@the_zenspiderGoGaRuCo 3014 151
Arithmetic Logic Unit
YUCK!Mux16(a=x, b=false, sel=zx, out=x2);
Mux16(a=y, b=false, sel=zy, out=y2); !Not16(in=x2, out=notx2); // if (zx==1) set x = 0 Not16(in=y2, out=noty2); // if (zy==1) set y = 0 !Mux16(a=x2, b=notx2, sel=nx, out=x3); // if (nx==1) set x = ~x Mux16(a=y2, b=noty2, sel=ny, out=y3); // if (ny==1) set y = ~y !Add16(a=x3, b=y3, out=add16); // if (f==1) set out = x + y And16(a=x3, b=y3, out=and16); // if (f==0) set out = x & y Mux16(a=and16, b=add16, sel=f, out=out1); !Not16(in=out1, out=notout); Mux16(a=out1, b=notout, sel=no, out=out, // if (no==1) set out = ~out out[0..7]=out2a, out[8..15]=out2b, out[15]=ng); // if (out<0) set ng = 1 !Or8Way(in=out2a, out=outa); Or8Way(in=out2b, out=outb); Or(a=outa, b=outb, out=nzr); !Not(in=nzr, out=zr); // if (out==0) set zr = 1
Ryan Davis, Seattle.rbLet’s Build a Computer!
@the_zenspiderGoGaRuCo 3014 151
Arithmetic Logic Unit
YUCK!Mux16(a=x, b=false, sel=zx, out=x2);
Mux16(a=y, b=false, sel=zy, out=y2); !Not16(in=x2, out=notx2); // if (zx==1) set x = 0 Not16(in=y2, out=noty2); // if (zy==1) set y = 0 !Mux16(a=x2, b=notx2, sel=nx, out=x3); // if (nx==1) set x = ~x Mux16(a=y2, b=noty2, sel=ny, out=y3); // if (ny==1) set y = ~y !Add16(a=x3, b=y3, out=add16); // if (f==1) set out = x + y And16(a=x3, b=y3, out=and16); // if (f==0) set out = x & y Mux16(a=and16, b=add16, sel=f, out=out1); !Not16(in=out1, out=notout); Mux16(a=out1, b=notout, sel=no, out=out, // if (no==1) set out = ~out out[0..7]=out2a, out[8..15]=out2b, out[15]=ng); // if (out<0) set ng = 1 !Or8Way(in=out2a, out=outa); Or8Way(in=out2b, out=outb); Or(a=outa, b=outb, out=nzr); !Not(in=nzr, out=zr); // if (out==0) set zr = 1
Ryan Davis, Seattle.rbLet’s Build a Computer!
@the_zenspiderGoGaRuCo 3014 151
Arithmetic Logic Unit
My Mind,
She Asplodes!
YUCK!Mux16(a=x, b=false, sel=zx, out=x2);
Mux16(a=y, b=false, sel=zy, out=y2); !Not16(in=x2, out=notx2); // if (zx==1) set x = 0 Not16(in=y2, out=noty2); // if (zy==1) set y = 0 !Mux16(a=x2, b=notx2, sel=nx, out=x3); // if (nx==1) set x = ~x Mux16(a=y2, b=noty2, sel=ny, out=y3); // if (ny==1) set y = ~y !Add16(a=x3, b=y3, out=add16); // if (f==1) set out = x + y And16(a=x3, b=y3, out=and16); // if (f==0) set out = x & y Mux16(a=and16, b=add16, sel=f, out=out1); !Not16(in=out1, out=notout); Mux16(a=out1, b=notout, sel=no, out=out, // if (no==1) set out = ~out out[0..7]=out2a, out[8..15]=out2b, out[15]=ng); // if (out<0) set ng = 1 !Or8Way(in=out2a, out=outa); Or8Way(in=out2b, out=outb); Or(a=outa, b=outb, out=nzr); !Not(in=nzr, out=zr); // if (out==0) set zr = 1
Ryan Davis, Seattle.rbLet’s Build a Computer!
@the_zenspiderGoGaRuCo 3014
Mux16(a=y2, b=noty2, sel=ny, out=y3); // if (ny==1) set y = ~y !Add16(a=x3, b=y3, out=add16); // if (f==1) set out = x + y And16(a=x3, b=y3, out=and16); // if (f==0) set out = x & y Mux16(a=and16, b=add16, sel=f, out=out1); !Not16(in=out1, out=notout); Mux16(a=out1, b=notout, sel=no, out=out, // if (no==1) set out = ~out out[0..7]=out2a, out[8..15]=out2b, out[15]=ng); // if (out<0) set ng = 1 !Or8Way(in=out2a, out=outa); Or8Way(in=out2b, out=outb); Or(a=outa, b=outb, out=nzr); !Not(in=nzr, out=zr); // if (out==0) set zr = 1152
My Mind,
She Asplodes!
Ryan Davis, Seattle.rbLet’s Build a Computer!
@the_zenspiderGoGaRuCo 3014
b0-7
b8-15
mux
mux
mux mux
mux muxNOT
NOT
NOT AND
add16
OR8
OR8
OR
out
zr
0
zy
0
y
x
zx
nx
ny
fno
ng
b15
Arithmetic Logic Unit
153
Ryan Davis, Seattle.rbLet’s Build a Computer!
@the_zenspiderGoGaRuCo 3014
b0-7
b8-15
mux
mux
mux mux
mux muxNOT
NOT
NOT AND
add16
OR8
OR8
OR
out
zr
0
zy
0
y
x
zx
nx
ny
fno
ng
b15
Arithmetic Logic Unit
153
Ryan Davis, Seattle.rbLet’s Build a Computer!
@the_zenspiderGoGaRuCo 3014
b0-7
b8-15
mux
mux
mux mux
mux muxNOT
NOT
NOT AND
add16
OR8
OR8
OR
out
zr
0
zy
0
y
x
zx
nx
ny
fno
ng
b15
Arithmetic Logic Unit
153
Always
Both
Ryan Davis, Seattle.rbLet’s Build a Computer!
@the_zenspiderGoGaRuCo 3014
b0-7
b8-15
mux
mux
mux mux
mux muxNOT
NOT
NOT AND
add16
OR8
OR8
OR
out
zr
0
zy
0
y
x
zx
nx
ny
fno
ng
b15
Arithmetic Logic Unit
153
Always
Both
Ryan Davis, Seattle.rbLet’s Build a Computer!
@the_zenspiderGoGaRuCo 3014
b0-7
b8-15
mux
mux
mux mux
mux muxNOT
NOT
NOT AND
add16
OR8
OR8
OR
out
zr
0
zy
0
y
x
zx
nx
ny
fno
ng
b15
Arithmetic Logic Unit
153
Always
Both Multiple &
Partial!!
Ryan Davis, Seattle.rbLet’s Build a Computer!
@the_zenspiderGoGaRuCo 3014
f(x,y)
zx zynx ny f no
zr ng
x
y
out
Arithmetic Logic Unit
154
b0-7
b8-15
mux
mux
mux mux
mux muxNOT
NOT
NOT AND
add16
OR8
OR8
OR
out
zr
0
zy
0
y
x
zx
nx
ny
fno
ng
b15
Ryan Davis, Seattle.rbLet’s Build a Computer!
@the_zenspiderGoGaRuCo 3014
6 little flags = Instruction set
155
01 -1x y
!x !y-x -y
x+1 y+1x-1 y-1x+yx-y y-xx&y x|y
Ryan Davis, Seattle.rbLet’s Build a Computer!
@the_zenspiderGoGaRuCo 3014
ALU in 440 NAND Gates By Mark Armbrust w/ Koen Simmons’ optimizations.
via forums for nand2tetris
156
Ryan Davis, Seattle.rbLet’s Build a Computer!
@the_zenspiderGoGaRuCo 3014
ALU in 440 NAND Gates By Mark Armbrust w/ Koen Simmons’ optimizations.
via forums for nand2tetris
156
Ryan Davis, Seattle.rbLet’s Build a Computer!
@the_zenspiderGoGaRuCo 3014
ALU in 440 NAND Gates By Mark Armbrust w/ Koen Simmons’ optimizations.
via forums for nand2tetris
156
Ryan Davis, Seattle.rbLet’s Build a Computer!
@the_zenspiderGoGaRuCo 3014
ALU in 440 NAND Gates By Mark Armbrust w/ Koen Simmons’ optimizations.
via forums for nand2tetris
156
Ryan Davis, Seattle.rbLet’s Build a Computer!
@the_zenspiderGoGaRuCo 3014
Sequential Logic
157
Ryan Davis, Seattle.rbLet’s Build a Computer!
@the_zenspiderGoGaRuCo 3014
Combinational vs
Sequential158
Ryan Davis, Seattle.rbLet’s Build a Computer!
@the_zenspiderGoGaRuCo 3014
SomeLogicin out
Combinational Chips
159
Ryan Davis, Seattle.rbLet’s Build a Computer!
@the_zenspiderGoGaRuCo 3014
InputLogic
OutputLogicMemoryin out
Sequential Chips
160
Ryan Davis, Seattle.rbLet’s Build a Computer!
@the_zenspiderGoGaRuCo 3014
InputLogic
OutputLogicMemoryin out
Sequential Chips
160Clock Input
Ryan Davis, Seattle.rbLet’s Build a Computer!
@the_zenspiderGoGaRuCo 3014
DFF
161
Ryan Davis, Seattle.rbLet’s Build a Computer!
@the_zenspiderGoGaRuCo 3014
DFF “Magic” Logic:
out(t) = in(t-1)
162
Ryan Davis, Seattle.rbLet’s Build a Computer!
@the_zenspiderGoGaRuCo 3014
Atomic in nand2tetris
163
Ryan Davis, Seattle.rbLet’s Build a Computer!
@the_zenspiderGoGaRuCo 3014
Can be created with nands!
164
Ryan Davis, Seattle.rbLet’s Build a Computer!
@the_zenspiderGoGaRuCo 3014
Building a DFF using the TECS Hardware Simulator, by Mark Armbrust.
http://www.marksmath.com/tecs/dff/
From NAND to DFF
165
Ryan Davis, Seattle.rbLet’s Build a Computer!
@the_zenspiderGoGaRuCo 3014
Building a DFF using the TECS Hardware Simulator, by Mark Armbrust.
http://www.marksmath.com/tecs/dff/
From NAND to DFF
165
NAND
NAND
Ryan Davis, Seattle.rbLet’s Build a Computer!
@the_zenspiderGoGaRuCo 3014
Building a DFF using the TECS Hardware Simulator, by Mark Armbrust.
http://www.marksmath.com/tecs/dff/
From NAND to DFF
165
NAND
NAND
NAND
NAND
NAND
NAND
Ryan Davis, Seattle.rbLet’s Build a Computer!
@the_zenspiderGoGaRuCo 3014
Building a DFF using the TECS Hardware Simulator, by Mark Armbrust.
http://www.marksmath.com/tecs/dff/
From NAND to DFF
165
NAND
NAND
NAND
NAND
NAND
NAND
NAND
NAND
NAND
NAND
NAND
NAND
NAND
NAND
NOT
Ryan Davis, Seattle.rbLet’s Build a Computer!
@the_zenspiderGoGaRuCo 3014
!
Details166
Just
Ryan Davis, Seattle.rbLet’s Build a Computer!
@the_zenspiderGoGaRuCo 3014
!
Details166
Interesting
Ryan Davis, Seattle.rbLet’s Build a Computer!
@the_zenspiderGoGaRuCo 3014
bit
load
in out
167
Ryan Davis, Seattle.rbLet’s Build a Computer!
@the_zenspiderGoGaRuCo 3014
bitbit(t) = if load then in else bit(t-1) end !return bit(t)
168
bit
load
in out
Ryan Davis, Seattle.rbLet’s Build a Computer!
@the_zenspiderGoGaRuCo 3014
dff(t) = if load then in else dff(t-1) end !return dff(t)
bit
load
in outdff
bit
169
Ryan Davis, Seattle.rbLet’s Build a Computer!
@the_zenspiderGoGaRuCo 3014
dff(t) = if load then in else dff(t-1) end !return dff(t)
load
inout mux dff
bit
170
Ryan Davis, Seattle.rbLet’s Build a Computer!
@the_zenspiderGoGaRuCo 3014 171
register
load
in out
Ryan Davis, Seattle.rbLet’s Build a Computer!
@the_zenspiderGoGaRuCo 3014
load
in outbit0 bit1 bit15…
register
172
Ryan Davis, Seattle.rbLet’s Build a Computer!
@the_zenspiderGoGaRuCo 3014
bit0
load
in0 out0
bit1in1 out1
bit2in2 out2
…inN outN
bit15in15 out15
Simple Linear Layout
173
Ryan Davis, Seattle.rbLet’s Build a Computer!
@the_zenspiderGoGaRuCo 3014 174
RAMn
in
load
addr
out
Ryan Davis, Seattle.rbLet’s Build a Computer!
@the_zenspiderGoGaRuCo 3014
in
load
addr
out
register
load
in out
register
load
in out
register
load
in out
register
load
in out
…
175
Ryan Davis, Seattle.rbLet’s Build a Computer!
@the_zenspiderGoGaRuCo 3014
InputLogic
OutputLogicMemoryin out
Sequential Logic
176
register
load
in out
register
load
in out
register
load
in out
register
load
in out
…Addressing Addressing
Ryan Davis, Seattle.rbLet’s Build a Computer!
@the_zenspiderGoGaRuCo 3014
InputLogic
OutputLogicMemoryin out
RAM8
177
register
load
in out
register
load
in out
register
load
in out
register
load
in out
…dmux8way mux8way
Ryan Davis, Seattle.rbLet’s Build a Computer!
@the_zenspiderGoGaRuCo 3014
DFFBit
RegisterRam8Ram64Ram512Ram4KRam16K
Complexity builds from Simplicity
178
Ryan Davis, Seattle.rbLet’s Build a Computer!
@the_zenspiderGoGaRuCo 3014
DFFBit
RegisterRam8Ram64Ram512Ram4KRam16K
Complexity builds from Simplicity
178
×8
×8
×8
×8
×4
1bit×16
Ryan Davis, Seattle.rbLet’s Build a Computer!
@the_zenspiderGoGaRuCo 3014
RAM64+?179
Ryan Davis, Seattle.rbLet’s Build a Computer!
@the_zenspiderGoGaRuCo 3014
Again180
Ryan Davis, Seattle.rbLet’s Build a Computer!
@the_zenspiderGoGaRuCo 3014
Exercise for the
“Reader”181
Ryan Davis, Seattle.rbLet’s Build a Computer!
@the_zenspiderGoGaRuCo 3014
outcounter
load
in
resetincr
182
Ryan Davis, Seattle.rbLet’s Build a Computer!
@the_zenspiderGoGaRuCo 3014
AKA Program Counter
183
Ryan Davis, Seattle.rbLet’s Build a Computer!
@the_zenspiderGoGaRuCo 3014
Addresses current instruction
in ROM184
Ryan Davis, Seattle.rbLet’s Build a Computer!
@the_zenspiderGoGaRuCo 3014
RegisterInc16
Mux16
reset load inc
0
in
outMux16AND
AND
OR
OR
Mux16
185
Ryan Davis, Seattle.rbLet’s Build a Computer!
@the_zenspiderGoGaRuCo 3014
RegisterInc16
Mux16
reset load inc
0
in
outMux16AND
AND
OR
OR
Mux16
185
Blah Blah Logic
Ryan Davis, Seattle.rbLet’s Build a Computer!
@the_zenspiderGoGaRuCo 3014
RegisterInc16
Mux16
reset load inc
0
in
outMux16AND
AND
OR
OR
Mux16
185
The Magic
Blah Blah Logic
Ryan Davis, Seattle.rbLet’s Build a Computer!
@the_zenspiderGoGaRuCo 3014
Computer Architecture
186
Ryan Davis, Seattle.rbLet’s Build a Computer!
@the_zenspiderGoGaRuCo 3014 187
Memory
code&
data
CPUInput
Output
ALU
Registers
Control
Ryan Davis, Seattle.rbLet’s Build a Computer!
@the_zenspiderGoGaRuCo 3014
cpu
188
CPU
outM
writeM
addressM
pc
inM
instruction
reset
Ryan Davis, Seattle.rbLet’s Build a Computer!
@the_zenspiderGoGaRuCo 3014
CPU Guts
?189
Ryan Davis, Seattle.rbLet’s Build a Computer!
@the_zenspiderGoGaRuCo 3014
address outROM32K
rom32k
190
Ryan Davis, Seattle.rbLet’s Build a Computer!
@the_zenspiderGoGaRuCo 3014
outKeyboard
keyboard
191
Ryan Davis, Seattle.rbLet’s Build a Computer!
@the_zenspiderGoGaRuCo 3014
screen
192
load outScreen8K words
in
address
Ryan Davis, Seattle.rbLet’s Build a Computer!
@the_zenspiderGoGaRuCo 3014
keyboard
addr
in
RAM
Screen
Keyboard
out
screen
Memory
193
Ryan Davis, Seattle.rbLet’s Build a Computer!
@the_zenspiderGoGaRuCo 3014 194
Memory
code&
data
CPUInput
Output
ALU
Registers
Control
Ryan Davis, Seattle.rbLet’s Build a Computer!
@the_zenspiderGoGaRuCo 3014
computer
195
address outROM32K
CPU
outM
writeM
addressM
pc
inM
instruction
reset
keyboard
addr
in
RAM
Screen
Keyboard
out
screen
Ryan Davis, Seattle.rbLet’s Build a Computer!
@the_zenspiderGoGaRuCo 3014
Let’s Go Home!
196
Ryan Davis, Seattle.rbLet’s Build a Computer!
@the_zenspiderGoGaRuCo 3014
apollo guidance computer197
Ryan Davis, Seattle.rbLet’s Build a Computer!
@the_zenspiderGoGaRuCo 3014
Julian Simioni, MWRC 2014Software Development Lessons from the
Apollo Program
16-bit words.
Most software in ROM
Never had an error in flight.
http://www.ibiblio.org/apollo/ to fly your own.
198
Ryan Davis, Seattle.rbLet’s Build a Computer!
@the_zenspiderGoGaRuCo 3014
2,800 dual 3-input
NOR ICs!!199
http://upload.wikimedia.org/wikipedia/commons/1/13/Agc_flatp.jpg
Ryan Davis, Seattle.rbLet’s Build a Computer!
@the_zenspiderGoGaRuCo 3014
Thank You200