The Elements of Computing Systems, My Workbook for the NAND to Tetris course.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 
Nemo c71dd21128 Break up the file a bit, haven't committed compilation stuff yet 2 years ago
assembler [08] Finishes VM Implementation 3 years ago
compiler Break up the file a bit, haven't committed compilation stuff yet 2 years ago
projects [10] Tokenizer works on all files correctly 2 years ago
vm [08] Update notes 3 years ago
.gitattributes gitattributes 3 years ago
.gitignore Break up the file a bit, haven't committed compilation stuff yet 2 years ago
NOTES.md Break up the file a bit, haven't committed compilation stuff yet 2 years ago
README.md Adds NOTES for compiler implementation 2 years ago

README.md

nand2tetris Status Badge

Working my way through the Nand to Tetris Course

  • Download the latest nand2tetris.zip from the book website, and overwrite everything in the projects and tools directory.
  • Remember to run chmod +X tools/*.sh if you're on *nix.

High level implementation notes

  1. Projects 1-5 as is
  2. Project 6 (Assembler) done in ruby with a port to Rust in progress
  3. Project 7-8 (VM) done in PHP
  4. Project 9 - Wrote a small 2 player Tic Tac Toe game. Plan to upgrade it to Ultimate Tic Tac Toe when I get time.
  5. Project 10-11 - Writing the compiler in Python

Detailed notes documenting progress updates are in NOTES.md.

Project 1: Boolean Logic

Build order as per the website. Cost for each gate in NAND in brackets.

  • Nand (primitive)
  • Not (1)
  • Or (3)
  • Xor (6, Can be improved)
  • And (2)
  • Mux (8, Took me ages. Can be improved)
  • DMux (5, Super Fun)
  • Not16 (16)
  • And16 (32)
  • Or16 (48)
  • Mux16 (113)
  • Or8Way (21)
  • Mux4Way16 (339)
  • Mux8Way16 (791)
  • DMux4Way (37, Fun)
  • DMux8Way (101)

Project 2: Boolean Arithmetic

CHIPs/Gates used in brackets

  • HalfAdder (Xor+And)
  • FullAdder (2 HalfAdder, 1 Or)
  • Add16 (1 HalfAdder, 15 FullAdder)
  • Inc16 (1 Add16)
  • ALU (6 Mux16, 3 Not16, 1 Add16, 1 And16, 2 Or8Way, 2 Or, 1 Not)

Project 3: Memory

Make sure you read through the Hardware Simulator Tutorial to understand the clock in the simulator.

  • DFF (primitive)
  • Bit (1 Mux, 1DFF)
  • Register (16 Bits)
  • RAM8 (8 Registers, 1 DMux8Way, 1 Mux8Way16) = 8 registers
  • RAM64 (8 RAM8, 1 DMux8Way, 1 Mux8Way16) = 64 registers
  • RAM512 (8 RAM64, 1 DMux8Way, 1 Mux8Way16) = 512 registers
  • RAM4K (8 RAM512, 1 DMux8Way, 1 Mux8Way16) = 4096 registers
  • RAM16K (4 RAM4K, 1 DMux4Way, 1 Mux4Way16) = 16384 registers
  • PC (1 Register, 1 Inc16, 1 Or8Way, 1 Mux8Way16)

Project 4: Machine Language Programming

Counting number of instructions by wc -l $file.hack

  • Mult (18)
  • Fill (98)

Project 5: Computer Architecture

Chips

  • Memory.hdl (2xMux16, 2xNot, 3xAnd 1 RAM16K)
  • CPU.hdl (6 And, 2 Nand, 3 Or, 1 Not, 1 Mux16, 1 Mux16, 2 Register, 1 PC, 1 ALU)
  • Computer.hdl (1 CPU, 1 ROM32K, 1 Memory)

Computer chip tests:

  • Add.hack
  • Max.hack
  • Rect.hack

Project 6: The Assembler

Without Symbols

  • MaxL.asm
  • RectL.asm
  • PongL.asm
  • Add.asm

Symbolic Programs

  • Max.asm
  • Rect.asm
  • Pong.asm

Project 7: Virtual Machine I - Stack Arithmetic

Final hack instruction set count in brackets. Calculated by running:

php file.vm > file.asm
ruby assembler.rb file.vm > file.hack
wc -l file.hack

Arithmetic Commands

  • SimpleAdd.vm (21)
  • StackTest.vm (334)

Memory Access Commands

  • BasicTest.vm (228)
  • PointerTest.vm (127)
  • StackTest.vm (73)

Project 8: Virtual Machine II - Program Control

Final hack instruction set count in brackets as before.

Program Flow Commands

  • BasicLoop.vm (93)
  • Fibonacci.vm (193)

Function Calling Commands

  • SimpleFunction.vm (128)
  • FibonacciElement (434)
  • NestedCall.vm (556)
  • StaticsTest.vm (664)

Project 9: High-Level Programming

  • TicTacToe

Project 10: Compiler I - Syntax Analysis

Tokenizer

  • Square
  • TestArray

Parser (Compilation Engine)

  • Square
  • ExpressionLessSquare
  • TestArray