> For the complete documentation index, see [llms.txt](https://wiki.zacheller.dev/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://wiki.zacheller.dev/hardware/nand2tetris/memory.md).

# Memory

**In a nutshell:** Having built the computer's ALU, this module we turn to building the computer's *main memory* unit, also known as *Random Access Memory,* or *RAM*. This will be done gradually, going bottom-up from elementary flip-flop gates to one-bit registers to *n*-bit registers to a family of RAM chips. Unlike the computer's processing chips, which are based on *combinational logic*, the computer's memory logic requires a clock-based *sequential logic*. We will start with an overview of this theoretical background, and then move on to build our memory chipset.

**Key concepts:** combinational vs sequential logic, clocks and cycles, flip-flops, registers, RAM units, counters.

## Sequential Logic

![](/files/-MIPw50yPlzPntsgWl2d)

![](/files/-MIPwGYjU5zwqaJYK2Ji)

* Why do we use discrete time steps instead of continuous time?
  * To ensure the system state is stabilized.

![](/files/-MIQ1d2q0kU2-R0i-SxY)

## Flip Flops

![](/files/-MIQ1vdvsTsYHbm5cjdR)

![Little triangle means chip is dependent on time, sequential, has state](/files/-MIQ2dLxE-NrFj8M7Tj3)

* Implementation of the D Flip Flop
  * in this course: it is a primitive
  * in physical implementations, it may be built from actual Nand gates

![](/files/-MIQ37nqiy4LjSewGG0i)

![](/files/-MIQ45pWHZeunrqqgfOh)

* What are the differences between the DFF chip and the Bit chip?
  * DFF always stores the “in” bit, while Bit only stores it if “load” is set to 1.
  * DFF can store information for one time unit only, while Bit can store it for many cycles.

![](/files/-MIQ4vcN7BPgqM-NZD62)

## Memory Units

![](/files/-MIQ6Y6SZlGVKKggP8xX)

![](/files/-MIQWOsm3f-Pm_xMFUT1)

Current value of a register is always being outputted.

![](/files/-MIQYAZMF5m-2rA-JB3I)

* What is the difference between a register’s width and a register’s address?
  * Width is the amount of data a single register holds, address is the location of the register within a larger chip.

![](/files/-MIQYaXlWhUXeGvBzL5d)

![](/files/-MIQYXonjhW8kDrT-nLc)

![](/files/-MIQZJKfAW02C1rPDR7j)

## Counters

![](/files/-MIQZl4yEwJ4oYmQ0nye)

![](/files/-MIQ_4_cxZGhDl8GxpgX)

## Project 3 Overview

![](/files/-MIQ_Q-M4m8KVIc9GiHy)

![16 bit register can be built from multiple 1-bit registers](/files/-MIQ_cXXI5RcfNG8pR_G)

![](/files/-MIQcJ6vgK27TYiRk_66)

![](/files/-MIQfFR-3GqzjCvwSeg5)

![](/files/-MIQn8JAxtqNqaXeCpZa)
