SlideShare a Scribd company logo
Elements of Computing Systems, Nisan & Schocken, MIT Press, www.nand2tetris.org , Chapter 5: Computer Architecture slide 1
www.nand2tetris.org
Building a Modern Computer From First Principles
Computer Architecture
Elements of Computing Systems, Nisan & Schocken, MIT Press, www.nand2tetris.org , Chapter 5: Computer Architecture slide 2
Babbage’s Analytical Engine (1835)
“We may say most aptly that the Analytical Engine
weaves algebraic patterns just as the Jacquard-
loom weaves flowers and leaves”
(Ada Lovelace)
Charles Babbage (1791-1871)
Elements of Computing Systems, Nisan & Schocken, MIT Press, www.nand2tetris.org , Chapter 5: Computer Architecture slide 3
Some early computers and computer scientists
Blaise Pascal
1623-1662
Gottfried Leibniz
1646-1716
Elements of Computing Systems, Nisan & Schocken, MIT Press, www.nand2tetris.org , Chapter 5: Computer Architecture slide 4
Von Neumann machine (circa 1940)
Arithmetic Logic
Unit (ALU)
CPU
Registers
Control
Memory
(data
+
instructions)
Input
device
Output
device
Andy Grove (and others) ... made it small and fast.John Von Neumann (and others) ... made it possible
Stored
program
concept!
Elements of Computing Systems, Nisan & Schocken, MIT Press, www.nand2tetris.org , Chapter 5: Computer Architecture slide 5
Arithmetic Logic
Unit (ALU)
CPU
Registers
Control
Memory
(data
+
instructions)
Input
device
Output
device
Processing logic: fetch-execute cycle
Executing the current instruction involves one or more of
the following micro-tasks:
Have the ALU compute some function out = f (register values)
Write the ALU output to selected registers
As a side-effect of this computation,
figure out which instruction to fetch and execute next.
Elements of Computing Systems, Nisan & Schocken, MIT Press, www.nand2tetris.org , Chapter 5: Computer Architecture slide 6
The Hack chip-set and hardware platform
Elementary logic gates
Nand
Not
And
Or
Xor
Mux
Dmux
Not16
And16
Or16
Mux16
Or8Way
Mux4Way16
Mux8Way16
DMux4Way
DMux8Way
Combinational chips
HalfAdder
FullAdder
Add16
Inc16
ALU
Sequential chips
DFF
Bit
Register
RAM8
RAM64
RAM512
RAM4K
RAM16K
PC
Computer Architecture
Memory
CPU
Computer
done
done
done
this lecture
Elements of Computing Systems, Nisan & Schocken, MIT Press, www.nand2tetris.org , Chapter 5: Computer Architecture slide 7
The Hack computer
Main parts of the Hack computer:
Instruction memory (ROM)
Memory (RAM):
• Data memory
• Screen (memory map)
• Keyboard (memory map)
CPU
Computer (the logic that holds everything together).
A 16-bit Von Neumann platform
The instruction memory and the data memory are physically separate
Screen: 512 rows by 256 columns, black and white
Keyboard: standard
Designed to execute programs written in the Hack machine language
Can be easily built from the chip-set that we built so far in the course
Elements of Computing Systems, Nisan & Schocken, MIT Press, www.nand2tetris.org , Chapter 5: Computer Architecture slide 8
Lecture / construction plan
Instruction memory
Memory:
Data memory
Screen
Keyboard
CPU
Computer
Elements of Computing Systems, Nisan & Schocken, MIT Press, www.nand2tetris.org , Chapter 5: Computer Architecture slide 9
Instruction memory
out
15 16
address
ROM32K
Function:
The ROM is pre-loaded with a program written in the Hack machine language
The ROM chip always emits a 16-bit number:
out = ROM32K[address]
This number is interpreted as the current instruction.
Elements of Computing Systems, Nisan & Schocken, MIT Press, www.nand2tetris.org , Chapter 5: Computer Architecture slide 10
Data memory
Low-level (hardware) read/write logic:
To read RAM[k]: set address to k,
probe out
To write RAM[k]=x: set address to k,
set in to x,
set load to 1,
run the clock
High-level (OS) read/write logic:
To read RAM[k]: use the OS command out = peek(k)
To write RAM[k]=x: use the OS command poke(k,x)
peek and poke are OS commands whose implementation should effect the same
behavior as the low-level commands
More about peek and poke this later in the course, when we’ll write the OS.
load
Elements of Computing Systems, Nisan & Schocken, MIT Press, www.nand2tetris.org , Chapter 5: Computer Architecture slide 11
Lecture / construction plan
Instruction memory
Memory:
Data memory
Screen
Keyboard
CPU
Computer
Elements of Computing Systems, Nisan & Schocken, MIT Press, www.nand2tetris.org , Chapter 5: Computer Architecture slide 12
Screen
The Screen chip has a basic RAM chip functionality:
read logic: out = Screen[address]
write logic: if load then Screen[address] = in
Side effect:
Continuously refreshes a 256 by 512 black-and-white
screen device
load
out
in
16
15
16address
Screen
Physical
Screen
The bit contents of the
Screen chip is called the
“screen memory map”
The simulated
256 by 512
B&W screen
When loaded into the
hardware simulator, the
built-in Screen.hdl chip
opens up a screen window;
the simulator then
refreshes this window
from the screen memory
map several times each
second.
Simulated screen:
Elements of Computing Systems, Nisan & Schocken, MIT Press, www.nand2tetris.org , Chapter 5: Computer Architecture slide 13
Screen memory map
How to set the (row,col) pixel of the screen to black or to white:
Low-level (machine language): Set the col%16 bit of the word found at
Screen[row*32+col/16] to 1 or to 0
(col/16 is integer division)
High-level: Use the OS command drawPixel(row,col)
(effects the same operation, discussed later in the course, when we’ll write the OS).
0
1
255
.
.
.
. . .0 1 2 3 4 5 6 7 511
0011000000000000
0000000000000000
0000000000000000
0
1
31
.
.
.
row 0
0001110000000000
0000000000000000
0000000000000000
32
33
63
.
.
.
row 1
0100100000000000
0000000000000000
0000000000000000
8129
8130
8160
.
.
.
row
255
. . .
. . .
. . .
.
.
.
refresh several times
each second
Screen
In the Hack platform,
the screen is
implemented as an 8K
16-bit RAM chip.
Elements of Computing Systems, Nisan & Schocken, MIT Press, www.nand2tetris.org , Chapter 5: Computer Architecture slide 14
Keyboard
Keyboard chip: a single 16-bit register
Input: scan-code (16-bit value) of the currently
pressed key, or 0 if no key is pressed
Output: same
How to read the keyboard:
Low-level (hardware): probe the contents of the Keyboard chip
High-level: use the OS command keyPressed()
(effects the same operation, discussed later in the course, when we’ll write the OS).
Special keys:
The keyboard is implemented as
a built-in Keyboard.hdl chip.
When this java chip is loaded
into the simulator, it connects
to the regular keyboard and
pipes the scan-code of the
currently pressed key to the
keyboard memory map.
The simulated
keyboard
enabler button
Simulated keyboard:
Elements of Computing Systems, Nisan & Schocken, MIT Press, www.nand2tetris.org , Chapter 5: Computer Architecture slide 15
Lecture / construction plan
Instruction memory
Memory:
Data memory
Screen
Keyboard
CPU
Computer
Elements of Computing Systems, Nisan & Schocken, MIT Press, www.nand2tetris.org , Chapter 5: Computer Architecture slide 16
Memory: conceptual / programmer’s view
Using the memory:
To record or recall values (e.g. variables, objects, arrays), use the first 16K words of
the memory
To write to the screen (or read the screen), use the next 8K words of the memory
To read which key is currently pressed, use the next word of the memory.
Data
Screen
memory
map
Keyboard map
Memory
Keyboard
Screen
Elements of Computing Systems, Nisan & Schocken, MIT Press, www.nand2tetris.org , Chapter 5: Computer Architecture slide 17
Memory: physical implementation
Access logic:
Access to any address from 0 to 16,383 results in accessing the RAM16K chip-part
Access to any address from 16,384 to 24,575 results in accessing the Screen chip-part
Access to address 24,576 results in accessing the keyboard chip-part
Access to any other address is invalid.
load
out
in
16
15
16
RAM16K
(16K mem. chip)
address
0
16383
Screen
(8K mem. chip)
16384
24575
24576
Keyboard
(one register)
Memory
Keyboard
Screen
The Memory chip is essentially a
package that integrates the three chip-
parts RAM16K, Screen, and Keyboard
into a single, contiguous address space.
This packaging effects the
programmer’s view of the memory, as
well as the necessary I/O side-effects.
Elements of Computing Systems, Nisan & Schocken, MIT Press, www.nand2tetris.org , Chapter 5: Computer Architecture slide 18
Lecture / construction plan
Instruction memory
Memory:
Data memory
Screen
Keyboard
CPU
Computer
Elements of Computing Systems, Nisan & Schocken, MIT Press, www.nand2tetris.org , Chapter 5: Computer Architecture slide 19
A pledge to patience ...
“At times … the fragments that I lay out for your inspection may
seem not to fit well together, as if they were stray pieces from
separate puzzles. In such cases, I would counsel patience. There
are moments when a large enough fragment can become a low
wall, a second fragment another wall to be raised at a right angle
to the first. A few struts and beams later, and we may made
ourselves a rough foundation … But it can consume the better
part of a chapter to build such a foundation; and as we do so the
fragment that we are examining may seem unconnected to the
larger whole. Only when we step back can we see that we have
been assembling something that can stand in the wind.”
From: Sailing the Wind Dark Sea (Thomas Cahill)
Elements of Computing Systems, Nisan & Schocken, MIT Press, www.nand2tetris.org , Chapter 5: Computer Architecture slide 20
CPU
instruction
inM
16
1
15
15
16 outM
16
writeM
addressM
pc
reset
1
CPU
to data
memory
to instruction
memory
from
data memory
from
instruction
memory
CPU internal components (invisible in this chip diagram): ALU and 3 registers: A, D, PC
CPU execute logic:
The CPU executes the instruction according to the Hack language specification:
The D and A values, if they appear in the instruction, are read from (or written to) the
respective CPU-resident registers
The M value, if there is one in the instruction’s RHS, is read from inM
If the instruction’s LHS includes M, then the ALU output is placed in outM, the value of
the CPU-resident A register is placed in addressM, and writeM is asserted.
a Hack machine language
instruction like M=D+M,
stated as a 16-bit value
Elements of Computing Systems, Nisan & Schocken, MIT Press, www.nand2tetris.org , Chapter 5: Computer Architecture slide 21
CPU
instruction
inM
16
1
15
15
16 outM
16
writeM
addressM
pc
reset
1
CPU
to data
memory
to instruction
memory
from
data memory
from
instruction
memory
CPU internal components (invisible in this chip diagram): ALU and 3 registers: A, D, PC
CPU fetch logic:
Recall that:
1. the instruction may include a jump directive (expressed as non-zero jump bits)
2. the ALU emits two control bits, indicating if the ALU output is zero or less than zero
If reset==0: the CPU uses this information (the jump bits and the ALU control bits) as follows:
If there should be a jump, the PC is set to the value of A; else, PC is set to PC+1
If reset==1: the PC is set to 0. (restarting the computer)
a Hack machine language
instruction like M=D+M,
stated as a 16-bit value
Elements of Computing Systems, Nisan & Schocken, MIT Press, www.nand2tetris.org , Chapter 5: Computer Architecture slide 22
The C-instruction revisited
jumpdestcomp
1 1 1 a c1 c2 c3 c4 c5 c6 d1 d2 d3 j1 j2 j3binary:
dest = comp; jump
Elements of Computing Systems, Nisan & Schocken, MIT Press, www.nand2tetris.org , Chapter 5: Computer Architecture slide 23
Execute logic:
Decode
Execute
Fetch logic:
If there should be a jump,
set PC to A
else set PC to PC+1
ALU
Mux
D
Mux
reset
inM
addressM
pc
outM
A/Minstruction
decode
C
C
C
C
C
D
A
PC
C
C
A
A
A
M
ALU output
writeMC
C
jumpdestcomp
1 1 1 a c1 c2 c3 c4 c5 c6 d1 d2 d3 j1 j2 j3binary:
dest = comp; jumpCPU implementation
Cycle:
Execute
Fetch
Resetting the computer:
Set reset to 1,
then set it to 0.
Chip diagram:
Includes most of the
CPU’s execution logic
The CPU’s control logic is
hinted: each circled “c”
represents one or more
control bits, taken from
the instruction
The “decode”
bar does not
represent a
chip, but
rather indicates
that the
instruction bits
are decoded
somehow.
Elements of Computing Systems, Nisan & Schocken, MIT Press, www.nand2tetris.org , Chapter 5: Computer Architecture slide 24
Lecture / construction plan
Instruction memory
Memory:
Data memory
Screen
Keyboard
CPU
Computer
Elements of Computing Systems, Nisan & Schocken, MIT Press, www.nand2tetris.org , Chapter 5: Computer Architecture slide 25
Computer-on-a-chip interface
Computer
reset
Keyboard
Screen
Elements of Computing Systems, Nisan & Schocken, MIT Press, www.nand2tetris.org , Chapter 5: Computer Architecture slide 26
Computer-on-a-chip implementation
Data
Memory
(Memory)
instruction
CPU
Instruction
Memory
(ROM32K)
inM
outM
addressM
writeM
pc
reset
CHIP Computer {
IN reset;
PARTS:
// implementation missing
}
CHIP Computer {
IN reset;
PARTS:
// implementation missing
}
Implementation:
Simple, the chip-parts do all the hard work.
Elements of Computing Systems, Nisan & Schocken, MIT Press, www.nand2tetris.org , Chapter 5: Computer Architecture slide 27
The spirit of things
We ascribe beauty to that which is
simple; which has no superfluous parts;
which exactly answers its end;
which stands related to all things;
which is the mean of many extremes.
(Ralph Waldo Emerson,
1803-1882)
Elements of Computing Systems, Nisan & Schocken, MIT Press, www.nand2tetris.org , Chapter 5: Computer Architecture slide 28
Lecture plan
Instruction memory
Memory:
Data memory
Screen
Keyboard
CPU
Computer
“Ya, right,
but what about
the software?”
Elements of Computing Systems, Nisan & Schocken, MIT Press, www.nand2tetris.org , Chapter 5: Computer Architecture slide 29
Perspective: from here to a “real” computer
Caching
More I/O units
Special-purpose processors (I/O, graphics, communications, …)
Multi-core / parallelism
Efficiency
Energy consumption considerations
And more ...
Elements of Computing Systems, Nisan & Schocken, MIT Press, www.nand2tetris.org , Chapter 5: Computer Architecture slide 30
Perspective: some issues we haven’t discussed (among many)
CISC / RISC (hardware / software trade-off)
Hardware diversity: desktop, laptop, hand-held, game machines, …
General-purpose vs. embedded computers
Silicon compilers
And more ...

