introduction to computer yung-yu chuang -...
TRANSCRIPT
![Page 1: Introduction to Computer Yung-Yu Chuang - 國立臺灣大學cyy/courses/introCS/13fall/lectures/... · Introduction to Computer Yung-Yu Chuang ... id / password • Mailing list](https://reader034.vdocuments.mx/reader034/viewer/2022052122/5ae5d06f7f8b9a29048cbd33/html5/thumbnails/1.jpg)
Course overview
Introduction to ComputerpYung-Yu Chuang
with slides by Nisan & Schocken (www.nand2tetris.org)
![Page 2: Introduction to Computer Yung-Yu Chuang - 國立臺灣大學cyy/courses/introCS/13fall/lectures/... · Introduction to Computer Yung-Yu Chuang ... id / password • Mailing list](https://reader034.vdocuments.mx/reader034/viewer/2022052122/5ae5d06f7f8b9a29048cbd33/html5/thumbnails/2.jpg)
Logistics
• Meeting time: 2:20pm-5:20pm, Tuesday Classroom: CSIE Room 104• Classroom: CSIE Room 104
• Instructor: 莊永裕 Yung-Yu Chuang T hi i t t TBD• Teaching assistant: TBD
• Webpage: http://www.csie.ntu.edu.tw/~cyy/introcs
id / password p• Mailing list: [email protected]
Please subscribe via Please subscribe via https://cmlmail.csie.ntu.edu.tw/mailman/listinfo/introcs/
![Page 3: Introduction to Computer Yung-Yu Chuang - 國立臺灣大學cyy/courses/introCS/13fall/lectures/... · Introduction to Computer Yung-Yu Chuang ... id / password • Mailing list](https://reader034.vdocuments.mx/reader034/viewer/2022052122/5ae5d06f7f8b9a29048cbd33/html5/thumbnails/3.jpg)
Textbook
The Elements of Computing Systems Noam Nisan Systems, Noam Nisan, Shimon Schocken, MIT Press
![Page 4: Introduction to Computer Yung-Yu Chuang - 國立臺灣大學cyy/courses/introCS/13fall/lectures/... · Introduction to Computer Yung-Yu Chuang ... id / password • Mailing list](https://reader034.vdocuments.mx/reader034/viewer/2022052122/5ae5d06f7f8b9a29048cbd33/html5/thumbnails/4.jpg)
References (TOY)
Princeton’s Introduction to CS, htt // i t d /i thttp://www.cs.princeton.edu/introcs/50machine/http://www.cs.princeton.edu/introcs/60circuits/
![Page 5: Introduction to Computer Yung-Yu Chuang - 國立臺灣大學cyy/courses/introCS/13fall/lectures/... · Introduction to Computer Yung-Yu Chuang ... id / password • Mailing list](https://reader034.vdocuments.mx/reader034/viewer/2022052122/5ae5d06f7f8b9a29048cbd33/html5/thumbnails/5.jpg)
References
CODE: The Hidden Language of C t H d d S ft Computer Hardware and Software, Charles Petzold, Microsoft Press.
Digital Design and Computer Digital Design and Computer Architecture, 2nd Edition, David Harris and Sarah Harris Morgan Harris and Sarah Harris, Morgan Kaufmann.
![Page 6: Introduction to Computer Yung-Yu Chuang - 國立臺灣大學cyy/courses/introCS/13fall/lectures/... · Introduction to Computer Yung-Yu Chuang ... id / password • Mailing list](https://reader034.vdocuments.mx/reader034/viewer/2022052122/5ae5d06f7f8b9a29048cbd33/html5/thumbnails/6.jpg)
Grading (subject to change)
• Assignments (n projects, 60%) from the accompanying websiteaccompanying website
• Class participation (4%) • Midterm exam (16%)• Final project (20%)p j ( )
![Page 7: Introduction to Computer Yung-Yu Chuang - 國立臺灣大學cyy/courses/introCS/13fall/lectures/... · Introduction to Computer Yung-Yu Chuang ... id / password • Mailing list](https://reader034.vdocuments.mx/reader034/viewer/2022052122/5ae5d06f7f8b9a29048cbd33/html5/thumbnails/7.jpg)
Early computers
![Page 8: Introduction to Computer Yung-Yu Chuang - 國立臺灣大學cyy/courses/introCS/13fall/lectures/... · Introduction to Computer Yung-Yu Chuang ... id / password • Mailing list](https://reader034.vdocuments.mx/reader034/viewer/2022052122/5ae5d06f7f8b9a29048cbd33/html5/thumbnails/8.jpg)
Early programming tools
![Page 9: Introduction to Computer Yung-Yu Chuang - 國立臺灣大學cyy/courses/introCS/13fall/lectures/... · Introduction to Computer Yung-Yu Chuang ... id / password • Mailing list](https://reader034.vdocuments.mx/reader034/viewer/2022052122/5ae5d06f7f8b9a29048cbd33/html5/thumbnails/9.jpg)
First popular PCs
![Page 10: Introduction to Computer Yung-Yu Chuang - 國立臺灣大學cyy/courses/introCS/13fall/lectures/... · Introduction to Computer Yung-Yu Chuang ... id / password • Mailing list](https://reader034.vdocuments.mx/reader034/viewer/2022052122/5ae5d06f7f8b9a29048cbd33/html5/thumbnails/10.jpg)
Early PCs
• Intel 8086 processorprocessor
• 768KB memory• 20MB disk• Dot-Matrix
printer (9-pin)
![Page 11: Introduction to Computer Yung-Yu Chuang - 國立臺灣大學cyy/courses/introCS/13fall/lectures/... · Introduction to Computer Yung-Yu Chuang ... id / password • Mailing list](https://reader034.vdocuments.mx/reader034/viewer/2022052122/5ae5d06f7f8b9a29048cbd33/html5/thumbnails/11.jpg)
GUI/IDE
![Page 12: Introduction to Computer Yung-Yu Chuang - 國立臺灣大學cyy/courses/introCS/13fall/lectures/... · Introduction to Computer Yung-Yu Chuang ... id / password • Mailing list](https://reader034.vdocuments.mx/reader034/viewer/2022052122/5ae5d06f7f8b9a29048cbd33/html5/thumbnails/12.jpg)
More advanced architectures
• PipelineSIMD• SIMD
• Multi-core• Cache
![Page 13: Introduction to Computer Yung-Yu Chuang - 國立臺灣大學cyy/courses/introCS/13fall/lectures/... · Introduction to Computer Yung-Yu Chuang ... id / password • Mailing list](https://reader034.vdocuments.mx/reader034/viewer/2022052122/5ae5d06f7f8b9a29048cbd33/html5/thumbnails/13.jpg)
More advanced software
![Page 14: Introduction to Computer Yung-Yu Chuang - 國立臺灣大學cyy/courses/introCS/13fall/lectures/... · Introduction to Computer Yung-Yu Chuang ... id / password • Mailing list](https://reader034.vdocuments.mx/reader034/viewer/2022052122/5ae5d06f7f8b9a29048cbd33/html5/thumbnails/14.jpg)
More “computers” around us
![Page 15: Introduction to Computer Yung-Yu Chuang - 國立臺灣大學cyy/courses/introCS/13fall/lectures/... · Introduction to Computer Yung-Yu Chuang ... id / password • Mailing list](https://reader034.vdocuments.mx/reader034/viewer/2022052122/5ae5d06f7f8b9a29048cbd33/html5/thumbnails/15.jpg)
My computers
Desktop(Intel Pentium D
3GHz Nvidia 7900)
VAIO Z46TD(I l C 2 D P9700 2 8GH )
3GHz, Nvidia 7900)
(Intel Core 2 Duo P9700 2.8GHz)
iPhone 5(A6,
iPad 2 ARM Cortex-A15?)iPad 2(dual-core A5 1GHz)
![Page 16: Introduction to Computer Yung-Yu Chuang - 國立臺灣大學cyy/courses/introCS/13fall/lectures/... · Introduction to Computer Yung-Yu Chuang ... id / password • Mailing list](https://reader034.vdocuments.mx/reader034/viewer/2022052122/5ae5d06f7f8b9a29048cbd33/html5/thumbnails/16.jpg)
Goal of the course
![Page 17: Introduction to Computer Yung-Yu Chuang - 國立臺灣大學cyy/courses/introCS/13fall/lectures/... · Introduction to Computer Yung-Yu Chuang ... id / password • Mailing list](https://reader034.vdocuments.mx/reader034/viewer/2022052122/5ae5d06f7f8b9a29048cbd33/html5/thumbnails/17.jpg)
The course at a glance
Objectives:U d t d h h d d ft t • Understand how hardware and software systems are built and how they work together
• Learn how to break complex problems into simpler ones• Learn how to break complex problems into simpler ones• Learn how large scale development projects are
planned and executed planned and executed • Have fun
Methodology:B ild l t l d ki • Build a complete, general-purpose and working computer systemPlay and experiment with this computer at any level of • Play and experiment with this computer, at any level of interest
![Page 18: Introduction to Computer Yung-Yu Chuang - 國立臺灣大學cyy/courses/introCS/13fall/lectures/... · Introduction to Computer Yung-Yu Chuang ... id / password • Mailing list](https://reader034.vdocuments.mx/reader034/viewer/2022052122/5ae5d06f7f8b9a29048cbd33/html5/thumbnails/18.jpg)
TOY machine
![Page 19: Introduction to Computer Yung-Yu Chuang - 國立臺灣大學cyy/courses/introCS/13fall/lectures/... · Introduction to Computer Yung-Yu Chuang ... id / password • Mailing list](https://reader034.vdocuments.mx/reader034/viewer/2022052122/5ae5d06f7f8b9a29048cbd33/html5/thumbnails/19.jpg)
TOY machine
• Starting from a simple construct
![Page 20: Introduction to Computer Yung-Yu Chuang - 國立臺灣大學cyy/courses/introCS/13fall/lectures/... · Introduction to Computer Yung-Yu Chuang ... id / password • Mailing list](https://reader034.vdocuments.mx/reader034/viewer/2022052122/5ae5d06f7f8b9a29048cbd33/html5/thumbnails/20.jpg)
TOY machine
• Build several components and connect them togethertogether
![Page 21: Introduction to Computer Yung-Yu Chuang - 國立臺灣大學cyy/courses/introCS/13fall/lectures/... · Introduction to Computer Yung-Yu Chuang ... id / password • Mailing list](https://reader034.vdocuments.mx/reader034/viewer/2022052122/5ae5d06f7f8b9a29048cbd33/html5/thumbnails/21.jpg)
TOY machine
• Almost as good as any computers
![Page 22: Introduction to Computer Yung-Yu Chuang - 國立臺灣大學cyy/courses/introCS/13fall/lectures/... · Introduction to Computer Yung-Yu Chuang ... id / password • Mailing list](https://reader034.vdocuments.mx/reader034/viewer/2022052122/5ae5d06f7f8b9a29048cbd33/html5/thumbnails/22.jpg)
TOY machine
A DUP 32int A[32]; 10: C020
lda R1, 1lda RA, A
20: 710121: 7A00
lda RC, 0
d ld RD 0 FF
i=0; Do {RD tdi
22: 7C00
23 8DFFread ld RD, 0xFFbz RD, exitadd R2 RA RC
RD=stdin;if (RD==0) break;
23: 8DFF24: CD2925: 12ACadd R2, RA, RC
sti RD, R2add RC, RC, R1
A[i]=RD;i=i+1;
25: 12AC26: BD0227: 1CC1
bz R0, read
it jl RF i t
} while (1);
i t ()
28: C023
29 FF2Bexit jl RF, printrhlt
printr(); 29: FF2B2A: 0000
![Page 23: Introduction to Computer Yung-Yu Chuang - 國立臺灣大學cyy/courses/introCS/13fall/lectures/... · Introduction to Computer Yung-Yu Chuang ... id / password • Mailing list](https://reader034.vdocuments.mx/reader034/viewer/2022052122/5ae5d06f7f8b9a29048cbd33/html5/thumbnails/23.jpg)
From NAND to Tetris
• The elements of computing systemsC• Courses
• Software• Cool stuffs
![Page 24: Introduction to Computer Yung-Yu Chuang - 國立臺灣大學cyy/courses/introCS/13fall/lectures/... · Introduction to Computer Yung-Yu Chuang ... id / password • Mailing list](https://reader034.vdocuments.mx/reader034/viewer/2022052122/5ae5d06f7f8b9a29048cbd33/html5/thumbnails/24.jpg)
Pong on the Hack computer
Pong, 1985 Pong, 2011
Pong, on our g,computer
![Page 25: Introduction to Computer Yung-Yu Chuang - 國立臺灣大學cyy/courses/introCS/13fall/lectures/... · Introduction to Computer Yung-Yu Chuang ... id / password • Mailing list](https://reader034.vdocuments.mx/reader034/viewer/2022052122/5ae5d06f7f8b9a29048cbd33/html5/thumbnails/25.jpg)
Theme and structure of the book
abstract interface SoftwareHuman Abstract design
H.L. Language&
Operating Sys.
abstract interface
Compiler
Chapters 10 - 11
VM TranslatorVi t l
abstract interface
hierarchyThoughtChapters 9, 12
VM Translator
Chapters 7 - 8
VirtualMachine
AssemblyLanguage
abstract interface
Assembler
Chapter 6
abstract interfaceComputerArchitecture
Chapters 4 - 5Gate Logic
MachineLanguage
abstract interface
H d
abstract interface
Gate Logic
Chapters 1 - 3 ElectricalEngineering
PhysicsHardwarehierarchy
HardwarePlatform
Chips &Logic Gates
abstract interface
hierarchy
(Abstraction–implementation paradigm)
![Page 26: Introduction to Computer Yung-Yu Chuang - 國立臺灣大學cyy/courses/introCS/13fall/lectures/... · Introduction to Computer Yung-Yu Chuang ... id / password • Mailing list](https://reader034.vdocuments.mx/reader034/viewer/2022052122/5ae5d06f7f8b9a29048cbd33/html5/thumbnails/26.jpg)
Application level: Pong (an example)
Ballabstraction
BatBatabstraction
![Page 27: Introduction to Computer Yung-Yu Chuang - 國立臺灣大學cyy/courses/introCS/13fall/lectures/... · Introduction to Computer Yung-Yu Chuang ... id / password • Mailing list](https://reader034.vdocuments.mx/reader034/viewer/2022052122/5ae5d06f7f8b9a29048cbd33/html5/thumbnails/27.jpg)
The big picture
H.L. Language&
abstract interface
Compilerabstract interface
Softwarehierarchy
HumanThought
Abstract design
Chapters 9, 12
Operating Sys. Chapters 10 - 11
VM Translator
Chapters 7 - 8
VirtualMachine
Assembly
abstract interface
Assembler
Ch t 6
AssemblyLanguage
Chapter 6
ComputerArchitectureMachine
L
abstract interface
abstract interfaceChapters 4 - 5
Gate Logic
Chapters 1 - 3 ElectricalEngineeringH d
Language
HardwarePlatform
Chips &
abstract interface
EngineeringPhysicsHardware
hierarchyChips &
Logic Gates
![Page 28: Introduction to Computer Yung-Yu Chuang - 國立臺灣大學cyy/courses/introCS/13fall/lectures/... · Introduction to Computer Yung-Yu Chuang ... id / password • Mailing list](https://reader034.vdocuments.mx/reader034/viewer/2022052122/5ae5d06f7f8b9a29048cbd33/html5/thumbnails/28.jpg)
High-level programming (Jack language)/** A Graphic Bat for a Pong Game */class Bat {
field int x, y; // screen location of the bat's top-left cornerfield int width, height; // bat's width & height
// The class constructor and most of the class methods are omitted
/** Draws (color=true) or erases (color=false) the bat */method void draw(boolean color) {
do Screen.setColor(color);do Screen.drawRectangle(x,y,x+width,y+height);
Typical call to OS th dg ( ,y, ,y g );
return;}
/** Moves the bat one step (4 pixels) to the right. */
an OS method
/ Moves the bat one step (4 pixels) to the right. /method void moveR() {
do draw(false); // erase the bat at the current locationlet x = x + 4; // change the bat's X-location// but don't go beyond the screen's right border
// but don t go beyond the screen s right borderif ((x + width) > 511) {
let x = 511 - width;} do draw(true); // re draw the bat in the new location
Ballabstraction
Batabstraction
do draw(true); // re-draw the bat in the new locationreturn;
}}
![Page 29: Introduction to Computer Yung-Yu Chuang - 國立臺灣大學cyy/courses/introCS/13fall/lectures/... · Introduction to Computer Yung-Yu Chuang ... id / password • Mailing list](https://reader034.vdocuments.mx/reader034/viewer/2022052122/5ae5d06f7f8b9a29048cbd33/html5/thumbnails/29.jpg)
Operating system level (Jack OS)/** An OS-level screen driver that abstracts the computer's physical screen */
class Screen {
static boolean currentColor; // the current color static boolean currentColor; // the current color
// The Screen class is a collection of methods, each implementing one
// abstract screen-oriented operation. Most of this code is omitted.
/** Draws a rectangle in the current color. */
// the rectangle's top left corner is anchored at screen location (x0,y0)
// and its width and length are x1 and y1, respectively.
function void drawRectangle(int x0, int y0, int x1, int y1) {
var int x, y;
let x = x0;
while (x < x1) {while (x < x1) {
let y = y0;
while(y < y1) {
do Screen.drawPixel(x,y);
let y = y+1;
}
let x = x+1;
}
Ballabstraction
Batabstraction
}
}
}
![Page 30: Introduction to Computer Yung-Yu Chuang - 國立臺灣大學cyy/courses/introCS/13fall/lectures/... · Introduction to Computer Yung-Yu Chuang ... id / password • Mailing list](https://reader034.vdocuments.mx/reader034/viewer/2022052122/5ae5d06f7f8b9a29048cbd33/html5/thumbnails/30.jpg)
The big picture
abstract interface Softwarehi h
HumanTh ht
Abstract design
H.L. Language&
Operating Sys.
Compiler
Chapters 10 - 11
VM TranslatorVirtual
abstract interface
hierarchyThoughtChapters 9, 12
Chapters 7 - 8
VirtualMachine
AssemblyLanguage
abstract interface
Assembler
Chapter 6
abstract interfaceComputerArchitecture
Chapters 4 - 5Gate Logic
MachineLanguage
Hardware
abstract interface
g
Chapters 1 - 3 ElectricalEngineering
PhysicsHardwarehierarchy
HardwarePlatform
Chips &Logic Gates
abstract interface
hierarchy
![Page 31: Introduction to Computer Yung-Yu Chuang - 國立臺灣大學cyy/courses/introCS/13fall/lectures/... · Introduction to Computer Yung-Yu Chuang ... id / password • Mailing list](https://reader034.vdocuments.mx/reader034/viewer/2022052122/5ae5d06f7f8b9a29048cbd33/html5/thumbnails/31.jpg)
A modern compilation modelSome Other
languageJack
language. . .Some
language. . . Proj. 9: building an app.
Proj. 12: building the OS
ProjectsSome
compiler Some Othercompiler
Jackcompiler
VM language
10-11
VMimplementation
over CISCplatforms
VM imp.over RISCplatforms
VM imp.over the Hack
platformVM
emulatorProjects7-8
RISCmachine
Hackhi
CISCmachine
written ina high level
. . .
machinelanguage
machinelanguage
machinelanguage
. . . a high-levellanguage
. . . Projects1 6. . .
RISCmachine
other digital platforms, each equippedwith its VM implementation
Hackcomputer
CISCmachine
Anycomputer
1-6
![Page 32: Introduction to Computer Yung-Yu Chuang - 國立臺灣大學cyy/courses/introCS/13fall/lectures/... · Introduction to Computer Yung-Yu Chuang ... id / password • Mailing list](https://reader034.vdocuments.mx/reader034/viewer/2022052122/5ae5d06f7f8b9a29048cbd33/html5/thumbnails/32.jpg)
Compilation 101
Source code push x
Intermediate code>
parsing Codegeneration
Source code
(x + width) > 511
push x
push width
add
push 511
+ 511
push 511
gt
widthx
Abstraction ImplementationSyntaxAnalysis
ParseTree
SemanticSynthesis
Observations:
Modularity
Abstraction / implementation interplay
The implementation uses abstract services from the level below.
![Page 33: Introduction to Computer Yung-Yu Chuang - 國立臺灣大學cyy/courses/introCS/13fall/lectures/... · Introduction to Computer Yung-Yu Chuang ... id / password • Mailing list](https://reader034.vdocuments.mx/reader034/viewer/2022052122/5ae5d06f7f8b9a29048cbd33/html5/thumbnails/33.jpg)
The virtual machine (VM modeled after JVM)
if ((x+width)>511) {let x=511-width; 75
s2memory (before)...
// VM implementation
let x 511 width;}
75450
sp
450
x
width
75
...
push x // s1
push width // s2
add // s3
75...
s4 s5 s9
push 511 // s4
gt // s5
if-goto L1 // s6
525511
sp
1sp
511450
sp
goto L2 // s7
L1:
push 511 // s8 s10 memory (after) push width // s9
sub // s10
pop x // s11
61sp 450
...width
...
memory (after)
L2:
... x 61...
![Page 34: Introduction to Computer Yung-Yu Chuang - 國立臺灣大學cyy/courses/introCS/13fall/lectures/... · Introduction to Computer Yung-Yu Chuang ... id / password • Mailing list](https://reader034.vdocuments.mx/reader034/viewer/2022052122/5ae5d06f7f8b9a29048cbd33/html5/thumbnails/34.jpg)
The big picture
abstract interface Softwarehi h
HumanTh ht
Abstract design
H.L. Language&
Operating Sys.
Compiler
Chapters 10 - 11
VM TranslatorVirtual
abstract interface
hierarchyThoughtChapters 9, 12
Chapters 7 - 8
VirtualMachine
AssemblyLanguage
abstract interface
Assembler
Chapter 6
abstract interfaceComputerArchitecture
Chapters 4 - 5Gate Logic
MachineLanguage
Hardware
abstract interface
g
Chapters 1 - 3 ElectricalEngineering
PhysicsHardwarehierarchy
HardwarePlatform
Chips &Logic Gates
abstract interface
hierarchy
![Page 35: Introduction to Computer Yung-Yu Chuang - 國立臺灣大學cyy/courses/introCS/13fall/lectures/... · Introduction to Computer Yung-Yu Chuang ... id / password • Mailing list](https://reader034.vdocuments.mx/reader034/viewer/2022052122/5ae5d06f7f8b9a29048cbd33/html5/thumbnails/35.jpg)
Low-level programming (on Hack)
Virtual machine program
...
push x
push widthp
add
push 511
gt gt
if-goto L1
goto L2
L1:L1:
push 511
push width
sub sub
pop x
L2:
...
![Page 36: Introduction to Computer Yung-Yu Chuang - 國立臺灣大學cyy/courses/introCS/13fall/lectures/... · Introduction to Computer Yung-Yu Chuang ... id / password • Mailing list](https://reader034.vdocuments.mx/reader034/viewer/2022052122/5ae5d06f7f8b9a29048cbd33/html5/thumbnails/36.jpg)
Low-level programming (on Hack)
Virtual machine program
...
push x
push widthp
add
push 511
gtAssembly program
VM translator
gt
if-goto L1
goto L2
L1:
// push 511
@511
D=A // D=511L1:
push 511
push width
sub
D A // D 511
@SP
A=M
M=D // *SP=D
push 511
sub
pop x
L2:
M D // SP D
@SP
M=M+1 // SP++
...
![Page 37: Introduction to Computer Yung-Yu Chuang - 國立臺灣大學cyy/courses/introCS/13fall/lectures/... · Introduction to Computer Yung-Yu Chuang ... id / password • Mailing list](https://reader034.vdocuments.mx/reader034/viewer/2022052122/5ae5d06f7f8b9a29048cbd33/html5/thumbnails/37.jpg)
Low-level programming (on Hack)
Virtual machine program
...
push x
push widthp
add
push 511
gtAssembly program
VMtranslator
gt
if-goto L1
goto L2
L1:
// push 511
@511
D=A // D=511L1:
push 511
push width
sub
//
@SP
A=M
M=D // *SP=D Executable
Assembler
push 511
sub
pop x
L2:
M D // SP D
@SP
M=M+1 // SP++
0000000000000000
1110110010001000@SPM=M+1 // SP++
...
![Page 38: Introduction to Computer Yung-Yu Chuang - 國立臺灣大學cyy/courses/introCS/13fall/lectures/... · Introduction to Computer Yung-Yu Chuang ... id / password • Mailing list](https://reader034.vdocuments.mx/reader034/viewer/2022052122/5ae5d06f7f8b9a29048cbd33/html5/thumbnails/38.jpg)
The big picture
abstract interface Softwarehi h
HumanTh ht
Abstract design
H.L. Language&
Operating Sys.
Compiler
Chapters 10 - 11
VM TranslatorVirtual
abstract interface
hierarchyThoughtChapters 9, 12
Chapters 7 - 8
VirtualMachine
AssemblyLanguage
abstract interface
Assembler
Chapter 6
abstract interfaceComputerArchitecture
Chapters 4 - 5Gate Logic
MachineLanguage
Hardware
abstract interface
g
Chapters 1 - 3 ElectricalEngineering
PhysicsHardwarehierarchy
HardwarePlatform
Chips &Logic Gates
abstract interface
hierarchy
![Page 39: Introduction to Computer Yung-Yu Chuang - 國立臺灣大學cyy/courses/introCS/13fall/lectures/... · Introduction to Computer Yung-Yu Chuang ... id / password • Mailing list](https://reader034.vdocuments.mx/reader034/viewer/2022052122/5ae5d06f7f8b9a29048cbd33/html5/thumbnails/39.jpg)
Machine language semantics (Hack)
Instruction code
Code semantics, as interpreted by the Hack hardware platform
Code syntax
Instruction code(0=“address” inst.) Address
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
1 1 1 0 0 1 0 0 01 1 1 0 1 1 1
0000000000000000
1111110111001000@0
M=M-1
ALUoperation code
DestinationCode
JumpCode
Instruction code(1=“compute” inst.) operation code
(M-1)
Code
(M)
Code
(no jump)
(1 compute inst.)
• We need a hardware architecture that realizes this semantics• The hardware platform should be designed to:
o Parse instructions, and,o Execute them.
![Page 40: Introduction to Computer Yung-Yu Chuang - 國立臺灣大學cyy/courses/introCS/13fall/lectures/... · Introduction to Computer Yung-Yu Chuang ... id / password • Mailing list](https://reader034.vdocuments.mx/reader034/viewer/2022052122/5ae5d06f7f8b9a29048cbd33/html5/thumbnails/40.jpg)
Computer architecture (Hack)instruction
DataMemory
(M)
ALUInstruction
Memory A
D
data out (M)M
data out
address of nextinstruction
ProgramCounter
instructiondata in RAM(A)
• A typical Von Neumann machine
![Page 41: Introduction to Computer Yung-Yu Chuang - 國立臺灣大學cyy/courses/introCS/13fall/lectures/... · Introduction to Computer Yung-Yu Chuang ... id / password • Mailing list](https://reader034.vdocuments.mx/reader034/viewer/2022052122/5ae5d06f7f8b9a29048cbd33/html5/thumbnails/41.jpg)
The big picture
SoftwareHuman Abstract design
H.L. Language&
Operating Sys.
abstract interface
Compiler
Chapters 10 - 11abstract interface
Softwarehierarchy
HumanThought
g
Chapters 9, 12
p g yVM Translator
Chapters 7 - 8
VirtualMachine
AssemblyLanguage
abstract interface
Assembler
Chapter 6
Language
ComputerArchitecture
Chapters 4 - 5
MachineLanguage
abstract interface
abstract interface
Gate Logic
Chapters 1 - 3 ElectricalEngineering
PhysicsHardware
HardwarePlatform
Chips &Logic Gates
abstract interface
yhierarchy Logic Gates
![Page 42: Introduction to Computer Yung-Yu Chuang - 國立臺灣大學cyy/courses/introCS/13fall/lectures/... · Introduction to Computer Yung-Yu Chuang ... id / password • Mailing list](https://reader034.vdocuments.mx/reader034/viewer/2022052122/5ae5d06f7f8b9a29048cbd33/html5/thumbnails/42.jpg)
Logic design
• Combinational logic (leading to an ALU)S i l l i (l di RAM)• Sequential logic (leading to a RAM)
• Putting the whole thing together (leading to a computer)
Using … gate logic
![Page 43: Introduction to Computer Yung-Yu Chuang - 國立臺灣大學cyy/courses/introCS/13fall/lectures/... · Introduction to Computer Yung-Yu Chuang ... id / password • Mailing list](https://reader034.vdocuments.mx/reader034/viewer/2022052122/5ae5d06f7f8b9a29048cbd33/html5/thumbnails/43.jpg)
Gate logic Hardware platform = inter-connected set of chips
Chips are made of simpler chips, all the way down to elemantary logic gatesh ps are made of s mpler ch ps, all the way down to elemantary log c 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 Every chip and gate has an interface, specifying WHAT it is doing, and an implementation, specifying HOW it is doing it.
Interface
a
Implementation
Xora
bout And
O t
a Not
0 0 00 1 1
a b out
And Not
Or out
0 1 11 0 11 1 0
Andb
![Page 44: Introduction to Computer Yung-Yu Chuang - 國立臺灣大學cyy/courses/introCS/13fall/lectures/... · Introduction to Computer Yung-Yu Chuang ... id / password • Mailing list](https://reader034.vdocuments.mx/reader034/viewer/2022052122/5ae5d06f7f8b9a29048cbd33/html5/thumbnails/44.jpg)
Hardware description language (HDL)
Anda
And
Or out
Not
And Not
b CHIP Xor {CHIP Xor { IN a,b; OUT out;
PARTS 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);}
![Page 45: Introduction to Computer Yung-Yu Chuang - 國立臺灣大學cyy/courses/introCS/13fall/lectures/... · Introduction to Computer Yung-Yu Chuang ... id / password • Mailing list](https://reader034.vdocuments.mx/reader034/viewer/2022052122/5ae5d06f7f8b9a29048cbd33/html5/thumbnails/45.jpg)
The tour ends:
Interface One implementation option (CMOS)
outa
bNand
0 0 1a b out
b
0 0 10 1 11 0 11 1 0
![Page 46: Introduction to Computer Yung-Yu Chuang - 國立臺灣大學cyy/courses/introCS/13fall/lectures/... · Introduction to Computer Yung-Yu Chuang ... id / password • Mailing list](https://reader034.vdocuments.mx/reader034/viewer/2022052122/5ae5d06f7f8b9a29048cbd33/html5/thumbnails/46.jpg)
The tour map, revisited
Compilerabstract interface Softwarehierarchy
HumanThought
Abstract design
Ch 9 12H.L. Language
&Operating Sys.
Compiler
Chapters 10 - 11
VM TranslatorVirtual
abstract interface
hierarchy
abstract interface
gChapters 9, 12
Operating System Chapters 7 - 8Machine
AssemblyLanguage
abstract interface
Course overview:Assembler
Chapter 6
Computerabstract interface
Course overview:Building this world,from the ground up
C t A hit t
ComputerArchitecture
Chapters 4 - 5Gate Logic
MachineLanguage
Hardware
abstract interface
abstract interface
Di it l S t D i
Computer Architecture Chapters 1 - 3 ElectricalEngineering
PhysicsHardwarehierarchy
Platform
Chips &Logic Gates
abstract interface
ElectronicsDigital System Design
![Page 47: Introduction to Computer Yung-Yu Chuang - 國立臺灣大學cyy/courses/introCS/13fall/lectures/... · Introduction to Computer Yung-Yu Chuang ... id / password • Mailing list](https://reader034.vdocuments.mx/reader034/viewer/2022052122/5ae5d06f7f8b9a29048cbd33/html5/thumbnails/47.jpg)
What you will learn
• Number systemsC bi i l l i• Combinational logic
• Sequential logic• Basic principle of computer architecture• Assembler• Assembler• Virtual machine
Hi h l l l• High-level language• Fundamentals of compilers • Basic operating system• Application programming• Application programming
![Page 48: Introduction to Computer Yung-Yu Chuang - 國立臺灣大學cyy/courses/introCS/13fall/lectures/... · Introduction to Computer Yung-Yu Chuang ... id / password • Mailing list](https://reader034.vdocuments.mx/reader034/viewer/2022052122/5ae5d06f7f8b9a29048cbd33/html5/thumbnails/48.jpg)
In short