The Hack computer is a theoretical computer design created by Noam Nisan and Shimon Schocken and described in their book, The Elements of Computing Systems: Building a Modern Computer from First Principles. In using the term “modern”, the authors refer to a digital, binary machine that is patterned according to the von Neumann architecture model. The Hack computer is intended for hands-on virtual construction in a hardware simulator application as a part of a basic, but comprehensive, course in computer organization and architecture. One such course, created by the authors and delivered in two parts, is freely available as a massive open online course (MOOC) called Build a Modern Computer From First Principles: From Nand to Tetris. In the twelve projects included in the course, learners start with a two input NAND gate and end up with a fully operational virtual computer, including both hardware (memory and CPU) and software (assembler, VM, Java-like programming language, and OS). In addition to the hardware simulator used for initial implementation of the computer hardware, a complete Hack computer emulator program and assembler that supports the projects described in the book and the on-line course is also available at the author's web site.
Hardware architecture
The Hack computer hardware consists of three basic elements as shown in the block diagram. There are two separate 16-bit memory units and a central processing unit (CPU). Because data is moved and processed by the computer in 16-bit words, the Hack computer is classified as a 16-bit architecture. The instruction memory, implemented as read-only memory from the viewpoint of the computer and designated ROM, holds assembled binary program code for execution. The random-access memory, called RAM, provides storage for an executing program’s data and provides services and storage areas for the computer’s memory-mapped I/O mechanism. Data processing and program control management are provided by the CPU. The three units are connected by parallel buses. The address buses (15-bit), as well as the data and instruction busses (16-bit) for the ROM and RAM units are completely independent. Therefore, the Hack design follows the Harvard architecture model with respect to bus communication between the memory units and the CPU. All memory is word addressable only.
Read-only memory (ROM) The Hack computer’s ROM module is presented as a linear array of individually addressable, sequential, 16-bit memory registers. Addresses start at 0 (0x0000). Since the memory elements are sequential devices, a system clock signal is supplied by the simulation application and the computer emulator application. The ROM address bus is 15 bits wide, so a total of 32,768 individual words are available for program instructions. The address of the currently active word is supplied by a program counter register within the CPU (see below). The value in the ROM memory register identified by the address placed on the instruction address bus in a particular clock cycle is available as the "current" instruction at the beginning of the next cycle. There is no instruction register; instructions are decoded in each cycle from the currently active ROM register.
Random-access memory (RAM) Although the RAM module is also viewed as a continuous linear array of individually addressable sequential, read-write, 16-bit memory registers, it is functionally organized by address range into three segments. Addresses 0 (0x000) through 16383 (0x3FFF) contain conventional 16-bit, read-write registers and are meant for use as general-purpose program data storage. The registers at addresses 16384 (0x4000) through 24575 (0x5FFF) are essentially like data RAM, but they are also designated for use by a built-in screen I/O subsystem. Data written to addresses in this range have the side effect of producing output on the computer’s virtual 256 x 512 screen (see I/O). If a program does not require screen output, registers in this range may be used for general program data. The final address in the RAM address space, at 24576 (0x6000), contains a single one word register whose current value is controlled by the output of a keyboard attached to the computer hosting the Hack emulator program. This keyboard memory map register is read-only (see I/O). Data memory addresses in the range 24577 (0x6001) through 32767 (0x7FFF) are invalid. State transitions of the selected RAM memory register is also coordinated by the system clock signal.
Central processing unit (CPU)
… excerpt ends here. Continue reading the full article.