More Related Content

What's hot

nand2tetris 舊版投影片 -- 第三章 循序邏輯
nand2tetris 舊版投影片 -- 第三章 循序邏輯nand2tetris 舊版投影片 -- 第三章 循序邏輯
nand2tetris 舊版投影片 -- 第三章 循序邏輯
鍾誠 陳鍾誠
 
Lecture 10 compiler i
Lecture 10 compiler iLecture 10 compiler i
Lecture 10 compiler i
鍾誠 陳鍾誠
 
Sequential logic
Sequential logicSequential logic
Sequential logic
鍾誠 陳鍾誠
 
Lecture 07 virtual machine i
Lecture 07 virtual machine iLecture 07 virtual machine i
Lecture 07 virtual machine i
鍾誠 陳鍾誠
 
nand2tetris 舊版投影片 -- 第一章 布林邏輯
nand2tetris 舊版投影片 -- 第一章 布林邏輯nand2tetris 舊版投影片 -- 第一章 布林邏輯
nand2tetris 舊版投影片 -- 第一章 布林邏輯
鍾誠 陳鍾誠
 
nand2tetris 舊版投影片 -- 第四章 機器語言
nand2tetris 舊版投影片 -- 第四章 機器語言nand2tetris 舊版投影片 -- 第四章 機器語言
nand2tetris 舊版投影片 -- 第四章 機器語言
鍾誠 陳鍾誠
 
