1. Where Are We Now?
In the previous lesson, we established: Electricity → Electrical Signal → Transistor → ON / OFF → 0 / 1.
However, an isolated transistor can only regulate an electrical current. For a computer to execute real work, it requires:
To accomplish this, we connect transistors in precise topologies. The outcome: Logic Gates.
2. What Is a Logic Gate?
A Logic Gate is an elementary digital circuit that receives one or more binary inputs and produces a single output according to a defined boolean rule.
Thus, a logic gate is the physical electronic block that executes boolean logic directly on 0s and 1s.
3. A Intuitive Real-World Example
Imagine a high-security vault door that unlocks only when:
- 1. You insert a valid physical key (
Key = 1) - 2. AND the digital security code is verified (
Security = 1)
If either condition evaluates to 0, the door remains locked. This is the essence of AND logic.
4. The AND Gate
Output is 1 if and only if ALL inputs are 1.
| Input A | Input B | Output (A AND B) |
|---|---|---|
| 0 | 0 | 0 |
| 0 | 1 | 0 |
| 1 | 0 | 0 |
| 1 | 1 | 1 |
Simple rule: AND = Every input must be 1.
5. The OR Gate
Output is 1 if AT LEAST ONE input is 1.
| Input A | Input B | Output (A OR B) |
|---|---|---|
| 0 | 0 | 0 |
| 0 | 1 | 1 |
| 1 | 0 | 1 |
| 1 | 1 | 1 |
Simple rule: OR = Any single 1 triggers a 1.
6. The NOT Gate (Inverter)
Takes a single input and outputs its exact opposite.
| Input | Output |
|---|---|
| 0 | 1 |
| 1 | 0 |
Simple rule: NOT = Flip the state.
7. Transistors → Logic Gates
When transistors are connected together, their synchronized switching dynamics form functional logic gates:
8. Constructing a NOT Gate & CMOS
When an input applies 0V, the transistor remains off, pulling output up to the positive supply (1). When input voltage is high (1), the transistor turns on, connecting output to ground (0).
Modern processors pair NMOS and PMOS transistors in complementary pairs to achieve almost zero static power leakage and rapid switching speeds.
9. The NAND Gate — Universal Building Block
NAND = NOT + AND (The output is 0 ONLY when both inputs are 1):
| A | B | AND | NAND |
|---|---|---|---|
| 0 | 0 | 0 | 1 |
| 0 | 1 | 0 | 1 |
| 1 | 0 | 0 | 1 |
| 1 | 1 | 1 | 0 |
10. The NOR Gate
NOR = NOT + OR (The output is 1 ONLY when both inputs are 0). Like NAND, NOR is also a functionally complete universal gate.
11. The XOR Gate (Exclusive OR)
XOR is foundational for arithmetic. Output is 1 when inputs differ, and 0 when they match:
| A | B | XOR Output |
|---|---|---|
| 0 | 0 | 0 |
| 0 | 1 | 1 |
| 1 | 0 | 1 |
| 1 | 1 | 0 |
12. First Major Breakthrough: The Half Adder
Consider binary single-digit addition: 1 + 1 = 10₂ (Sum = 0, Carry = 1).
A Half Adder requires just two interconnected gates:
13. The Full Adder & Multi-Bit Addition
To add multi-bit numbers (1011 + 0110), each stage must accommodate a Carry-In bit from the preceding position. This circuit is a Full Adder. Chaining multiple full adders in parallel forms a Ripple Carry Adder.
14. The Arithmetic Logic Unit (ALU)
By gathering adders, subtrackers, AND/OR/XOR gates, and multiplexers together, we form the CPU's calculating powerhouse: the ALU.
The ALU performs calculations, but relies on the Control Unit, Instruction Decoder, and Registers to direct its operations.
15. A Crucial Missing Piece: Remembering Data
All circuits built so far are combinational: the moment input voltages vanish, output dissolves instantly. But running programs requires preserving previous computational steps.
"How can logic gates physically 'remember' past states?"
This breakthrough gives birth to Memory (Latches, Flip-Flops, Registers, and RAM).
🧠 Key Takeaways
- Logic Gates form the foundational layer of digital decision making.
- AND (all 1s required), OR (any 1 suffices), NOT (inverts value).
- XOR (1 when inputs differ) is the heart of binary arithmetic.
- NAND and NOR are Universal Gates capable of synthesizing all other gates.
- Pairing XOR with AND creates a Half Adder that computes single-bit sums.
- Combining adders and boolean gates builds the ALU—the calculation core of the CPU.
Lesson 07 — How Computers Remember Data: Latches, Flip-Flops & RAM
In the next lesson, we discover:
And learn how continuous electrical feedback enables circuits to store a 1 or 0 indefinitely.