In the previous chapter, we studied Boolean algebra as a mathematical system, learning how AND, OR, and NOT operations combine two-valued variables using well-defined laws. Boolean algebra, however, is only the theory. Logic gates are what actually bring that theory to life inside real computer hardware, turning abstract Boolean operations into physical electronic components that process real signals.
A logic gate is a basic electronic building block that takes one or more binary inputs and produces a single binary output, based on a specific logical rule. Every single digital circuit inside a computer, from the simplest calculator to the most powerful processor, is ultimately built by combining enormous numbers of these simple logic gates together in different arrangements.
In this tutorial, you will learn about the standard logic gate symbols, examine truth tables for each major gate, including AND, OR, NOT, NAND, NOR, XOR, and XNOR, and understand why NAND and NOR are often referred to as universal gates.
A logic gate physically implements one of the logical operations we studied in Boolean algebra, using electronic components such as transistors. Each gate accepts one or more input signals, where a high voltage typically represents a binary 1 and a low voltage represents a binary 0, and produces a single output signal based on the specific rule that gate follows.
Logic gates are usually drawn using standardized symbols in circuit diagrams, which makes it possible for engineers anywhere in the world to read and understand a digital circuit's design without needing to know the exact internal electronic details of how each gate is built.
The AND gate produces a high output only when every one of its inputs is high. This directly mirrors the AND operation from Boolean algebra, requiring all conditions to be true at once for the overall result to be true.
| Input A | Input B | Output (A AND B) |
|---|---|---|
| 0 | 0 | 0 |
| 0 | 1 | 0 |
| 1 | 0 | 0 |
| 1 | 1 | 1 |
Input A = video is uploaded successfully Input B = thumbnail is uploaded successfully Output = video goes live on CS Engineering Gyan only if BOTH A and B are 1
The OR gate produces a high output whenever at least one of its inputs is high. The only situation where the OR gate produces a low output is when every single one of its inputs is low.
| Input A | Input B | Output (A OR B) |
|---|---|---|
| 0 | 0 | 0 |
| 0 | 1 | 1 |
| 1 | 0 | 1 |
| 1 | 1 | 1 |
Input A = viewer clicked the bell icon Input B = viewer manually enabled notifications in settings Output = viewer receives notifications if EITHER A or B is 1
The NOT gate, also called an inverter, is the only basic gate that accepts a single input rather than two. It simply reverses whatever value is given to it, turning a 1 into a 0 and a 0 into a 1.
| Input A | Output (NOT A) |
|---|---|
| 0 | 1 |
| 1 | 0 |
Input A = video comments are enabled Output = NOT A represents whether comments are disabled
The NAND gate, short for "NOT AND," produces the exact opposite output of a regular AND gate. It outputs a low value only when every input is high, and produces a high output in every other case.
| Input A | Input B | Output (A NAND B) |
|---|---|---|
| 0 | 0 | 1 |
| 0 | 1 | 1 |
| 1 | 0 | 1 |
| 1 | 1 | 0 |
Notice that the NAND truth table is simply the AND truth table with every output value flipped, which makes sense given that NAND is essentially an AND gate immediately followed by a NOT gate.
The NOR gate, short for "NOT OR," similarly produces the exact opposite output of a regular OR gate. It outputs a high value only when every input is low, and produces a low output in every other case.
| Input A | Input B | Output (A NOR B) |
|---|---|---|
| 0 | 0 | 1 |
| 0 | 1 | 0 |
| 1 | 0 | 0 |
| 1 | 1 | 0 |
The XOR gate, short for "Exclusive OR," produces a high output only when its two inputs are different from each other. If both inputs are the same, whether both 0 or both 1, the XOR gate produces a low output.
| Input A | Input B | Output (A XOR B) |
|---|---|---|
| 0 | 0 | 0 |
| 0 | 1 | 1 |
| 1 | 0 | 1 |
| 1 | 1 | 0 |
Input A = viewer watched the video on mobile Input B = viewer watched the video on desktop Output = 1 only if the viewer used EXACTLY ONE of these two devices, not both and not neither
XOR is especially important in Computer Organization because of its close relationship with binary addition, since XOR naturally produces the correct sum bit when adding two single binary digits together, ignoring any carry.
The XNOR gate, short for "Exclusive NOR," produces the exact opposite output of an XOR gate. It outputs a high value only when both of its inputs are the same, whether both 0 or both 1, and produces a low output whenever the inputs differ.
| Input A | Input B | Output (A XNOR B) |
|---|---|---|
| 0 | 0 | 1 |
| 0 | 1 | 0 |
| 1 | 0 | 0 |
| 1 | 1 | 1 |
Because XNOR produces a high output exactly when its two inputs match, it is often described as an equality checker, useful in circuits designed to detect whether two binary values are identical.
| Gate | Number of Inputs | Produces High Output When |
|---|---|---|
| AND | Two or more | All inputs are high |
| OR | Two or more | At least one input is high |
| NOT | One | The single input is low |
| NAND | Two or more | At least one input is low |
| NOR | Two or more | All inputs are low |
| XOR | Two | The inputs differ from each other |
| XNOR | Two | The inputs match each other |
NAND and NOR gates hold a special place in digital circuit design because they are considered universal gates, meaning that either one of them, entirely on its own, can be used to construct every other basic logic gate, including AND, OR, and NOT.
This property is extremely valuable in practice, since it means an entire digital circuit can theoretically be built using nothing but NAND gates, or nothing but NOR gates, which can simplify manufacturing and reduce the variety of components a circuit design needs to rely on.
A NAND gate connected to itself: Connect both inputs of a NAND gate to the same signal, A A NAND A = NOT A This works because feeding the same value into both inputs of a NAND gate always produces the complement of that value
Step 1: Pass A and B through a NAND gate Result: A NAND B Step 2: Pass the result through a second NAND gate, connecting both of its inputs to that same result (A NAND B) NAND (A NAND B) = A AND B This works because applying NAND twice in this pattern cancels out the inversion, leaving plain AND behavior
These examples demonstrate exactly why NAND is called a universal gate: by combining several NAND gates in different arrangements, it becomes possible to recreate the behavior of NOT, AND, and eventually every other gate as well. The exact same universal property also applies to NOR gates.
| Advantages | Limitations |
|---|---|
| Provide the fundamental building blocks for constructing any digital circuit. | Building complex functionality from basic gates alone can require many individual components. |
| Universal gates like NAND and NOR simplify manufacturing by reducing component variety. | Circuits built entirely from universal gates can be harder to read and understand at a glance. |
| Standardized symbols and truth tables make gate behavior consistent and predictable. | Beginners can find it confusing to distinguish between similarly behaving gates like NAND and NOR. |
| Mistake | Correct Practice |
|---|---|
| Confusing NAND with NOR, since both involve negated outputs. | Remember that NAND is the inverse of AND, while NOR is the inverse of OR. |
| Assuming XOR behaves the same as OR. | Remember that XOR outputs 0 when both inputs are 1, unlike regular OR which outputs 1 in that case. |
| Thinking a NOT gate can accept two inputs like the other basic gates. | Remember that NOT is unique among the basic gates, since it only ever accepts a single input. |
| Believing universal gates can only build a limited number of specific functions. | Understand that NAND or NOR alone can be combined to build every other basic logic gate. |
Logic gates take the abstract operations of Boolean algebra and turn them into real, physical building blocks capable of processing binary signals inside actual computer hardware. Starting from the three basic gates, AND, OR, and NOT, we explored how NAND, NOR, XOR, and XNOR extend this foundation with their own distinct behaviors and truth tables.
We also saw why NAND and NOR are considered universal gates, capable of reconstructing every other basic gate entirely on their own, which plays an important practical role in simplifying digital circuit manufacturing. Together, these seven gates form the essential vocabulary used to describe and build every digital circuit found inside a modern computer.
With logic gates covered, you are now ready to explore registers, where these gates are combined together to build small, fast storage components used directly inside the CPU to hold data during instruction processing.