EN

Logic gate simulator

Build a circuit, toggle the inputs and get its truth table and equation

Simulator

Circuit
Gates

Each gate can take the variables or the output of an earlier gate as input. Tick «Output» on the gates you want to see in the truth table.

Inputs (click to switch between 0 and 1, also on the diagram):

Truth table

Expression of each output

The basic logic gates

A logic gate is a circuit that gives a two-level output (0 or 1, low or high) depending on its inputs. With just three operations, AND (product), OR (sum) and NOT (negation), any logic function can be built; the other gates are combinations of these that are manufactured for convenience. Each card shows the American symbol (ANSI/IEEE 91, used in almost every textbook) and the rectangular IEC 60617 symbol, common in European drawings.

NAND and NOR: universal gates

With NAND gates alone (or NOR gates alone) any other gate can be built. An inverter is a NAND with both inputs tied together; an AND is a NAND followed by an inverter; an OR is obtained by inverting the inputs of a NAND, by De Morgan's law:

\[ \overline{A\cdot B} = \overline{A} + \overline{B} \qquad\qquad \overline{A + B} = \overline{A}\cdot\overline{B} \]

That is why many integrated circuits and chip cells are based on NAND: in CMOS technology it is the fastest and smallest gate. Load the «XOR built only from NAND gates» example to see how four NANDs make an XOR.

How to use the simulator

  1. Choose an example or the number of variables (A to D) and build the circuit row by row: gate type, number of inputs and where each input comes from.
  2. A gate can only use outputs of earlier gates, so the circuit never has feedback (it is combinational). Circuits with memory, such as flip-flops, are covered in latches and flip-flops.
  3. Click the inputs to change their value. Green wires are at 1 and grey ones at 0.
  4. Below you get the truth table, the expression formed by the circuit as built and its minimal form as a sum of products, computed with the Quine-McCluskey method. If they differ, the circuit can be simplified.

Logic gate integrated circuits

Function74HC seriesCMOS 4000 seriesContents
NAND74HC00CD40114 two-input gates
NOR74HC02CD40014 two-input gates
NOT74HC04CD40696 inverters
AND74HC08CD40814 two-input gates
OR74HC32CD40714 two-input gates
XOR74HC86CD40704 two-input gates
Schmitt inverter74HC14CD401066 inverters with hysteresis

Note: the 74HC02 (NOR) pinout differs from the other two-input parts, and the 4000 series pinouts do not match the 74HC ones either. Always tie unused inputs to 0 or 1 (whichever does not alter the function): a floating CMOS input can oscillate, draw current and heat the chip. To mix families or voltages, see logic level shifting.

Related: Boolean algebra, Karnaugh map, multiplexers, BCD to 7-segment decoder and ladder simulator.