Nand2Tetris — Part 1

Morgan Fogarty
2 min readDec 13, 2020

I’ve been once again trying to understand programming in a way that feels grounded. My manager suggested that solidifying first principles could be my ticket, and gave me a challenge: Nand2Tetris.

Nand2Tetris is a self paced project in which the learner creates a simple computer(in a hardware simulator) from small modules — chips.

I have endeavored upon the first chapter and corresponding tasks. Wow were they fun!

First, I learned about boolean logic and logic gates and the HDL(Hardware Description Language) I’d be using. Then I learned how to use the hardware simulator.

Hardware simulator

Then I was tasked with implementing the following gates using only the gates I had implemented previously: Not, And, Or, Xor, Mux, Dmux and the multibit version of each of those. I was given Nand and only Nand, initially. While implementing Xor I learned about De Morgan’s laws, which was great fun.

A very useful lesson I learned during this chapter 1 project is boolean function synthesis. Taking a truth table and turning it into a function. Here’s an example of Mux in a picture of my notes.

Truth table to boolean function
Boolean function implemented in HDL

In starting this project, I came to appreciate the higher level languages we use to write code everyday. Being able to use an if statement is so much simpler for the human than writing logic gates. Ha!

If I had to compare this to something I’m more familiar with, I’d compare it to ballet. In this project, I started with Nand. From there I was able to build other gates. I’ll compare Nand to first position. In this first chapter, I was not able to use Mux until I first used Nand to implement Or within mux. In ballet, when doing a tendu at the barre á la seconde, and closing into fifth position, one must pass through first position along the way. Closing securely in fifth position is not possible without first position. Mux is not possible without Nand and Or.

I look forward in the next chapter to learning about boolean arithmetic and creating an Arithmetic Logic Unit.

--

--

Morgan Fogarty

I’m just a girl, standing in front of some code, asking it to love her.