the elements of computing systems (from nand to tetris) building a modern computer from first...

26
The Elements of Computing Systems (From NAND to Tetris) Building a Modern Computer from First Principles

Upload: alison-mosley

Post on 18-Dec-2015

223 views

Category:

Documents


4 download

TRANSCRIPT

Page 1: The Elements of Computing Systems (From NAND to Tetris) Building a Modern Computer from First Principles

The Elements of Computing Systems (From NAND to Tetris)

Building a Modern Computer from First Principles

Page 2: The Elements of Computing Systems (From NAND to Tetris) Building a Modern Computer from First Principles

Authors

Professor Shimon Schocken Information Technologies

and Dean of the Efi Arazi School of Computer Science, Interdisciplinary Center Herzliya

Professor Noam Nisan Institute of Computer

Science and Engineering, Hebrew University of Jerusalem

Page 3: The Elements of Computing Systems (From NAND to Tetris) Building a Modern Computer from First Principles

introduction

students start with the primitive NAND gate, and using a hardware simulator and HDL, they build basic gates, using which they build an ALU (Arithmatical Logic Unit), going on to building an actual computer (in simulation). Then they create an assembly language for this computer, followed by a high level language, an operating system, and finally a game using the language they created, on the machine they created.

Page 4: The Elements of Computing Systems (From NAND to Tetris) Building a Modern Computer from First Principles

characters

Designed to support one- or two-semester courses

each chapter presents a key hardware or software abstraction

the only pre-requisite being a programming experience

http://www.diycomputerscience.com/courses/course/the-elements-of-computing-systems

Page 5: The Elements of Computing Systems (From NAND to Tetris) Building a Modern Computer from First Principles

contents Designing elementary logic gates from a NAND gate using Hardware

Description Language Building an ALU (Arithmatic Logic Unit) Designing Registers, RAM, etc Designing an assembly language Building the entire computer (in simulation) with the ALU, Registers,

RAM, and the assembly language Building an Assembler for the assembly language we created Building a Virtual Machine (similar to the JVM - though much smaller

in scope) Introducing a high level, object oriented programming language Writing a compiler for the high level language Writing an Operating System for our computer, using the high level

language we created Some more fun (discussing improvements, and future directions)

Page 6: The Elements of Computing Systems (From NAND to Tetris) Building a Modern Computer from First Principles

1.Designing elementary logic gates from a NAND gate using Hardware Description

Language Resources

The hardware simulator HDL

Activities

Page 7: The Elements of Computing Systems (From NAND to Tetris) Building a Modern Computer from First Principles

Activities Download and install the TECS Hardware Simulator TECS - Build a NOT gate(NAND ) TECS - Build an AND gate(NAND) TECS - Build an OR gate(NAND) TECS - Build an XOR gate(NAND, AND, OR) TECS - Build a MUX(NAND, AND, OR, XOR) TECS - Build a DMUX(NAND, AND, OR, XOR, MUX) TECS - Build a 16 bit NOT(NAND, AND, OR, XOR, MUX, DMUX) TECS - Build a 16 bit AND (NAND, AND, OR, XOR, MUX, DMUX) TECS - Build a 16 bit OR(NAND, AND, OR, XOR, MUX, DMUX) TECS - Build a 16 bit MUX

(NAND, AND, OR, XOR, MUX, DMUX, 16-NOT, 16-AND, 16-OR) TECS - Build an 8 Way OR TECS - Build a 16 bit / 4 Way MUX TECS - Build a 16 bit / 8 Way MUX TECS - Build a 4 Way DMUX TECS - Build an 8 Way DMUX

Page 8: The Elements of Computing Systems (From NAND to Tetris) Building a Modern Computer from First Principles

2.Building an ALU (Arithmatic Logic Unit)

Activities TECS - Build a Half Adder TECS - Build a Full Adder TECS - Build a 16 bit Adder TECS - Build a 16 bit Incrementer TECS - Build an ALU

Page 9: The Elements of Computing Systems (From NAND to Tetris) Building a Modern Computer from First Principles

3.Designing Registers, RAM, etc

Activities TECS - Build a 1 bit binary cell(DFF) TECS - Build a 16 bit register(DFF) TECS - Build a 16-bit / 8-register memory(DFF) TECS - Build a 16-bit / 64-register memory(DFF) TECS - Build a 16-bit / 512-register memory(DFF) TECS - Build a 16-bit / 4096-register memory(DFF) TECS - Build a 16-bit / 16384-register memory(DFF) TECS - Build a 16-bit Program Counter(DFF)

Page 10: The Elements of Computing Systems (From NAND to Tetris) Building a Modern Computer from First Principles

4.Designing an assembly language

Activities TECS - Get familiar with the assembler and CPU

emulator TECS - Write a assembly language program to

multiply two numbers TECS - Write an IO bound program using our

assembly language IO handling: This program runs an infinite loop that listens

to the keyboard input. When a key is pressed (any key), the program blackens the screen, i.e. writes "black" in every pixel. When no key is pressed, the screen should be cleared.

Page 11: The Elements of Computing Systems (From NAND to Tetris) Building a Modern Computer from First Principles

5. Building the entire computer (in simulation) with the ALU, Registers, RAM, and the assembly language

Activities TECS - Create a (simulated) memory chip

The Memory chip should be composed from three chips: RAM16K, Screen, and Keyboard. 