Lecture 06 assembler
Lecture 06 assemblerLecture 06 assembler
Lecture 06 assembler
鍾誠 陳鍾誠
 
Machine language
Machine languageMachine language
Machine language
鍾誠 陳鍾誠
 
Mutual Exclusion
Mutual ExclusionMutual Exclusion
Mutual Exclusion
David Evans
 
FLASHBRAIN report
FLASHBRAIN reportFLASHBRAIN report
FLASHBRAIN reportDaniel Han
 
Chapter#4
Chapter#4Chapter#4
Computer organiztion3
Computer organiztion3Computer organiztion3
Computer organiztion3Umang Gupta
 
Advance Computer Architecture
Advance Computer ArchitectureAdvance Computer Architecture
Advance Computer Architecture
Vrushali Lanjewar
 
Computer organiztion2
Computer organiztion2Computer organiztion2
Computer organiztion2Umang Gupta
 
interfacing matlab with embedded systems
interfacing matlab with embedded systemsinterfacing matlab with embedded systems
interfacing matlab with embedded systems
Raghav Shetty
 
Itec 625 midterm examination solution
Itec 625 midterm examination solutionItec 625 midterm examination solution
Itec 625 midterm examination solution
bestwriter
 

What's hot (18)

nand2tetris 舊版投影片 -- 第三章 循序邏輯
nand2tetris 舊版投影片 -- 第三章 循序邏輯nand2tetris 舊版投影片 -- 第三章 循序邏輯
nand2tetris 舊版投影片 -- 第三章 循序邏輯
 
Lecture 10 compiler i
Lecture 10 compiler iLecture 10 compiler i
Lecture 10 compiler i
 
Sequential logic
Sequential logicSequential logic
Sequential logic
 
Lecture 07 virtual machine i
Lecture 07 virtual machine iLecture 07 virtual machine i
Lecture 07 virtual machine i
 
nand2tetris 舊版投影片 -- 第一章 布林邏輯
nand2tetris 舊版投影片 -- 第一章 布林邏輯nand2tetris 舊版投影片 -- 第一章 布林邏輯
nand2tetris 舊版投影片 -- 第一章 布林邏輯
 
nand2tetris 舊版投影片 -- 第四章 機器語言
nand2tetris 舊版投影片 -- 第四章 機器語言nand2tetris 舊版投影片 -- 第四章 機器語言
nand2tetris 舊版投影片 -- 第四章 機器語言
 
Lecture 06 assembler
Lecture 06 assemblerLecture 06 assembler
Lecture 06 assembler
 
Machine language
Machine languageMachine language
Machine language
 
Matlab workshop
Matlab workshopMatlab workshop
Matlab workshop
 
Mutual Exclusion
Mutual ExclusionMutual Exclusion
Mutual Exclusion
 
FLASHBRAIN report
FLASHBRAIN reportFLASHBRAIN report
FLASHBRAIN report
 
Chapter#4
Chapter#4Chapter#4
Chapter#4
 
Computer organiztion3
Computer organiztion3Computer organiztion3
Computer organiztion3
 
Advance Computer Architecture
Advance Computer ArchitectureAdvance Computer Architecture
Advance Computer Architecture
 
Computer organiztion2
Computer organiztion2Computer organiztion2
Computer organiztion2
 
Computer Quiz MCQ's
Computer Quiz MCQ'sComputer Quiz MCQ's
Computer Quiz MCQ's
 
interfacing matlab with embedded systems
interfacing matlab with embedded systemsinterfacing matlab with embedded systems
interfacing matlab with embedded systems
 
Itec 625 midterm examination solution
Itec 625 midterm examination solutionItec 625 midterm examination solution
Itec 625 midterm examination solution
 

Similar to nand2tetris 舊版投影片 -- 第五章 計算機結構

Motherboard
MotherboardMotherboard
Motherboard
BarojReal
 
Lecture 1
Lecture 1Lecture 1
Lecture 1
Chamila Fernando
 
Computer 20091205 (student preso)
Computer 20091205 (student preso)Computer 20091205 (student preso)
Computer 20091205 (student preso)
Roppon Picha
 
Making a Process (Virtualizing Memory)
Making a Process (Virtualizing Memory)Making a Process (Virtualizing Memory)
Making a Process (Virtualizing Memory)
David Evans
 
125252.ppt
125252.ppt125252.ppt
125252.ppt
divlee1
 
INTRODUCTION TO COMPUTER SYSTEMS ARCHITECTURE1_17 December 2023.ppt
INTRODUCTION TO COMPUTER SYSTEMS ARCHITECTURE1_17 December 2023.pptINTRODUCTION TO COMPUTER SYSTEMS ARCHITECTURE1_17 December 2023.ppt
INTRODUCTION TO COMPUTER SYSTEMS ARCHITECTURE1_17 December 2023.ppt
MozammelHaque53
 
Mac os
Mac osMac os
parts_of_a_computer.pdf
parts_of_a_computer.pdfparts_of_a_computer.pdf
parts_of_a_computer.pdf
CHETANShimpi8
 
