KAHIBARO Bookshelves
Discord Login Register

9.2.4.2. Logic Gates

Basic idea

Logic gates are the building blocks of digital electronics. They take one or more input signals and produce one output signal according to a simple rule. In digital systems, each signal is treated as having one of two states, usually called 0 and 1. A logic gate decides what output to give for every possible combination of these input states.

You can think of a logic gate as an electronic decision maker. If the inputs meet a certain condition, the output becomes 1. If not, the output becomes 0. These simple decisions are what allow computers, calculators, phones, and control systems to work.

Binary logic and truth tables

Because digital signals use only two values, logic gates are described using binary logic. The behavior of a gate is usually shown with a truth table. A truth table lists all possible input combinations and the corresponding output.

For a gate with one input, there are $2^1 = 2$ possible input states. For a gate with two inputs, there are $2^2 = 4$ possible input states.

Here is a table for the most common gates.

GateInputsOutput rule
NOT1Reverses the input
AND2Output is 1 only if both inputs are 1
OR2Output is 1 if at least one input is 1
NAND2Opposite of AND
NOR2Opposite of OR
XOR2Output is 1 if the inputs are different
XNOR2Output is 1 if the inputs are the same

NOT gate

The NOT gate has only one input. It produces the opposite value at the output. If the input is 1, the output is 0. If the input is 0, the output is 1. This operation is called inversion.

Input $A$Output $\lnot A$
01
10

In words, the NOT gate answers the question, "Is the input not true?"

Important rule for a NOT gate:
$$\text{Output} = \lnot A$$
A NOT gate always flips 0 to 1 and 1 to 0.

AND gate

The AND gate has two inputs, often called $A$ and $B$. Its output is 1 only when both inputs are 1. In every other case, the output is 0.

$A$$B$$A \land B$
000
010
100
111

This gate is useful when two conditions must both be satisfied. For example, a machine may run only if a power switch is on and a safety switch is closed.

Important rule for an AND gate:
$$\text{Output} = A \land B$$
The output is 1 only for $A=1$ and $B=1$.

OR gate

The OR gate also has two inputs. Its output is 1 if at least one input is 1. The only time the output is 0 is when both inputs are 0.

$A$$B$$A \lor B$
000
011
101
111

This gate is useful when either one of several conditions is enough to trigger an action.

Important rule for an OR gate:
$$\text{Output} = A \lor B$$
The output is 0 only when both inputs are 0.

NAND gate

A NAND gate is a combination of NOT and AND. It gives the opposite output of an AND gate. So it is 0 only when both inputs are 1. In all other cases, it is 1.

$A$$B$$\lnot(A \land B)$
001
011
101
110

The NAND gate is very important in electronics because any logical operation can be built using only NAND gates.

Important rule for a NAND gate:
$$\text{Output} = \lnot(A \land B)$$
A NAND gate is the inverse of an AND gate.

NOR gate

A NOR gate is the opposite of an OR gate. It gives 1 only when both inputs are 0. If either input is 1, the output becomes 0.

$A$$B$$\lnot(A \lor B)$
001
010
100
110

Like the NAND gate, the NOR gate is also universal, meaning all logic functions can be built from NOR gates alone.

Important rule for a NOR gate:
$$\text{Output} = \lnot(A \lor B)$$
A NOR gate is the inverse of an OR gate.

XOR gate

XOR means exclusive OR. Its output is 1 when the two inputs are different. If the inputs are the same, the output is 0.

$A$$B$$A \oplus B$
000
011
101
110

The XOR gate is useful for comparing bits and for arithmetic circuits such as adders.

Important rule for an XOR gate:
$$\text{Output} = A \oplus B$$
The output is 1 only when the inputs are different.

XNOR gate

XNOR is the opposite of XOR. Its output is 1 when the inputs are the same, and 0 when they are different.

$A$$B$$\lnot(A \oplus B)$
001
010
100
111

This gate is useful when checking whether two binary values match.

Important rule for an XNOR gate:
$$\text{Output} = \lnot(A \oplus B)$$
The output is 1 when both inputs are equal.

Gate symbols and signal flow

In circuit diagrams, logic gates are shown with standard symbols. Inputs are usually drawn on the left and the output on the right. A small circle on the output side usually means inversion, which means a NOT operation is included.

For example, an AND gate with a small output circle becomes a NAND gate. An OR gate with a small output circle becomes a NOR gate.

Basic idea of signal flow through a logic gate

Combining gates

Single gates are simple, but when gates are connected together, they can perform much more complicated tasks. One gate's output can become another gate's input. In this way, larger digital circuits are built from smaller logical steps.

Suppose we want an output that is 1 only when either $A$ or $B$ is 1, and also a control signal $C$ is 1. One possible expression is

$$Y = (A \lor B) \land C$$

This means first apply an OR gate to $A$ and $B$, then feed that result into an AND gate together with $C$.

Combining an OR gate and an AND gate

Universal gates

Some gates are especially powerful because they can be used to build all other gates. These are called universal gates. NAND and NOR are the two standard universal gates.

For example, a NOT gate can be made from a NAND gate by connecting both inputs together:

$$\lnot A = A \text{ NAND } A$$

Similarly, an AND gate can be made by taking the NAND result and inverting it:

$$A \land B = \lnot(A \text{ NAND } B)$$

This is important in practical electronics because a whole circuit can sometimes be built using only one type of gate, which simplifies design and manufacturing.

Key fact:
NAND and NOR are universal gates.
Any digital logic function can be built from only NAND gates, or only NOR gates.

Logic levels and real voltages

Although logic gates are described using the abstract values 0 and 1, real electronic circuits use voltages. A low voltage represents logic 0, and a high voltage represents logic 1. The exact voltage ranges depend on the technology being used.

So a logic gate is really an electronic device that reads input voltages, interprets them as binary states, and produces an output voltage representing the logical result.

This means logic gates connect abstract logic with physical electronics.

Practical meaning

Logic gates are used whenever a system must make decisions based on signals. A safety alarm might use an OR gate so that any one of several sensors can trigger the alarm. A machine interlock might use an AND gate so that several safe conditions must all be true before the machine starts. A comparator can use XOR or XNOR behavior to test whether two bits match.

Even very complex digital devices are built from these basic ideas. At the lowest level, many circuits reduce to combinations of NOT, AND, OR, and related gates.

Summary of gate behavior

The main gates can be compared compactly in one truth table.

$A$$B$ANDORNANDNORXORXNOR
00001101
01011010
10011010
11110001

Core ideas to remember:
$$\lnot A$$ is NOT
$$A \land B$$ is AND
$$A \lor B$$ is OR
$$\lnot(A \land B)$$ is NAND
$$\lnot(A \lor B)$$ is NOR
$$A \oplus B$$ is XOR
$$\lnot(A \oplus B)$$ is XNOR
Logic gates take binary inputs and produce binary outputs according to fixed rules.

Views: 0

Comments

Please login to add a comment.

Don't have an account? Register now!