Logic Gates

Fundamental building blocks of digital circuits: AND, OR, NOT, XOR gates and their truth tables.

Logic Gates Playground

Drag gates, connect them, and observe outputs.

Palette
Input
Output
AND
OR
NOT
NAND
NOR
XOR
XNOR
Tip: Click an output port, then an input port to connect. Click an occupied input to remove its wire.
Canvas

The Building Blocks of the Digital World

At the heart of every digital device-from the simplest calculator to the most powerful supercomputer-lie millions or even billions of tiny electronic switches called logic gates. These are the fundamental building blocks of digital circuits. A logic gate is a device that performs a basic logical function based on . It takes one or more binary inputs (0s and 1s) and produces a single binary output based on a specific rule.

Understanding logic gates is understanding the very language of computers. By combining these simple gates in various ways, engineers can build complex circuits that perform arithmetic, store data, and make decisions.

Fundamental Logic Gates

There are three primary logic gates from which all others can be derived. Let's explore them one by one.

1. The AND Gate

The AND gate is a logical multiplier. Its output is '1' (True) only if all of its inputs are '1'. If any input is '0', the output is '0'. Think of it as a series circuit with two switches: the light bulb only turns on if both switches are closed.

Bramka AND

ANSI Symbol for AND gate

Truth Table (A AND B)

Input AInput BOutput Y
000
010
100
111

Logical Expression: Y=Aâ‹…BY = A \cdot B or Y=ABY = AB


2. The OR Gate

The OR gate is a logical adder. Its output is '1' (True) if any of its inputs are '1'. The output is '0' only when all inputs are '0'. Think of it as a parallel circuit: the light bulb turns on if either switch (or both) is closed.

Bramka OR

ANSI Symbol for OR gate

Truth Table (A OR B)

Input AInput BOutput Y
000
011
101
111

Logical Expression: Y=A+BY = A + B


3. The NOT Gate (Inverter)

The NOT gate is the simplest gate. It has only one input and one output. Its function is to invert the input signal. If the input is '1', the output is '0', and if the input is '0', the output is '1'. It simply flips the state.

Bramka NOT

ANSI Symbol for NOT gate

Truth Table (NOT A)

Input AOutput Y
01
10

Logical Expression: Y=A‾Y = \overline{A} or Y=¬AY = \neg A

Universal Gates: NAND and NOR

While AND, OR, and NOT are fundamental, there are two other gates called "universal gates" because any other logical function can be created by combining only NAND gates, or only NOR gates.

4. The NAND Gate (NOT-AND)

The NAND gate is simply an AND gate followed by a NOT gate. Its output is '0' only if all of its inputs are '1'. Otherwise, the output is '1'.

Bramka NAND

ANSI Symbol for NAND gate

Truth Table (A NAND B)

ABY
001
011
101
110

Logical Expression: Y=A⋅B‾Y = \overline{A \cdot B}


5. The NOR Gate (NOT-OR)

The NOR gate is an OR gate followed by a NOT gate. Its output is '1' only when all inputs are '0'. If any input is '1', the output is '0'.

Bramka NOR

ANSI Symbol for NOR gate

Truth Table (A NOR B)

ABY
001
010
100
110

Logical Expression: Y=A+B‾Y = \overline{A + B}

Exclusive Gates: XOR and XNOR

These gates perform more specialized logical functions, commonly used in circuits that perform arithmetic and data checking.

6. The XOR Gate (Exclusive OR)

The XOR gate's output is '1' only if the inputs are different. If the inputs are the same (both '0' or both '1'), the output is '0'. It's a key component in adders and parity checkers.

Bramka XOR

ANSI Symbol for XOR gate

Truth Table (A XOR B)

ABY
000
011
101
110

Logical Expression: Y=A⊕BY = A \oplus B


7. The XNOR Gate (Exclusive NOR)

The XNOR gate is an XOR gate followed by a NOT gate. Its output is '1' only if the inputs are the same. It functions as a logical equality checker.

Bramka XNOR

ANSI Symbol for XNOR gate

Truth Table (A XNOR B)

ABY
001
010
100
111

Logical Expression: Y=A⊕B‾Y = \overline{A \oplus B}

    Logic Gates | Teleinf Edu