Ch 1 introduction and 2 computer software 1
Ch 1 introduction  and 2 computer software 1Ch 1 introduction  and 2 computer software 1
Ch 1 introduction and 2 computer software 1rjsuthar56
 
Architecture presentation
Architecture presentationArchitecture presentation
Architecture presentation
Md. Touhidur Rahman
 
Computer Organization and BASIC Programming
Computer Organization and BASIC     Programming     Computer Organization and BASIC     Programming
Computer Organization and BASIC Programming
MuhammadAhmad844
 
Computer and its uses in modern life.pptx
Computer and its uses in modern life.pptxComputer and its uses in modern life.pptx
Computer and its uses in modern life.pptx
MdNasirUddin592112
 
Introduction to computer_lec_01_fall_2018
Introduction to computer_lec_01_fall_2018Introduction to computer_lec_01_fall_2018
Introduction to computer_lec_01_fall_2018
Ramadan Babers, PhD
 
Principles of computer design
Principles of computer designPrinciples of computer design
Principles of computer design
Indeevari Ramanayake
 
computer organisation and architecture_ppt.pptx
computer organisation and architecture_ppt.pptxcomputer organisation and architecture_ppt.pptx
computer organisation and architecture_ppt.pptx
vishnuvardhan749108
 
Computer Hardware-Part 1
Computer Hardware-Part 1Computer Hardware-Part 1
Computer Hardware-Part 1
Coky Fauzi Alfi
 
M1- IT Tools & Application.docx
M1- IT Tools & Application.docxM1- IT Tools & Application.docx
M1- IT Tools & Application.docx
ssuser3940ac
 
Motherboard
MotherboardMotherboard
Motherboard
BarojReal
 
Lecture 1 - introduction to computer systems architecture 2018 / 2019
Lecture 1 - introduction to computer systems architecture 2018 / 2019Lecture 1 - introduction to computer systems architecture 2018 / 2019
Lecture 1 - introduction to computer systems architecture 2018 / 2019
Mousuf Zaman C
 

Similar to nand2tetris 舊版投影片 -- 第五章 計算機結構 (20)

Motherboard
MotherboardMotherboard
Motherboard
 
Lecture 1
Lecture 1Lecture 1
Lecture 1
 
Computer 20091205 (student preso)
Computer 20091205 (student preso)Computer 20091205 (student preso)
Computer 20091205 (student preso)
 
Making a Process (Virtualizing Memory)
Making a Process (Virtualizing Memory)Making a Process (Virtualizing Memory)
Making a Process (Virtualizing Memory)
 
125252.ppt
125252.ppt125252.ppt
125252.ppt
 
INTRODUCTION TO COMPUTER SYSTEMS ARCHITECTURE1_17 December 2023.ppt
INTRODUCTION TO COMPUTER SYSTEMS ARCHITECTURE1_17 December 2023.pptINTRODUCTION TO COMPUTER SYSTEMS ARCHITECTURE1_17 December 2023.ppt
INTRODUCTION TO COMPUTER SYSTEMS ARCHITECTURE1_17 December 2023.ppt
 
Mac os
Mac osMac os
Mac os
 
parts_of_a_computer.pdf
parts_of_a_computer.pdfparts_of_a_computer.pdf
parts_of_a_computer.pdf
 
Ch 1 introduction and 2 computer software 1
Ch 1 introduction  and 2 computer software 1Ch 1 introduction  and 2 computer software 1
Ch 1 introduction and 2 computer software 1
 
Architecture presentation
Architecture presentationArchitecture presentation
Architecture presentation
 
Notes
NotesNotes
Notes
 
Computer Organization and BASIC Programming
Computer Organization and BASIC     Programming     Computer Organization and BASIC     Programming
Computer Organization and BASIC Programming
 
Computer and its uses in modern life.pptx
Computer and its uses in modern life.pptxComputer and its uses in modern life.pptx
Computer and its uses in modern life.pptx
 
Introduction to computer_lec_01_fall_2018
Introduction to computer_lec_01_fall_2018Introduction to computer_lec_01_fall_2018
Introduction to computer_lec_01_fall_2018
 
Principles of computer design
Principles of computer designPrinciples of computer design
Principles of computer design
 
computer organisation and architecture_ppt.pptx
computer organisation and architecture_ppt.pptxcomputer organisation and architecture_ppt.pptx
computer organisation and architecture_ppt.pptx
 
Computer Hardware-Part 1
Computer Hardware-Part 1Computer Hardware-Part 1
Computer Hardware-Part 1
 
M1- IT Tools & Application.docx
M1- IT Tools & Application.docxM1- IT Tools & Application.docx
M1- IT Tools & Application.docx
 
Motherboard
MotherboardMotherboard
Motherboard
 
Lecture 1 - introduction to computer systems architecture 2018 / 2019
Lecture 1 - introduction to computer systems architecture 2018 / 2019Lecture 1 - introduction to computer systems architecture 2018 / 2019
Lecture 1 - introduction to computer systems architecture 2018 / 2019
 

More from 鍾誠 陳鍾誠

用十分鐘瞭解 新竹科學園區的發展史
用十分鐘瞭解  新竹科學園區的發展史用十分鐘瞭解  新竹科學園區的發展史
用十分鐘瞭解 新竹科學園區的發展史
鍾誠 陳鍾誠
 
用十分鐘搞懂 λ-Calculus
用十分鐘搞懂 λ-Calculus用十分鐘搞懂 λ-Calculus
用十分鐘搞懂 λ-Calculus
鍾誠 陳鍾誠
 
交⼤資訊⼯程學系備審資料 ⾱詠祥
交⼤資訊⼯程學系備審資料 ⾱詠祥交⼤資訊⼯程學系備審資料 ⾱詠祥
交⼤資訊⼯程學系備審資料 ⾱詠祥
鍾誠 陳鍾誠
 
smallpt: Global Illumination in 99 lines of C++
smallpt:  Global Illumination in 99 lines of C++smallpt:  Global Illumination in 99 lines of C++
smallpt: Global Illumination in 99 lines of C++
鍾誠 陳鍾誠
 
西洋史 (你或許不知道但卻影響現代教育的那些事)
西洋史  (你或許不知道但卻影響現代教育的那些事)西洋史  (你或許不知道但卻影響現代教育的那些事)
西洋史 (你或許不知道但卻影響現代教育的那些事)
鍾誠 陳鍾誠
 
區塊鏈 (比特幣背後的關鍵技術) -- 十分鐘系列
區塊鏈  (比特幣背後的關鍵技術)   -- 十分鐘系列區塊鏈  (比特幣背後的關鍵技術)   -- 十分鐘系列
區塊鏈 (比特幣背後的關鍵技術) -- 十分鐘系列
鍾誠 陳鍾誠
 
區塊鏈 (比特幣背後的關鍵技術) -- 十分鐘系列
區塊鏈  (比特幣背後的關鍵技術)   -- 十分鐘系列區塊鏈  (比特幣背後的關鍵技術)   -- 十分鐘系列
區塊鏈 (比特幣背後的關鍵技術) -- 十分鐘系列
鍾誠 陳鍾誠
 
