Nand2Tetris - Overview

Nand2Tetris is the name of a project that is the focus of the text The Elements of Computing Systems: Building a Modern Computer from First Principles by Noam Nisan and Shimon Schocken (2008 MIT Press, ISBN 978-0-262-64068-8).

The book is extremely affordable -- when I last looked it was $28 from MIT Press. Also, the first half of the book is available for free online -- as well as all of the projects and the software tools and files associated with the Nand2Tetris project -- at the Nand2Tetris website.

The goal of the book is to provide students with an integrated look at an entire, complete computer from the basic NAND gate all the way up to an operating system and everything -- and I mean everything (subject to the caveats below) -- in between. This includes the computer hardware (adders, ALUs, registers, memory, CPU, jump logic, program counter, and the complete computer) as well as the software that runs on it (machine executable instructions, assembly language source code, intermediate virtual machine language source code, high level object-oriented language source code) and also the tools that process the source code files at each level (the assembler, the VM translator, and the compiler) and, finally, a basic operating system library with routines to do string and array allocation, dynamic memory allocation and heap management, math routines, keyboard input, and console and screen graphics output.

All of this is done in a single semester, which means that not only is it fast paced, but it is also very focused. The material is covered at a depth that is sufficient to complete the projects, but not much further. None-the-less, the depth is amazingly adequate to expose students to concepts that are sometimes not even mentioned in traditional courses and here they are not only mentioned, but the students have to understand them well enough to implement them.

It should be stated that students don't actually work with ANY hardware (other than the computer that the software is installed on). Everything is tested using various emulators. There is a hardware emulator that uses the HDL (hardware description language) files that the students develop, a CPU emulator that runs assembly language code on an "official" version of the CPU hardware, and a VM emulator that executes the intermediate level VM code on the "official" standard mapping.

Now, I know that previously I said that students did everything and this is pretty much a true statement, particularly for the vertical stack starting from the NAND gate and moving up to the operating system. But it is not the case for the peripherals associated with a computer. For instance, the emulators use memory mapped I/O to interface to the keyboard and the screen display (which is shown within the emulator). Thus students do not gain much understanding of how a CPU communicates with the many peripherals that it must deal with in order to function, at least not beyond the basic concept of memory-mapped I/O. Another element that is entirely missing is the notion of mass storage of any kind; thus no hard drive, files, or file system. It should also be pointed out that the "operating system" is an operating system in a very primitive sense, namely a library of functions that programs can invoke essentially as system calls. There is no command line monitor program even along the lines of the original DOS/UNIX operating systems.

In this blog each of the twelve Nand2Tretris projects will have a separate child category dedicated to it. These will develop over time -- probably the better part of six months.

Since this is a text and project that is widely used at many universities around the world, the posts here will NOT include solutions to the projects. For similar reasons, responses to these posts will be moderated to ensure that discussions do not stray too far into giving out too much information.

One of my goals is to move this project out of the emulated world and into the read world by implementing the processor in an FPGA (I would not be the first to do this) and to then extend the projects so encompass communication with physical peripherals, starting with a keyboard and VGA monitor, and then adding hard drive support (probably in the form of an SD card) with a simple file system and then a true operating system (albeit it still a very primitive one).

Blog entry information

Author
WBahn
Views
6,888
Last update

More entries in General

More entries from WBahn

Share this entry

Top