Reference

The logic gates

A gate takes one or two inputs, each on (1) or off (0), and gives one output. Six gates build everything a computer does. The little table under each gate is its truth table — it shows the output for every possible input. Back to the lab anytime: Open the circuit lab →

  • AND &

    On only when BOTH inputs are on. Think "a and b are both true".

    about
    000
    100
    010
    111
  • OR ≥1

    On when AT LEAST ONE input is on. Off only when both are off.

    about
    000
    101
    011
    111
  • NOT ¬

    Flips one input: on becomes off, off becomes on. The only one-input gate.

    about
    01
    10
  • XOR =1

    On when the two inputs are DIFFERENT (exactly one is on). This is the "sum" bit of adding.

    about
    000
    101
    011
    110
  • NAND

    AND, then flipped — off only when both inputs are on. Every other gate can be built from just NAND.

    about
    001
    101
    011
    110
  • NOR ≥1̄

    OR, then flipped — on only when both inputs are off.

    about
    001
    100
    010
    110

Adding two bits needs just two gates: the sum is a XOR b and the carry is a AND b. Chain those and you have built an adder — the heart of a CPU. Try a challenge →