梯度下降法 (隱藏在深度學習背後的演算法) -- 十分鐘系列
梯度下降法  (隱藏在深度學習背後的演算法) -- 十分鐘系列梯度下降法  (隱藏在深度學習背後的演算法) -- 十分鐘系列
梯度下降法 (隱藏在深度學習背後的演算法) -- 十分鐘系列
鍾誠 陳鍾誠
 
用十分鐘理解 《微分方程》
用十分鐘理解  《微分方程》用十分鐘理解  《微分方程》
用十分鐘理解 《微分方程》
鍾誠 陳鍾誠
 
系統程式 -- 前言
系統程式 -- 前言系統程式 -- 前言
系統程式 -- 前言
鍾誠 陳鍾誠
 
系統程式 -- 附錄
系統程式 -- 附錄系統程式 -- 附錄
系統程式 -- 附錄
鍾誠 陳鍾誠
 
系統程式 -- 第 12 章 系統軟體實作
系統程式 -- 第 12 章 系統軟體實作系統程式 -- 第 12 章 系統軟體實作
系統程式 -- 第 12 章 系統軟體實作
鍾誠 陳鍾誠
 
系統程式 -- 第 11 章 嵌入式系統
系統程式 -- 第 11 章 嵌入式系統系統程式 -- 第 11 章 嵌入式系統
系統程式 -- 第 11 章 嵌入式系統
鍾誠 陳鍾誠
 
系統程式 -- 第 10 章 作業系統
系統程式 -- 第 10 章 作業系統系統程式 -- 第 10 章 作業系統
系統程式 -- 第 10 章 作業系統
鍾誠 陳鍾誠
 
系統程式 -- 第 9 章 虛擬機器
系統程式 -- 第 9 章 虛擬機器系統程式 -- 第 9 章 虛擬機器
系統程式 -- 第 9 章 虛擬機器
鍾誠 陳鍾誠
 
系統程式 -- 第 8 章 編譯器
系統程式 -- 第 8 章 編譯器系統程式 -- 第 8 章 編譯器
系統程式 -- 第 8 章 編譯器
鍾誠 陳鍾誠
 
系統程式 -- 第 7 章 高階語言
系統程式 -- 第 7 章 高階語言系統程式 -- 第 7 章 高階語言
系統程式 -- 第 7 章 高階語言
鍾誠 陳鍾誠
 
系統程式 -- 第 6 章 巨集處理器
系統程式 -- 第 6 章 巨集處理器系統程式 -- 第 6 章 巨集處理器
系統程式 -- 第 6 章 巨集處理器
鍾誠 陳鍾誠
 
系統程式 -- 第 5 章 連結與載入
系統程式 -- 第 5 章 連結與載入系統程式 -- 第 5 章 連結與載入
系統程式 -- 第 5 章 連結與載入
鍾誠 陳鍾誠
 
系統程式 -- 第 4 章 組譯器
系統程式 -- 第 4 章 組譯器系統程式 -- 第 4 章 組譯器
系統程式 -- 第 4 章 組譯器
鍾誠 陳鍾誠
 

More from 鍾誠 陳鍾誠 (20)

用十分鐘瞭解 新竹科學園區的發展史
用十分鐘瞭解  新竹科學園區的發展史用十分鐘瞭解  新竹科學園區的發展史
用十分鐘瞭解 新竹科學園區的發展史
 
用十分鐘搞懂 λ-Calculus
用十分鐘搞懂 λ-Calculus用十分鐘搞懂 λ-Calculus
用十分鐘搞懂 λ-Calculus
 
交⼤資訊⼯程學系備審資料 ⾱詠祥
交⼤資訊⼯程學系備審資料 ⾱詠祥交⼤資訊⼯程學系備審資料 ⾱詠祥
交⼤資訊⼯程學系備審資料 ⾱詠祥
 
smallpt: Global Illumination in 99 lines of C++
smallpt:  Global Illumination in 99 lines of C++smallpt:  Global Illumination in 99 lines of C++
smallpt: Global Illumination in 99 lines of C++
 
西洋史 (你或許不知道但卻影響現代教育的那些事)
西洋史  (你或許不知道但卻影響現代教育的那些事)西洋史  (你或許不知道但卻影響現代教育的那些事)
西洋史 (你或許不知道但卻影響現代教育的那些事)
 
區塊鏈 (比特幣背後的關鍵技術) -- 十分鐘系列
區塊鏈  (比特幣背後的關鍵技術)   -- 十分鐘系列區塊鏈  (比特幣背後的關鍵技術)   -- 十分鐘系列
區塊鏈 (比特幣背後的關鍵技術) -- 十分鐘系列
 
區塊鏈 (比特幣背後的關鍵技術) -- 十分鐘系列
區塊鏈  (比特幣背後的關鍵技術)   -- 十分鐘系列區塊鏈  (比特幣背後的關鍵技術)   -- 十分鐘系列
區塊鏈 (比特幣背後的關鍵技術) -- 十分鐘系列
 
梯度下降法 (隱藏在深度學習背後的演算法) -- 十分鐘系列
梯度下降法  (隱藏在深度學習背後的演算法) -- 十分鐘系列梯度下降法  (隱藏在深度學習背後的演算法) -- 十分鐘系列
梯度下降法 (隱藏在深度學習背後的演算法) -- 十分鐘系列
 
用十分鐘理解 《微分方程》
用十分鐘理解  《微分方程》用十分鐘理解  《微分方程》
用十分鐘理解 《微分方程》
 
系統程式 -- 前言
系統程式 -- 前言系統程式 -- 前言
系統程式 -- 前言
 
系統程式 -- 附錄
系統程式 -- 附錄系統程式 -- 附錄
系統程式 -- 附錄
 
系統程式 -- 第 12 章 系統軟體實作
系統程式 -- 第 12 章 系統軟體實作系統程式 -- 第 12 章 系統軟體實作
系統程式 -- 第 12 章 系統軟體實作
 
系統程式 -- 第 11 章 嵌入式系統
系統程式 -- 第 11 章 嵌入式系統系統程式 -- 第 11 章 嵌入式系統
系統程式 -- 第 11 章 嵌入式系統
 
系統程式 -- 第 10 章 作業系統
系統程式 -- 第 10 章 作業系統系統程式 -- 第 10 章 作業系統
系統程式 -- 第 10 章 作業系統
 
系統程式 -- 第 9 章 虛擬機器
系統程式 -- 第 9 章 虛擬機器系統程式 -- 第 9 章 虛擬機器
系統程式 -- 第 9 章 虛擬機器
 
系統程式 -- 第 8 章 編譯器
系統程式 -- 第 8 章 編譯器系統程式 -- 第 8 章 編譯器
系統程式 -- 第 8 章 編譯器
 
系統程式 -- 第 7 章 高階語言
系統程式 -- 第 7 章 高階語言系統程式 -- 第 7 章 高階語言
系統程式 -- 第 7 章 高階語言
 
系統程式 -- 第 6 章 巨集處理器
系統程式 -- 第 6 章 巨集處理器系統程式 -- 第 6 章 巨集處理器
系統程式 -- 第 6 章 巨集處理器
 
