Arithmetic Logic Unit

An Arithmetic Logic Unit (ALU) is the core calculation component of any Minecraft redstone computer, capable of performing both mathematical operations (addition and subtraction) and bitwise logic (AND, OR, XOR, and their inverses). This tutorial covers a standard ripple-carry concept before showing you how to build a much faster, vertically stackable carry-cancel ALU.

Redstone ComputingExpertJava Edition
Arithmetic Logic Unit video tutorial

Video: Arithmetic Logic Units with Redstone by iPlayGames

How to build it

  1. Build the Input Inverters

    For each bit of your ALU, start by building two comparator-based XOR gates for your A and B inputs. Connect a shared control line to the second input of each gate so you can invert A or invert B on command.

  2. Construct the Core XOR/OR Gate

    Feed the outputs of your input stages into a central comparator XOR gate. Add an extra comparator line next to it that forces the gate to act as an OR gate when toggled, while simultaneously canceling out the AND output.

  3. Extract the AND Output

    Branch off the front of the core XOR gate into a comparator in subtract mode. When either A or B is powered, the line receives signal, unless the XOR gate's output is active and subtracts it—leaving an output only when both A and B are active (A AND B).

  4. Build the Carry-Cancel Tower

    At the output of the AND gate and the inverted XOR gate, construct a vertical carry tower so the bits can stack every two blocks vertically. Wire the AND output to generate a carry and the NOT output to cancel incoming carries.

  5. Shift the Carry with Glass

    Because a carry generated by one bit applies to the next bit up, use a glass block ladder to shift the calculated carry line two blocks upward into the next bit's slice without interfering with the current bit's wiring.

  6. Add the Final Output XOR

    Build one more XOR gate at the end of each bit slice. Feed the first stage's A XOR B result into one side, and the shifted carry line into the other side to produce your final bit output.

  7. Wire the Control Lines

    Stack your 2-block-tall bit slices vertically for as many bits as you need (e.g., 4 or 8 bits). Connect vertical control towers across all bits for: Invert A, Invert B, OR (disable carries), Carry-In, and Flood Carry (invert final output).

How it works

This ALU uses the carry-cancel addition method combined with De Morgan's laws to reuse the same hardware for both math and logic:

  • Comparator XOR & AND: A comparator in subtract mode comparing inputs A and B creates an XOR gate. A parallel line is powered whenever A or B is on, and the XOR output subtracts from it—meaning a signal only passes through when both A and B are on (creating an AND gate).
  • Addition & Subtraction: With all logic control lines off, the circuit acts as a full adder. The first XOR calculates the half-add, the AND gate generates a carry up the glass tower to the next bit, and the final XOR adds the carry. To subtract (A - B), you invert input B and turn on Carry-In (two's complement).
  • Logic Operations (AND, OR, NAND, NOR, XOR): Turning on the OR control line disables the AND carry generation so bits no longer affect each other. By selectively toggling Invert A, Invert B, and Flood Carry (which inverts the final output XOR), you can simulate any logic gate. For example, inverting both A and B into an OR gate and inverting the output via Flood Carry yields A AND B.

Tips & variations

  • Preventing Comparator Loops: When routing the side inputs of subtract-mode comparators in tight 2-block vertical slices, make sure the output dust does not loop back into its own side input, which will create an unintended comparator clock.
  • How to Run XOR Logic: To perform a bitwise XOR on the carry-cancel ALU, leave the circuit in addition mode, turn on Flood Carry, and turn on Invert B.
  • Vertical Stacking: Every bit slice is 2 blocks tall. Always use transparent blocks like glass to move signals vertically between bits so you do not accidentally cut off redstone dust lines.

Frequently asked questions

What is the difference between the two ALUs shown in the video?
The first design builds separate outputs for AND, XOR, and Addition and cancels out the unused ones. The second design is a carry-cancel ALU that reuses the adder's internal gates to perform all logic operations, making it much faster and more compact.
How do you subtract numbers on this ALU?
Use two's complement subtraction: input your numbers into A and B, toggle the 'Invert B' control line on, and turn on the initial 'Carry-In' for the first bit.
Why do we disable carries during logic operations?
In arithmetic, adding 1 + 1 carries over to the next bit. In bitwise logic (like AND or OR), each bit must be calculated independently without overflowing into adjacent bits.

Components used

More alu / cpu part