(Usage hints for this presentation)
IT Systems, Summer Term 2025
Dr. Jens Lechtenbörger (License Information)
Video by co-creator of Nand2Tetris
Recall: Build general-purpose, programmable computer; here, the Hack platform

Hack CPU executes instructions in machine language
Each Hack instruction consists of 16 bits
i = i + 10000000000010000 (A-instruction, starts with 0,
binary number for 16)
@161111 110111 001 000
(C-instruction, starts with 1, encodes operation)
M=M+1M+1), 3 blue bits specify where
to store the result (in M, the memory location for our variable)Modern processors behave similarly
Projects focus on successively more complex chips
From simple logic gates to entire computer
Digital/binary devices with bit as basic unit of information
Chips come with specifications/interfaces (and tests)
Results/implementations for each project are building blocks for subsequent ones
You work on projects individually
Project 1
Given: Nand(x, y), false
| x | y | Nand(x, y) |
|---|---|---|
| 0 | 0 | 1 |
| 0 | 1 | 1 |
| 1 | 0 | 1 |
| 1 | 1 | 0 |
Nand is a binary Boolean function
0 represents false, 1 represents trueLearn about Boolean logic
Implement sequence of chips (from specifications)
Not(x)
Not flips its argument: true = Not(false), false = Not(true)Not(x) = Nand(x, x)
And
True if and only if all arguments are true; revisited
subsequentlyXor, Or, Mux, and several more…And GateAnd Gate
Three files for binary function And(a, b)
And.hdl// This file is part of www.nand2tetris.org
// and the book "The Elements of Computing Systems"
// by Nisan and Schocken, MIT Press.
// File name: projects/01/And.hdl
/**
* And gate:
* out = 1 if (a == 1 and b == 1)
* 0 otherwise
*/
CHIP And {
IN a, b;
OUT out;
PARTS:
// Put your code here:
}
File And.cmp
| a | b | out |
|---|---|---|
| 0 | 0 | 0 |
| 0 | 1 | 0 |
| 1 | 0 | 0 |
| 1 | 1 | 1 |
File And.tst
And Gate (1/3)And gate should do
Specification: out == 1 if and only if a == b == 1
And.hdlCHIP And {
IN a, b;
OUT out;
PARTS:
// Put your code here:
}
And Gate (2/3)And gate
Gate logic: And(a, b) = Not(Nand(a, b))
And.hdlCHIP And {
IN a, b;
OUT out;
PARTS:
// Put your code here:
}
And Gate (3/3)And gate
Gate logic: And(a, b) = Not(Nand(a, b))
And.hdlCHIP And {
IN a, b;
OUT out;
PARTS:
Nand(a = a, b = b, out = aNandB);
Not(in = aNandB, out = out);
}
tools subdirectory: chmod u+x *.sh
Previous And implementation in Hardware Simulator
Source files are available on GitLab (check out embedded submodules) under free licenses. Icons of custom controls are by @fontawesome, released under CC BY 4.0.
Except where otherwise noted, the work “Nand2Tetris”, © 2024-2025 Jens Lechtenbörger, is published under the Creative Commons license CC BY-SA 4.0.