Professional Documents
Culture Documents
www.idc.ac.il/tecs
Elements of Computing Systems, Nisan & Schocken, MIT Press, www.idc.ac.il/tecs , Course Introduction
slide 1
Elements of Computing Systems, Nisan & Schocken, MIT Press, www.idc.ac.il/tecs , Course Introduction
slide 2
slide 3
Demo
Pong, 1985
Pong, 2011
Pong, on our
computer
Elements of Computing Systems, Nisan & Schocken, MIT Press, www.idc.ac.il/tecs , Course Introduction
slide 4
Abstract design
Software
hierarchy
abstract interface
Chapters 9, 12
H.L. Language
&
Operating Sys.
Compiler
abstract interface
Chapters 10 - 11
Virtual
Machine
VM Translator
abstract interface
Chapters 7 - 8
Assembly
Language
Assembler
Chapter 6
abstract interface
Machine
Language
Computer
Architecture
abstract interface
Chapters 4 - 5
Hardware
Platform
Hardware
hierarchy
Gate Logic
abstract interface
Chapters 1 - 3
Chips &
Logic Gates
Electrical
Engineering
Physics
(Abstractionimplementation paradigm)
Elements of Computing Systems, Nisan & Schocken, MIT Press, www.idc.ac.il/tecs , Course Introduction
slide 5
Ball
abstraction
Bat
abstraction
Elements of Computing Systems, Nisan & Schocken, MIT Press, www.idc.ac.il/tecs , Course Introduction
slide 6
Human
Thought
Abstract design
Software
hierarchy
abstract interface
Chapters 9, 12
H.L. Language
&
Operating Sys.
Compiler
abstract interface
Chapters 10 - 11
Virtual
Machine
VM Translator
abstract interface
Chapters 7 - 8
Assembly
Language
Assembler
Chapter 6
abstract interface
Machine
Language
Computer
Architecture
abstract interface
Chapters 4 - 5
Hardware
Platform
Hardware
hierarchy
Gate Logic
abstract interface
Chapters 1 - 3
Chips &
Logic Gates
Elements of Computing Systems, Nisan & Schocken, MIT Press, www.idc.ac.il/tecs , Course Introduction
Electrical
Engineering
Physics
slide 7
Typical call to
an OS method
/**
/** Moves
Moves the
the bat
bat one
one step
step (4
(4 pixels)
pixels) to
to the
the right.
right. */
*/
method
void
moveR()
{
method void moveR() {
do
do draw(false);
draw(false); //
// erase
erase the
the bat
bat at
at the
the current
current location
location
let
x
=
x
+
4;
//
change
the
bat's
X-location
let x = x + 4;
// change the bat's X-location
//
but
don't
go
beyond
// but don't go beyond the
the screen's
screen's right
right border
border
if
((x
+
width)
>
511)
{
if ((x + width) > 511) {
let
let xx == 511
511 -- width;
width;
}}
do
do draw(true);
draw(true); //
// re-draw
re-draw the
the bat
bat in
in the
the new
new location
location
return;
return;
}}
Ball
abstraction
Bat
abstraction
}}
Elements of Computing Systems, Nisan & Schocken, MIT Press, www.idc.ac.il/tecs , Course Introduction
slide 8
Ball
abstraction
Bat
abstraction
}}
}}
}}
Elements of Computing Systems, Nisan & Schocken, MIT Press, www.idc.ac.il/tecs , Course Introduction
slide 9
Human
Thought
Abstract design
Software
hierarchy
abstract interface
Chapters 9, 12
H.L. Language
&
Operating Sys.
Compiler
abstract interface
Chapters 10 - 11
Virtual
Machine
VM Translator
abstract interface
Chapters 7 - 8
Assembly
Language
Assembler
Chapter 6
abstract interface
Machine
Language
Computer
Architecture
abstract interface
Chapters 4 - 5
Hardware
Platform
Hardware
hierarchy
Gate Logic
abstract interface
Chapters 1 - 3
Chips &
Logic Gates
Elements of Computing Systems, Nisan & Schocken, MIT Press, www.idc.ac.il/tecs , Course Introduction
Electrical
Engineering
Physics
slide 10
...
Some
compiler
...
Some Other
language
Jack
language
Jack
compiler
Some Other
compiler
Projects
10-11
VM language
VM
implementation
over CISC
platforms
CISC
machine
language
VM imp.
over RISC
platforms
RISC
machine
language
CISC
machine
RISC
machine
written in
a high-level
language
...
...
VM imp.
over the Hack
platform
VM
emulator
Projects
7-8
Hack
machine
language
Projects
...
1-6
Any
computer
Elements of Computing Systems, Nisan & Schocken, MIT Press, www.idc.ac.il/tecs , Course Introduction
Hack
computer
slide 11
Compilation 101
Intermediate code
>
Source code
(x
(x ++ width)
width) >> 511
511
parsing
511
Code
generation
push
push xx
push
push width
width
add
add
push
push 511
511
gt
gt
Abstraction
Syntax
Analysis
width
Parse
Tree
Semantic
Synthesis
Implementation
Observations:
Modularity
Abstraction / implementation interplay
The implementation uses abstract services from the level below.
Elements of Computing Systems, Nisan & Schocken, MIT Press, www.idc.ac.il/tecs , Course Introduction
slide 12
The Virtual Machine (our stack-based VM, quite similar to Javas JVM)
if ((x+width)>511) {
let x=511-width;
}
...
width
75
450
...
// VM implementation
s2
memory (before)
450
sp
75
...
push x
// s1
push width
// s2
add
// s3
push 511
// s4
525
gt
// s5
511
if-goto L1
// s6
goto L2
// s7
s4
s5
s9
511
sp
450
sp
sp
L1:
push 511
// s8
push width
// s9
sub
// s10
pop x
// s11
s10
memory (after)
...
61
sp
width
...
L2:
...
Elements of Computing Systems, Nisan & Schocken, MIT Press, www.idc.ac.il/tecs , Course Introduction
450
61
...
slide 13
Human
Thought
Abstract design
Software
hierarchy
abstract interface
Chapters 9, 12
H.L. Language
&
Operating Sys.
Compiler
abstract interface
Chapters 10 - 11
Virtual
Machine
VM Translator
abstract interface
Chapters 7 - 8
Assembly
Language
Assembler
Chapter 6
abstract interface
Machine
Language
Computer
Architecture
abstract interface
Chapters 4 - 5
Hardware
Platform
Hardware
hierarchy
Gate Logic
abstract interface
Chapters 1 - 3
Chips &
Logic Gates
Elements of Computing Systems, Nisan & Schocken, MIT Press, www.idc.ac.il/tecs , Course Introduction
Electrical
Engineering
Physics
slide 14
For now,
ignore all
details!
VM
translator
Assembly program
gt
if-goto L1
// push 511
goto L2
@511
L1:
D=A
// D=511
push 511
@SP
push width
A=M
sub
M=D
pop x
@SP
@SP
M=M+1 // SP++
L2:
Assembler
// *SP=D
Executable
0000000000000000
1110110010001000
...
Elements of Computing Systems, Nisan & Schocken, MIT Press, www.idc.ac.il/tecs , Course Introduction
slide 15
Human
Thought
Abstract design
Software
hierarchy
abstract interface
Chapters 9, 12
H.L. Language
&
Operating Sys.
Compiler
abstract interface
Chapters 10 - 11
Virtual
Machine
VM Translator
abstract interface
Chapters 7 - 8
Assembly
Language
Assembler
Chapter 6
abstract interface
Machine
Language
Computer
Architecture
abstract interface
Chapters 4 - 5
Hardware
Platform
Hardware
hierarchy
Gate Logic
abstract interface
Chapters 1 - 3
Chips &
Logic Gates
Elements of Computing Systems, Nisan & Schocken, MIT Press, www.idc.ac.il/tecs , Course Introduction
Electrical
Engineering
Physics
slide 16
For now,
ignore all
details!
Address
Code syntax
0
0000000000000000
@0
1111110111001000
M=M-1
1
1 1
Instruction code
(1=compute inst.)
ALU
operation code
Destination
Code
Jump
Code
(M-1)
(M)
(no jump)
slide 17
For now,
ignore all
details!
Instruction
Memory
ALU
Data
Memory
data out
(M)
address of next
instruction
Program
Counter
data in
RAM(A)
slide 18
Abstract design
Software
hierarchy
abstract interface
Chapters 9, 12
H.L. Language
&
Operating Sys.
Compiler
abstract interface
Chapters 10 - 11
Virtual
Machine
VM Translator
abstract interface
Chapters 7 - 8
Assembly
Language
Assembler
Chapter 6
abstract interface
Machine
Language
Computer
Architecture
abstract interface
Chapters 4 - 5
Hardware
Platform
Hardware
hierarchy
Gate Logic
abstract interface
Chapters 1 - 3
Chips &
Logic Gates
Elements of Computing Systems, Nisan & Schocken, MIT Press, www.idc.ac.il/tecs , Course Introduction
Electrical
Engineering
Physics
slide 19
Logic design
Combinational logic
Sequential logic
(leading to an ALU)
(leading to a RAM)
Elements of Computing Systems, Nisan & Schocken, MIT Press, www.idc.ac.il/tecs , Course Introduction
slide 20
Gate logic
Hardware platform = inter-connected set of chips
Chips are made of simpler chips, all the way down to logic gates
Logic gate = hardware element that implements a certain Boolean function
Every chip and gate has an interface, specifying WHAT it is doing, and an
implementation, specifying HOW it is doing it.
Implementation
Interface
a
Xor
out
And
Not
Or
out
0
0
1
1
0
1
0
1
0
1
1
0
out
Not
And
Elements of Computing Systems, Nisan & Schocken, MIT Press, www.idc.ac.il/tecs , Course Introduction
slide 21
out
Not
And
CHIP Xor {
IN a,b;
OUT out;
PARTS:
Not(in=a,out=Nota);
Not(in=b,out=Notb);
And(a=a,b=Notb,out=w1);
And(a=Nota,b=b,out=w2);
Or(a=w1,b=w2,out=out);
}
Elements of Computing Systems, Nisan & Schocken, MIT Press, www.idc.ac.il/tecs , Course Introduction
slide 22
Interface
a
out
Nand
b
a
out
0
0
1
1
0
1
0
1
1
1
1
0
Elements of Computing Systems, Nisan & Schocken, MIT Press, www.idc.ac.il/tecs , Course Introduction
slide 23
Human
Thought
Abstract design
Software
hierarchy
abstract interface
Chapters 9, 12
H.L. Language
&
Operating Sys.
Compiler
abstract interface
Chapters 10 - 11
Virtual
Machine
VM Translator
abstract interface
Chapters 7 - 8
Assembly
Language
Assembler
Chapter 6
Course overview:
Building this world,
from the ground up
abstract interface
Machine
Language
Computer
Architecture
abstract interface
Chapters 4 - 5
Hardware
Platform
Hardware
hierarchy
Gate Logic
abstract interface
Chapters 1 - 3
Chips &
Logic Gates
Elements of Computing Systems, Nisan & Schocken, MIT Press, www.idc.ac.il/tecs , Course Introduction
Electrical
Engineering
Physics
slide 24