Circuit
Gates
Depth gates on the longest path

    Symbols

    More about logic gates

    Logic circuit simulator

    Every computer is built from a handful of tiny decision makers called logic gates. Each one looks at one or two signals that are either 0 or 1 and answers with a 0 or a 1, by a rule as simple as: 1 only if both inputs are 1. Wire a few of them together and they can add numbers, choose between signals or remember a bit. In this simulator you place gates on a board, join them with wires, flip the inputs and watch the signals travel. The truth table and the formula of each output follow along as you build. Choose an example or build your own circuit. Click a part in the row above the board to add it, drag it into place, and drag from an output pin (on the right of a part) to an input pin (on the left) to join them with a wire; you can also tap one pin and then the other. Click an input to switch it between 0 and 1 and watch the signal run through the gates: a green wire carries a 1. Select a part or a wire and press Delete to remove it, drag the end of a wire off its pin to take it away, drag the background to move the view and use the buttons in the corner to zoom. The truth table lists the outputs for every combination of inputs: click a row to set the inputs to it.

    How it works

    1. Choose an example such as the half adder, or click the parts above the board to add inputs, gates and outputs.
    2. Drag from an output pin to an input pin to wire two parts together, and drag the parts to arrange the circuit.
    3. Click the inputs to switch them between 0 and 1, and read the truth table and the formula of each output.

    Seven gates

    An AND gate gives 1 only when both inputs are 1, an OR gate when at least one is, and a NOT gate turns 0 into 1 and 1 into 0. XOR gives 1 when exactly one input is 1, which makes it the gate that adds two bits. NAND, NOR and XNOR are AND, OR and XOR followed by a NOT, drawn as a small circle on the output. NAND alone is enough to build every other gate, and so is NOR: try the example that makes an XOR out of four NAND gates and compare its truth table with that of a real XOR.

    From adding to remembering

    A half adder adds two bits with one XOR gate for the sum and one AND gate for the carry. A full adder also takes the carry of the column before it, and a chain of full adders adds numbers of any length. These circuits are combinational: their outputs depend only on the inputs at that moment, so a truth table says everything about them. Feed an output back into the circuit and something new happens: it can remember. Two NOR gates that feed each other form an SR latch, the simplest memory, and two latches in a row make a flip-flop that takes a new value only when the clock ticks.

    Frequently asked questions

    What is a logic gate?

    A small electronic circuit with one or two inputs and one output, each either 0 (a low voltage) or 1 (a high voltage). The output follows from the inputs by a fixed rule, such as AND, OR or NOT. In a real chip a gate is made of a few transistors, and a modern processor contains billions of them.

    Why are NAND and NOR called universal gates?

    Because any logic circuit can be built from NAND gates alone, or from NOR gates alone. A NAND with both inputs joined is a NOT, a NAND followed by a NOT is an AND, and NANDs fed with inverted inputs make an OR. Open the example XOR from NAND gates to see four NANDs do the work of an XOR.

    Why does my circuit have no truth table?

    A truth table lists the outputs for every combination of inputs, which only works when the outputs depend on nothing else. A circuit with a loop, where an output finds its way back to an earlier input, also depends on its own past: a latch answers the same inputs differently depending on what it has stored. Such circuits are called sequential, and the simulator shows them as circuits with memory. The table is also left out when there are more than six inputs, which would take more than 64 rows.

    What does oscillating mean?

    That the signals never come to rest. The simplest case is a ring of three NOT gates: whatever value a wire has, one trip round the ring turns it into its opposite, so the circuit keeps flipping. Real chips use exactly such rings as simple clock generators. A ring of two NOT gates is stable instead, and is the heart of a memory cell.

    What is the difference between the ANSI and the IEC symbols?

    They are two ways of drawing the same gates. The ANSI symbols, usual in the United States and in most textbooks, give every gate its own shape: a D for AND, a curved shield for OR, a triangle for NOT. The IEC symbols, common in European standards, are rectangles with a sign inside: & for AND, ≥1 for OR, =1 for XOR and 1 for NOT. In both, a small circle on the output means that the result is inverted.

    Logic Circuit Simulator: how do I record a video?

    Press the red Record button in the playback bar: it films what the stage shows. Press it again to stop, and the video is saved to your device. Recording is free; you only need to sign in. Without a subscription the video carries a small PictorX logo in a corner. The button beside Record opens the video options: the shape (as shown, square, story 9:16 or wide 16:9), the length (until you stop, or 5, 10, 15 or 30 seconds for social media) and the file: MP4, WebM or an animated GIF. You can add one of three music tracks: calm, bright or beat.

    Ready to try it?

    Open PictorX in your browser — no install, no credit card required to start.

    Go to Editor