系統程式 -- 第 5 章 連結與載入
系統程式 -- 第 5 章 連結與載入系統程式 -- 第 5 章 連結與載入
系統程式 -- 第 5 章 連結與載入
 
系統程式 -- 第 4 章 組譯器
系統程式 -- 第 4 章 組譯器系統程式 -- 第 4 章 組譯器
系統程式 -- 第 4 章 組譯器
 

Recently uploaded

Digital Artifact 2 - Investigating Pavilion Designs
Digital Artifact 2 - Investigating Pavilion DesignsDigital Artifact 2 - Investigating Pavilion Designs
Digital Artifact 2 - Investigating Pavilion Designs
chanes7
 
The Accursed House by Émile Gaboriau.pptx
The Accursed House by Émile Gaboriau.pptxThe Accursed House by Émile Gaboriau.pptx
The Accursed House by Émile Gaboriau.pptx
DhatriParmar
 
A Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in EducationA Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in Education
Peter Windle
 
The Diamonds of 2023-2024 in the IGRA collection
The Diamonds of 2023-2024 in the IGRA collectionThe Diamonds of 2023-2024 in the IGRA collection
The Diamonds of 2023-2024 in the IGRA collection
Israel Genealogy Research Association
 
STRAND 3 HYGIENIC PRACTICES.pptx GRADE 7 CBC
STRAND 3 HYGIENIC PRACTICES.pptx GRADE 7 CBCSTRAND 3 HYGIENIC PRACTICES.pptx GRADE 7 CBC
STRAND 3 HYGIENIC PRACTICES.pptx GRADE 7 CBC
kimdan468
 
Biological Screening of Herbal Drugs in detailed.
Biological Screening of Herbal Drugs in detailed.Biological Screening of Herbal Drugs in detailed.
Biological Screening of Herbal Drugs in detailed.
Ashokrao Mane college of Pharmacy Peth-Vadgaon
 
The Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official PublicationThe Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official Publication
Delapenabediema
 
2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...
Sandy Millin
 
Digital Artifact 1 - 10VCD Environments Unit
Digital Artifact 1 - 10VCD Environments UnitDigital Artifact 1 - 10VCD Environments Unit
Digital Artifact 1 - 10VCD Environments Unit
chanes7
 
Supporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptxSupporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptx
Jisc
 
Acetabularia Information For Class 9 .docx
Acetabularia Information For Class 9  .docxAcetabularia Information For Class 9  .docx
Acetabularia Information For Class 9 .docx
vaibhavrinwa19
 
S1-Introduction-Biopesticides in ICM.pptx
S1-Introduction-Biopesticides in ICM.pptxS1-Introduction-Biopesticides in ICM.pptx
S1-Introduction-Biopesticides in ICM.pptx
tarandeep35
 
Natural birth techniques - Mrs.Akanksha Trivedi Rama University
Natural birth techniques - Mrs.Akanksha Trivedi Rama UniversityNatural birth techniques - Mrs.Akanksha Trivedi Rama University
Natural birth techniques - Mrs.Akanksha Trivedi Rama University
Akanksha trivedi rama nursing college kanpur.
 
CACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdfCACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdf
camakaiclarkmusic
 
Lapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdfLapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdf
Jean Carlos Nunes Paixão
 
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
Levi Shapiro
 
1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx
JosvitaDsouza2
 
MASS MEDIA STUDIES-835-CLASS XI Resource Material.pdf
MASS MEDIA STUDIES-835-CLASS XI Resource Material.pdfMASS MEDIA STUDIES-835-CLASS XI Resource Material.pdf
MASS MEDIA STUDIES-835-CLASS XI Resource Material.pdf
goswamiyash170123
 
Advantages and Disadvantages of CMS from an SEO Perspective
Advantages and Disadvantages of CMS from an SEO PerspectiveAdvantages and Disadvantages of CMS from an SEO Perspective
Advantages and Disadvantages of CMS from an SEO Perspective
Krisztián Száraz
 
Unit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdfUnit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdf
Thiyagu K
 

Recently uploaded (20)

Digital Artifact 2 - Investigating Pavilion Designs
Digital Artifact 2 - Investigating Pavilion DesignsDigital Artifact 2 - Investigating Pavilion Designs
Digital Artifact 2 - Investigating Pavilion Designs
 
The Accursed House by Émile Gaboriau.pptx
The Accursed House by Émile Gaboriau.pptxThe Accursed House by Émile Gaboriau.pptx
The Accursed House by Émile Gaboriau.pptx
 
A Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in EducationA Strategic Approach: GenAI in Education
A Strategic Approach: GenAI in Education
 
The Diamonds of 2023-2024 in the IGRA collection
The Diamonds of 2023-2024 in the IGRA collectionThe Diamonds of 2023-2024 in the IGRA collection
The Diamonds of 2023-2024 in the IGRA collection
 
STRAND 3 HYGIENIC PRACTICES.pptx GRADE 7 CBC
STRAND 3 HYGIENIC PRACTICES.pptx GRADE 7 CBCSTRAND 3 HYGIENIC PRACTICES.pptx GRADE 7 CBC
STRAND 3 HYGIENIC PRACTICES.pptx GRADE 7 CBC
 
Biological Screening of Herbal Drugs in detailed.
Biological Screening of Herbal Drugs in detailed.Biological Screening of Herbal Drugs in detailed.
Biological Screening of Herbal Drugs in detailed.
 
The Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official PublicationThe Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official Publication
 
2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...
 
Digital Artifact 1 - 10VCD Environments Unit
Digital Artifact 1 - 10VCD Environments UnitDigital Artifact 1 - 10VCD Environments Unit
Digital Artifact 1 - 10VCD Environments Unit
 
Supporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptxSupporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptx
 
Acetabularia Information For Class 9 .docx
Acetabularia Information For Class 9  .docxAcetabularia Information For Class 9  .docx
Acetabularia Information For Class 9 .docx
 
S1-Introduction-Biopesticides in ICM.pptx
S1-Introduction-Biopesticides in ICM.pptxS1-Introduction-Biopesticides in ICM.pptx
S1-Introduction-Biopesticides in ICM.pptx
 
Natural birth techniques - Mrs.Akanksha Trivedi Rama University
Natural birth techniques - Mrs.Akanksha Trivedi Rama UniversityNatural birth techniques - Mrs.Akanksha Trivedi Rama University
Natural birth techniques - Mrs.Akanksha Trivedi Rama University
 
CACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdfCACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdf
 
Lapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdfLapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdf
 
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
 
1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx
 
MASS MEDIA STUDIES-835-CLASS XI Resource Material.pdf
MASS MEDIA STUDIES-835-CLASS XI Resource Material.pdfMASS MEDIA STUDIES-835-CLASS XI Resource Material.pdf
MASS MEDIA STUDIES-835-CLASS XI Resource Material.pdf
 
Advantages and Disadvantages of CMS from an SEO Perspective
Advantages and Disadvantages of CMS from an SEO PerspectiveAdvantages and Disadvantages of CMS from an SEO Perspective
Advantages and Disadvantages of CMS from an SEO Perspective
 
Unit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdfUnit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdf
 

