
Video: Arithmetic Logic Units with Redstone by iPlayGames
How to build it
- 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.
- 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.
- 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).
- 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.
- 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.
- 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.
- 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
ANDgate). - 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.





