> 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)


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://wiki.zacheller.dev/hardware/nand2tetris/memory.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
