Computer Data Memory

Data memory acts as a large expandable register bank (RAM) that lets an 8-bit redstone computer store and retrieve far more values than its main register file can hold alone. By wiring multiplexers between your ALU, register file, and data memory, your computer can execute Load (LOD) and Store (STR) instructions using calculated memory addresses.

Redstone ComputingExpertJava Edition
Computer Data Memory video tutorial

Video: Finishing Our Redstone Computer - LRCWV Episode 9 by Professorvatcraft

How to build it

  1. Position the Data Memory Module

    Build or paste a multi-address data memory array next to your computer's ALU and register file. Ensure the module has clearly separated buses for data input (write), address selection, data output (read), a read/write control line, and a clock input.

  2. Build the Offset Multiplexer Before the ALU

    Install a multiplexer on the second input bus of your ALU. Wire it so it can switch between the standard Register B output and the 4-bit immediate offset value coming from the instruction decoder.

  3. Route ALU Output to the Memory Address Bus

    Tap a bus off the ALU output and run it into the address decoder input of the data memory. During memory operations, the ALU adds Register A and the 4-bit offset to calculate the target memory address.

  4. Connect the Data Input Bus for Store Operations

    Run a data bus from the register file output into the write-data input of the data memory so the value held in Register B can be written into the selected memory address.

  5. Add Multiplexers for Register File Write-Back

    Place multiplexers along the return bus leading back to the register file's write-data input. Wire them to choose between the normal ALU calculation result and the read output bus coming from the data memory.

  6. Adjust the Data Memory Read Gate

    If your data memory design has a read-disable gate that blocks output signals due to timing delays in your computer, remove the blocking gate so the memory outputs its addressed value continuously to the return multiplexer.

  7. Wire the Load and Store Control Lines

    Add two new instruction lines on your control unit decoder for Load (LOD) and Store (STR). Connect both lines to enable the register file and trigger a shared control line that flips your new multiplexers into memory mode.

  8. Connect the Read/Write Toggle Line

    Run a dedicated control wire from only the Store (STR) instruction line to the read/write enable input of the data memory. Build vertical slime block and sticky piston towers to carry the control signals cleanly down into the memory module.

  9. Run a Test Program

    Program your instruction memory to load the number 1 into Register 1, store Register 1 into memory address 0 (Register 0 + offset 0), load memory address 0 into Register 2, and halt. Pulse the main clock to verify that Register 2 receives the value 1.

How it works

Integrating data memory into a redstone CPU relies on two instructions that both use 4-bit operands (Register A, Register B, and an Offset):

  • Address Calculation: When either LOD or STR is decoded, the control unit switches the input multiplexer at the ALU. Instead of comparing two registers, the ALU adds the value inside Register A to the 4-bit Offset from the instruction. The resulting sum travels down the bus to select the exact address in the data memory.
  • Store (STR): Both the shared memory-mode line and the dedicated write line turn on. The data from Register B is routed to the data memory's write port and saved into the calculated address when the clock pulses.
  • Load (LOD): Only the shared memory-mode line activates, leaving the data memory in read mode. The data stored at the calculated address flows out of the memory, passes through the write-back multiplexer (bypassing the direct ALU result), and gets written into Register B in the main register file.

Tips & variations

  • Use Schematic Mods: Because data memory arrays are massive stacks of registers, building one block-by-block is tedious. Using a schematic mod like Litematica to paste the memory bank in place saves hours of repetitive work.
  • Vertical Signal Transmission: Use sticky pistons pushing slime block columns with redstone blocks to send control signals straight up or down instantly without large repeater staircases.
  • Watch Signal Timing: Removing the read-enable gate on the data memory keeps the read bus live at all times, which prevents slow control lines from missing the clock window during a LOD instruction.

Frequently asked questions

What is the difference between a register file and data memory?
A register file holds a small number of fast-access values directly wired to the ALU, while data memory acts like RAM—storing many more addresses that are accessed using Load and Store instructions.
Why does the data memory use the ALU during Load and Store?
The ALU is used to add the base address held in Register A to the 4-bit offset encoded in the instruction, allowing the computer to dynamically calculate which memory address to read or write.
What is the difference between the Load and Store control lines?
Both instructions flip the multiplexers to route address and memory buses, but only the Store instruction powers the memory's write-enable line so data is overwritten.

Components used

More computer