worldngayon students

Logic gates simulator

Add input switches, gates and output lamps, then drag from a gate’s output dot to another gate’s input dot to wire them. Tap a switch to change it between 0 and 1 and watch the signals flow (green wires are 1). The truth table and Boolean expression update as you build.

Add

Examples:

Drag empty space to move around. Select a gate or wire and press Delete to remove it.

The logic gates

GateOutput is 1 when…ExpressionA=0,B=00,11,01,1
ANDboth inputs are 1A · B0001
ORat least one input is 1A + B0111
NOTthe input is 0A′0 → 1, 1 → 0
NANDnot both are 1(A · B)′1110
NORboth are 0(A + B)′1000
XORthe inputs are differentA ⊕ B0110
XNORthe inputs are the same(A ⊕ B)′1001

Adding binary numbers

A half adder adds two bits: the XOR gate gives the sum bit and the AND gate gives the carry (1 + 1 = 10 in binary, so sum 0, carry 1). A full adder also adds a carry coming in from the column before, so full adders can be chained to add numbers of any length. This is how a computer’s arithmetic unit adds.

Universal gates

NAND and NOR are called universal gates: any logic circuit can be built from NAND gates alone (or NOR gates alone). Load the XOR from NAND example to see four NAND gates doing the job of an XOR gate.

Memory from feedback

Wire the output of a gate back into the input of an earlier gate and the circuit can remember. The SR latch made from two NOR gates stores one bit: set S to 1 and back to 0 and Q stays 1; set R to 1 and Q goes back to 0. This is the starting point for flip-flops, registers and computer memory.

Questions students ask

What is a truth table?

A table listing every possible combination of inputs and the output each one gives. With n inputs there are 2ⁿ rows. The simulator builds it for you from your circuit.

What does A′ mean?

NOT A, the opposite of A. Some books write it with a bar over the letter or as ¬A. · means AND, + means OR and ⊕ means XOR.

Why does my circuit say it oscillates?

A gate is feeding back into itself in a way that can never settle, for example a NOT gate whose output is wired to its own input: 0 becomes 1, which becomes 0, and so on.

More engineering and electricity

Know someone who needs this?

It's free for every student. Send it to your class group chat.

Updated · Free, no sign-up ·

Connected tools

The same idea from another angle, across the site.