nand2tetris 舊版投影片 -- 第五章 計算機結構

  • 1. Elements of Computing Systems, Nisan & Schocken, MIT Press, www.nand2tetris.org , Chapter 5: Computer Architecture slide 1 www.nand2tetris.org Building a Modern Computer From First Principles Computer Architecture
  • 2. Elements of Computing Systems, Nisan & Schocken, MIT Press, www.nand2tetris.org , Chapter 5: Computer Architecture slide 2 Babbage’s Analytical Engine (1835) “We may say most aptly that the Analytical Engine weaves algebraic patterns just as the Jacquard- loom weaves flowers and leaves” (Ada Lovelace) Charles Babbage (1791-1871)
  • 3. Elements of Computing Systems, Nisan & Schocken, MIT Press, www.nand2tetris.org , Chapter 5: Computer Architecture slide 3 Some early computers and computer scientists Blaise Pascal 1623-1662 Gottfried Leibniz 1646-1716
  • 4. Elements of Computing Systems, Nisan & Schocken, MIT Press, www.nand2tetris.org , Chapter 5: Computer Architecture slide 4 Von Neumann machine (circa 1940) Arithmetic Logic Unit (ALU) CPU Registers Control Memory (data + instructions) Input device Output device Andy Grove (and others) ... made it small and fast.John Von Neumann (and others) ... made it possible Stored program concept!
  • 5. Elements of Computing Systems, Nisan & Schocken, MIT Press, www.nand2tetris.org , Chapter 5: Computer Architecture slide 5 Arithmetic Logic Unit (ALU) CPU Registers Control Memory (data + instructions) Input device Output device Processing logic: fetch-execute cycle Executing the current instruction involves one or more of the following micro-tasks: Have the ALU compute some function out = f (register values) Write the ALU output to selected registers As a side-effect of this computation, figure out which instruction to fetch and execute next.
  • 6. Elements of Computing Systems, Nisan & Schocken, MIT Press, www.nand2tetris.org , Chapter 5: Computer Architecture slide 6 The Hack chip-set and hardware platform Elementary logic gates Nand Not And Or Xor Mux Dmux Not16 And16 Or16 Mux16 Or8Way Mux4Way16 Mux8Way16 DMux4Way DMux8Way Combinational chips HalfAdder FullAdder Add16 Inc16 ALU Sequential chips DFF Bit Register RAM8 RAM64 RAM512 RAM4K RAM16K PC Computer Architecture Memory CPU Computer done done done this lecture
  • 7. Elements of Computing Systems, Nisan & Schocken, MIT Press, www.nand2tetris.org , Chapter 5: Computer Architecture slide 7 The Hack computer Main parts of the Hack computer: Instruction memory (ROM) Memory (RAM): • Data memory • Screen (memory map) • Keyboard (memory map) CPU Computer (the logic that holds everything together). A 16-bit Von Neumann platform The instruction memory and the data memory are physically separate Screen: 512 rows by 256 columns, black and white Keyboard: standard Designed to execute programs written in the Hack machine language Can be easily built from the chip-set that we built so far in the course
  • 8. Elements of Computing Systems, Nisan & Schocken, MIT Press, www.nand2tetris.org , Chapter 5: Computer Architecture slide 8 Lecture / construction plan Instruction memory Memory: Data memory Screen Keyboard CPU Computer
  • 9. Elements of Computing Systems, Nisan & Schocken, MIT Press, www.nand2tetris.org , Chapter 5: Computer Architecture slide 9 Instruction memory out 15 16 address ROM32K Function: The ROM is pre-loaded with a program written in the Hack machine language The ROM chip always emits a 16-bit number: out = ROM32K[address] This number is interpreted as the current instruction.
  • 10. Elements of Computing Systems, Nisan & Schocken, MIT Press, www.nand2tetris.org , Chapter 5: Computer Architecture slide 10 Data memory Low-level (hardware) read/write logic: To read RAM[k]: set address to k, probe out To write RAM[k]=x: set address to k, set in to x, set load to 1, run the clock High-level (OS) read/write logic: To read RAM[k]: use the OS command out = peek(k) To write RAM[k]=x: use the OS command poke(k,x) peek and poke are OS commands whose implementation should effect the same behavior as the low-level commands More about peek and poke this later in the course, when we’ll write the OS. load
  • 11. Elements of Computing Systems, Nisan & Schocken, MIT Press, www.nand2tetris.org , Chapter 5: Computer Architecture slide 11 Lecture / construction plan Instruction memory Memory: Data memory Screen Keyboard CPU Computer
  • 12. Elements of Computing Systems, Nisan & Schocken, MIT Press, www.nand2tetris.org , Chapter 5: Computer Architecture slide 12 Screen The Screen chip has a basic RAM chip functionality: read logic: out = Screen[address] write logic: if load then Screen[address] = in Side effect: Continuously refreshes a 256 by 512 black-and-white screen device load out in 16 15 16address Screen Physical Screen The bit contents of the Screen chip is called the “screen memory map” The simulated 256 by 512 B&W screen When loaded into the hardware simulator, the built-in Screen.hdl chip opens up a screen window; the simulator then refreshes this window from the screen memory map several times each second. Simulated screen:
  • 13. Elements of Computing Systems, Nisan & Schocken, MIT Press, www.nand2tetris.org , Chapter 5: Computer Architecture slide 13 Screen memory map How to set the (row,col) pixel of the screen to black or to white: Low-level (machine language): Set the col%16 bit of the word found at Screen[row*32+col/16] to 1 or to 0 (col/16 is integer division) High-level: Use the OS command drawPixel(row,col) (effects the same operation, discussed later in the course, when we’ll write the OS). 0 1 255 . . . . . .0 1 2 3 4 5 6 7 511 0011000000000000 0000000000000000 0000000000000000 0 1 31 . . . row 0 0001110000000000 0000000000000000 0000000000000000 32 33 63 . . . row 1 0100100000000000 0000000000000000 0000000000000000 8129 8130 8160 . . . row 255 . . . . . . . . . . . . refresh several times each second Screen In the Hack platform, the screen is implemented as an 8K 16-bit RAM chip.
  • 14. Elements of Computing Systems, Nisan & Schocken, MIT Press, www.nand2tetris.org , Chapter 5: Computer Architecture slide 14 Keyboard Keyboard chip: a single 16-bit register Input: scan-code (16-bit value) of the currently pressed key, or 0 if no key is pressed Output: same How to read the keyboard: Low-level (hardware): probe the contents of the Keyboard chip High-level: use the OS command keyPressed() (effects the same operation, discussed later in the course, when we’ll write the OS). Special keys: The keyboard is implemented as a built-in Keyboard.hdl chip. When this java chip is loaded into the simulator, it connects to the regular keyboard and pipes the scan-code of the currently pressed key to the keyboard memory map. The simulated keyboard enabler button Simulated keyboard:
  • 15. Elements of Computing Systems, Nisan & Schocken, MIT Press, www.nand2tetris.org , Chapter 5: Computer Architecture slide 15 Lecture / construction plan Instruction memory Memory: Data memory Screen Keyboard CPU Computer
  • 16. Elements of Computing Systems, Nisan & Schocken, MIT Press, www.nand2tetris.org , Chapter 5: Computer Architecture slide 16 Memory: conceptual / programmer’s view Using the memory: To record or recall values (e.g. variables, objects, arrays), use the first 16K words of the memory To write to the screen (or read the screen), use the next 8K words of the memory To read which key is currently pressed, use the next word of the memory. Data Screen memory map Keyboard map Memory Keyboard Screen
  • 17. Elements of Computing Systems, Nisan & Schocken, MIT Press, www.nand2tetris.org , Chapter 5: Computer Architecture slide 17 Memory: physical implementation Access logic: Access to any address from 0 to 16,383 results in accessing the RAM16K chip-part Access to any address from 16,384 to 24,575 results in accessing the Screen chip-part Access to address 24,576 results in accessing the keyboard chip-part Access to any other address is invalid. load out in 16 15 16 RAM16K (16K mem. chip) address 0 16383 Screen (8K mem. chip) 16384 24575 24576 Keyboard (one register) Memory Keyboard Screen The Memory chip is essentially a package that integrates the three chip- parts RAM16K, Screen, and Keyboard into a single, contiguous address space. This packaging effects the programmer’s view of the memory, as well as the necessary I/O side-effects.
  • 18. Elements of Computing Systems, Nisan & Schocken, MIT Press, www.nand2tetris.org , Chapter 5: Computer Architecture slide 18 Lecture / construction plan Instruction memory Memory: Data memory Screen Keyboard CPU Computer
  • 19. Elements of Computing Systems, Nisan & Schocken, MIT Press, www.nand2tetris.org , Chapter 5: Computer Architecture slide 19 A pledge to patience ... “At times … the fragments that I lay out for your inspection may seem not to fit well together, as if they were stray pieces from separate puzzles. In such cases, I would counsel patience. There are moments when a large enough fragment can become a low wall, a second fragment another wall to be raised at a right angle to the first. A few struts and beams later, and we may made ourselves a rough foundation … But it can consume the better part of a chapter to build such a foundation; and as we do so the fragment that we are examining may seem unconnected to the larger whole. Only when we step back can we see that we have been assembling something that can stand in the wind.” From: Sailing the Wind Dark Sea (Thomas Cahill)
  • 20. Elements of Computing Systems, Nisan & Schocken, MIT Press, www.nand2tetris.org , Chapter 5: Computer Architecture slide 20 CPU instruction inM 16 1 15 15 16 outM 16 writeM addressM pc reset 1 CPU to data memory to instruction memory from data memory from instruction memory CPU internal components (invisible in this chip diagram): ALU and 3 registers: A, D, PC CPU execute logic: The CPU executes the instruction according to the Hack language specification: The D and A values, if they appear in the instruction, are read from (or written to) the respective CPU-resident registers The M value, if there is one in the instruction’s RHS, is read from inM If the instruction’s LHS includes M, then the ALU output is placed in outM, the value of the CPU-resident A register is placed in addressM, and writeM is asserted. a Hack machine language instruction like M=D+M, stated as a 16-bit value
  • 21. Elements of Computing Systems, Nisan & Schocken, MIT Press, www.nand2tetris.org , Chapter 5: Computer Architecture slide 21 CPU instruction inM 16 1 15 15 16 outM 16 writeM addressM pc reset 1 CPU to data memory to instruction memory from data memory from instruction memory CPU internal components (invisible in this chip diagram): ALU and 3 registers: A, D, PC CPU fetch logic: Recall that: 1. the instruction may include a jump directive (expressed as non-zero jump bits) 2. the ALU emits two control bits, indicating if the ALU output is zero or less than zero If reset==0: the CPU uses this information (the jump bits and the ALU control bits) as follows: If there should be a jump, the PC is set to the value of A; else, PC is set to PC+1 If reset==1: the PC is set to 0. (restarting the computer) a Hack machine language instruction like M=D+M, stated as a 16-bit value
  • 22. Elements of Computing Systems, Nisan & Schocken, MIT Press, www.nand2tetris.org , Chapter 5: Computer Architecture slide 22 The C-instruction revisited jumpdestcomp 1 1 1 a c1 c2 c3 c4 c5 c6 d1 d2 d3 j1 j2 j3binary: dest = comp; jump
  • 23. Elements of Computing Systems, Nisan & Schocken, MIT Press, www.nand2tetris.org , Chapter 5: Computer Architecture slide 23 Execute logic: Decode Execute Fetch logic: If there should be a jump, set PC to A else set PC to PC+1 ALU Mux D Mux reset inM addressM pc outM A/Minstruction decode C C C C C D A PC C C A A A M ALU output writeMC C jumpdestcomp 1 1 1 a c1 c2 c3 c4 c5 c6 d1 d2 d3 j1 j2 j3binary: dest = comp; jumpCPU implementation Cycle: Execute Fetch Resetting the computer: Set reset to 1, then set it to 0. Chip diagram: Includes most of the CPU’s execution logic The CPU’s control logic is hinted: each circled “c” represents one or more control bits, taken from the instruction The “decode” bar does not represent a chip, but rather indicates that the instruction bits are decoded somehow.
  • 24. Elements of Computing Systems, Nisan & Schocken, MIT Press, www.nand2tetris.org , Chapter 5: Computer Architecture slide 24 Lecture / construction plan Instruction memory Memory: Data memory Screen Keyboard CPU Computer
  • 25. Elements of Computing Systems, Nisan & Schocken, MIT Press, www.nand2tetris.org , Chapter 5: Computer Architecture slide 25 Computer-on-a-chip interface Computer reset Keyboard Screen
  • 26. Elements of Computing Systems, Nisan & Schocken, MIT Press, www.nand2tetris.org , Chapter 5: Computer Architecture slide 26 Computer-on-a-chip implementation Data Memory (Memory) instruction CPU Instruction Memory (ROM32K) inM outM addressM writeM pc reset CHIP Computer { IN reset; PARTS: // implementation missing } CHIP Computer { IN reset; PARTS: // implementation missing } Implementation: Simple, the chip-parts do all the hard work.
  • 27. Elements of Computing Systems, Nisan & Schocken, MIT Press, www.nand2tetris.org , Chapter 5: Computer Architecture slide 27 The spirit of things We ascribe beauty to that which is simple; which has no superfluous parts; which exactly answers its end; which stands related to all things; which is the mean of many extremes. (Ralph Waldo Emerson, 1803-1882)
  • 28. Elements of Computing Systems, Nisan & Schocken, MIT Press, www.nand2tetris.org , Chapter 5: Computer Architecture slide 28 Lecture plan Instruction memory Memory: Data memory Screen Keyboard CPU Computer “Ya, right, but what about the software?”
  • 29. Elements of Computing Systems, Nisan & Schocken, MIT Press, www.nand2tetris.org , Chapter 5: Computer Architecture slide 29 Perspective: from here to a “real” computer Caching More I/O units Special-purpose processors (I/O, graphics, communications, …) Multi-core / parallelism Efficiency Energy consumption considerations And more ...
  • 30. Elements of Computing Systems, Nisan & Schocken, MIT Press, www.nand2tetris.org , Chapter 5: Computer Architecture slide 30 Perspective: some issues we haven’t discussed (among many) CISC / RISC (hardware / software trade-off) Hardware diversity: desktop, laptop, hand-held, game machines, … General-purpose vs. embedded computers Silicon compilers And more ...