TECS - Build a (simulated) CPU chipusing the ALU and register chips 

TECS - Build a (simulated) Computer chip using the Memory, and CPU chips we created in the past two

activities. Add.hack Adds the two constants 2 and 3 and writes the result in

RAM[0]. Max.hack: Computes the maximum of RAM[0] and RAM[1] and

writes the result in RAM[2]. Rect.hack: Draws a rectangle of width 16 pixels and length RAM[0]

at the top left of the screen.

Page 12: The Elements of Computing Systems (From NAND to Tetris) Building a Modern Computer from First Principles

6. Building an Assembler for the assembly language we

created Activities

TECS - Build an assembler Develop an assembler that translates programs

written in Hack assembly language into the binary code understood by the Hack hardware platform. 

write a symbol-less assembler, then extend your assembler with symbol handling capabilities. 

use the following *.asm programs for testing your assembler, such as add, max, rect, ping-pong game

Page 13: The Elements of Computing Systems (From NAND to Tetris) Building a Modern Computer from First Principles

7. Building a Virtual Machine (similar to the JVM - though much smaller in scope)

Activities TECS - Build the Stack Arithmatical part of

the VM TECS - Build the Program Control part of the

VM

Page 14: The Elements of Computing Systems (From NAND to Tetris) Building a Modern Computer from First Principles

8. Introducing a high level, object oriented programming language

Activities TECS - Write a program using Jack

Page 15: The Elements of Computing Systems (From NAND to Tetris) Building a Modern Computer from First Principles

9. Writing a compiler for the high level language

Activities TECS - Build a Compiler (Syntax Analysis) TECS - Build a Compiler (Code Generation)

Page 16: The Elements of Computing Systems (From NAND to Tetris) Building a Modern Computer from First Principles

10. Writing an Operating System for our computer, using the high level

language we created Activities

TECS - Build an operating system

Page 17: The Elements of Computing Systems (From NAND to Tetris) Building a Modern Computer from First Principles

11. Some more fun (discussing improvements, and future directions)

Activities More fun to go

Page 18: The Elements of Computing Systems (From NAND to Tetris) Building a Modern Computer from First Principles

Stanford Computer Science 101Stanford Online class

Page 19: The Elements of Computing Systems (From NAND to Tetris) Building a Modern Computer from First Principles

Instructor

Nick Parlante has been teaching Computer Science at Stanford

for over 20 years teaches programming best practices at Google produced the Google Python Class and 

codingbat.com code practice site, and the infamous Binky Pointer Fun video

Page 20: The Elements of Computing Systems (From NAND to Tetris) Building a Modern Computer from First Principles

Introduction

teaches the essential ideas of Computer Science for a zero-prior-experience audience.

uses small coding experiments in the browser to play with the nature of computers, understanding their strengths and limitations

an excellent first step for someone who then wants to take a full programming course

Page 21: The Elements of Computing Systems (From NAND to Tetris) Building a Modern Computer from First Principles

Syllabus The nature of computers and code, what they can and cannot

do How computer hardware works: chips, cpu, memory, disk Necessary jargon: bits, bytes, megabytes, gigabytes How software works: what is a program, what is "running" How digital images work Computer code: loops and logic Big ideas: abstraction, logic, bugs How structured data works How the internet works: ip address, routing, ethernet, wi-fi Computer security: viruses, trojans, and passwords, oh my! Analog vs. digital Digital media, images, sounds, video, compression

Page 22: The Elements of Computing Systems (From NAND to Tetris) Building a Modern Computer from First Principles

Workload 3-5 hours/week

Registration Sign up for the "To be announced" session to be

notified by email when the class is next run sign up for "Self-Study" to start browsing the

class materials right away

Page 23: The Elements of Computing Systems (From NAND to Tetris) Building a Modern Computer from First Principles

Content Organization

 lecture videos eight and twelve minutes /chunk, two hours

worth of video content /week Quiz programming assignments

does not look like full, professional Javascript code

written document

Page 24: The Elements of Computing Systems (From NAND to Tetris) Building a Modern Computer from First Principles

Lectures Week1

Introduction to Computing Principles(19 mins) Variables(6 mins) Introduction to digital images(13 mins) Image code(9 mins)

Week2 For Loops(10 mins) Expressions(14 mins) Puzzies(4 mins) Graysclae(14 mins)

Week3 If Logic(16 mins) Bluescreen( 12 mins) Hardware(15 mins) Optional Viedo:hard-drive Bites Bytes 1(9 mins) Bites Bytes 2(7 mins)

Page 25: The Elements of Computing Systems (From NAND to Tetris) Building a Modern Computer from First Principles

Lectures cont. Week4

Software (9 mins)Ⅰ Software (11 mins)Ⅱ Networking (16mins) TCP/IP(16 mins) Table Date(16 mins)

Week 5 String(4 mins) Boolean Logic(11 mins) Count (5 mins)Ⅰ Count (15 mins)Ⅱ Analog Digital 1(22 mins)

Week 6 Optional Video: Office Hours Analog Digital 2(24 mins) Digital Media(22 mins) Security(30 mins) Conclusions(14 mins)

Page 26: The Elements of Computing Systems (From NAND to Tetris) Building a Modern Computer from First Principles

conclusion

Why does the course content and book materials vary so much

Abroad university also has the similar computer foundation course

What should we do? content or method How can we do? visualization, motivation