REDSTONEPEDIA › Circuits › Logic gates
Logic gate
A XOR B (one, not both) · 15 blocks
It has two inputs, A and B. The output is on when exactly one of A and B is on, not both.
reacts in 2 ticks (0.1 s) · made of comparator, redstone wire · fits in 4×4×2
Try it
Use the A and B buttons under the view to drive the inputs: the box marked OUT turns red while the output is on. Press play under the view to watch a demo on a loop; touch any other control to take over.
How this design does it: XOR gate, 15 blocks, 2 ticks, glitch-free: a dust lies on each input block, and two subtract comparators stand in a square with them, so each dust is one comparator's back and the other's side.
Build it
Download .litematic Download the design as text
The .litematic opens in Litematica (Minecraft 26.3): every block of the design in one region. The text file is the same build written as plain text, block by block.
Blocks used: comparator redstone wire stone
Details: how it works, measurements and properties
In depth
A logic gate: the output depends only on the inputs right now. XOR: the output is on while exactly one of A and B is on (not both).
| A | B | OUT |
|---|---|---|
| off | off | off |
| off | on | on |
| on | off | on |
| on | on | off |
The output settles 2 ticks (0.1 s) after an input changes.
How to try it
Press play under the view to watch the demo on a loop (the badge reads demo with the step it is on; the same sequence is drawn as a timing diagram below). Touch any control to stop it and try the circuit yourself.
To try it: tap the A button of the bar (or the cell tagged A) to turn that input on or off (it powers the cell with a redstone block); tap the B button of the bar (or the cell tagged B) to turn that input on or off (it powers the cell with a redstone block).
Inputs are tagged in lime; the output is tagged OUT: the redstone lamp in that cell (the view adds it to show the output) lights while the output is on (the output strip by the demo badge shows its last 40 game ticks, 2 seconds). Drag to look around, pinch or scroll to zoom, step one game tick at a time with the step button.
Inputs and output over time
The inputs follow this schedule (the 3D view's demo plays the same). Lime: an input is on; orange: the output is on (taller = a stronger signal, 1 to 15). Time runs left to right in game ticks (20 ticks = 1 s).
Swipe the diagram sideways: the whole sequence lasts 281 ticks (14.05 s).
Step by step (13 lines)
00 (rest): output 0 -> 01: output 1 after 2 ticks (0.1 s) -> 00: output 0 after 2 ticks (0.1 s) -> 10: output 1 after 2 ticks (0.1 s) -> 00: output 0 after 2 ticks (0.1 s) -> 11: output 0 -> 01: output 1 after 2 ticks (0.1 s) -> 10: output 1 -> 01: output 1 -> 11: output 0 after 2 ticks (0.1 s) -> 10: output 1 after 2 ticks (0.1 s) -> 11: output 0 after 2 ticks (0.1 s) -> 00: output 0
Measurements
| metric | value | what it means |
|---|---|---|
| function | xor | the logic function the truth table names |
| latency | 2 ticks (0.1 s) | the worst time from an input change to the output's change |
Notes from its designer
XOR gate, 15 blocks, 2 ticks, glitch-free: a dust lies on each input block, and two subtract comparators stand in a square with them, so each dust is one comparator's back and the other's side. The comparator reading A's dust from behind has B's dust at its side and lights only when A is on alone; the other one, the mirror, lights only when B is on alone. The first points straight into the output; the second powers a block whose dust climbs over the square, across stones laid on the core, and lands on top of the output.
Properties
| Study | Logic gates |
|---|---|
| Kind | Logic gate |
| Blocks placed | 15 (not counting the input levers or buttons and the lamp the view adds) |
| Box | 4×4×2 (32 blocks of space) |
| Made of (the blocks that change state) | comparator, redstone wire |
| Inputs / outputs | A (repeater), B (repeater) / OUT |
| Design file | gate-xor |
The design file
Design file (25 lines)
# Logic gate: A XOR B (one, not both) · 15 blocks # https://vjeux.github.io/redstonepedia/circuits/gates/gate-xor.html name: gate-xor circuit: gate xor port input.a: 0 0 0 port input.b: 1 0 1 port output: 2 1 0 origin: -1 0 0 palette: S minecraft:stone C minecraft:comparator[facing=west,mode=subtract,powered=false] K minecraft:comparator[facing=east,mode=subtract,powered=false] d minecraft:redstone_wire[east=side,north=side,power=0,south=side,west=side] layer 0: ..S. .S.. layer 1: SdC. SKd. layer 2: dSSd d... layer 3: .dd. ....