Clever Quest Lab ← Labs

Logic Gate Simulator

Build a circuit and watch the logic work.

Examples

Loading replaces the workspace. Undo brings your circuit back.

Nothing selected

Mouse: drag a part from the palette, drag from pin to pin to wire, click a switch to flip it, drag the background to pan. Keyboard: Tab steps through parts and pins, arrow keys move a part, Space flips a switch, Enter on a pin starts or ends a wire, Delete removes, Esc cancels.

Tap a palette item, then tap the workspace to place it. Tap a pin, then a second pin to connect them. Tap a switch to flip it. Drag a part to move it, drag the background to pan.

Thick green = 1, thin grey = 0, dashed orange with “?” = unstable. A dashed pin marked “n/c” is not connected and reads 0.

Truth table

Boolean expressions

    ¬ NOT · ∧ AND · ∨ OR · ⊕ XOR

    Build from expression

    Operators: ! not, & and, | or, ^ xor, -> implies, <-> iff, or the words not, and, or, xor. T, F, 1 and 0 mean true and false, so name your inputs with other letters.

    Clock

    Flips every Clock part on and off at this rate. It stays off until you start it.

    Save and share

    The circuit is saved in this browser automatically. A share link stores the whole circuit in the address.

    How to use it

    The page opens with a half adder already wired up. Flip the two switches on the left and watch the wires, the lamps and the marked row of the truth table change together. To build your own circuit, add switches (inputs), gates and lamps (outputs) from the palette, then join an output pin on the right of one part to an input pin on the left of another. An input pin takes one wire; an output pin can feed any number of inputs. The Examples list loads six ready circuits, and “Build from expression” turns a formula such as (A & B) | !C into gates. The circuit is saved in this browser; “Share link” puts it into a web address.

    Controls

    How it works

    A logic gate takes signals that are either 0 or 1 and produces one output. AND gives 1 only when both inputs are 1. OR gives 1 when at least one input is 1. NOT flips its input. XOR gives 1 when the two inputs differ. NAND, NOR and XNOR are AND, OR and XOR followed by NOT; the small circle on the output means “inverted”.

    A truth table lists every combination of inputs, one per row, with the outputs the circuit gives. With n inputs there are 2n rows: 4 for two switches and 64 for six, the largest table this page prints. The panel also shows a Boolean expression for each lamp, read from the wiring. To work on formulas alone, use the truth table generator, the Boolean algebra simplifier or the Karnaugh map solver.

    Half adder: S = A ⊕ B,   C = A ∧ B
    Full adder: S = A ⊕ B ⊕ Cin,   Cout = (A ∧ B) ∨ (Cin ∧ (A ⊕ B))

    The sum bit is 1 when exactly one input is 1 (XOR); the carry is 1 when both are (AND). A full adder also accepts the carry from the column to its right, so a chain of full adders adds binary numbers of any length.

    NAND is called universal because every other gate can be made from it. Join both inputs of a NAND and you get NOT. A NOT after a NAND is AND. By De Morgan’s law, ¬(A ∧ B) = ¬A ∨ ¬B, so a NAND fed with inverted inputs is OR. NOR is universal in the same way.

    All of this is combinational logic: the outputs depend only on the present inputs. Feed an output back to an earlier input and the circuit becomes sequential. In the SR latch, two NOR gates feed each other. A brief 1 on S sets Q to 1, and the loop keeps it there after S returns to 0; a 1 on R resets it. That is one bit of memory. If the signals do not settle within 200 evaluation passes, as with a NOT gate wired to itself, the circuit is reported as oscillating.

    Things to try

    Frequently asked questions

    Why do some pins say “n/c”?

    It means “not connected”. An input without a wire reads as 0, so the gate still gives an output, but probably not the one you wanted.

    Why is there no truth table for my circuit?

    Either it has more than six inputs, which would need more than 64 rows, or a feedback loop reaches a lamp. With feedback the outputs depend on history, so the page shows a log of recent states instead.

    What does “oscillating” mean?

    The circuit has no stable state: every pass changes at least one signal. A real circuit of this kind keeps flipping as fast as its gates allow.

    Does the simulator model gate delays?

    No. The gates here are ideal. Real gates need a short time to switch, which causes brief glitches that are not shown. In a real SR latch, releasing S and R at the same moment gives an unpredictable result; here the outcome is always the same.

    More free games and simulators