12 min read Beginner Lesson 06 (of 30)
Course 01 · Part 2 — Digital Logic & Circuits

Lesson 06 — Logic Gates: How Transistors Form Logic

Not just memorizing truth tables—understand how a handful of switching transistors make logical decisions and empower a computer to perform its very first binary addition.

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:

Making decisions
Testing conditions
Comparing values
Computing math
Combining information streams

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.

Input (0 or 1) ──→ [ Logic Gate ] ──→ Output (0 or 1)

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)
Key (1) AND Security (1) = Door Unlocked (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 AInput BOutput (A AND B)
000
010
100
111

Simple rule: AND = Every input must be 1.

5. The OR Gate

Output is 1 if AT LEAST ONE input is 1.

Input AInput BOutput (A OR B)
000
011
101
111

Simple rule: OR = Any single 1 triggers a 1.

6. The NOT Gate (Inverter)

Takes a single input and outputs its exact opposite.

InputOutput
01
10

Simple rule: NOT = Flip the state.

7. Transistors → Logic Gates

When transistors are connected together, their synchronized switching dynamics form functional logic gates:

Transistors Electronic Circuit Logic Gate

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).

CMOS (Complementary Metal-Oxide-Semiconductor):

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):

ABANDNAND
0001
0101
1001
1110
NAND is a Universal Gate — using exclusively NAND gates, engineers can synthesize NOT, AND, OR, XOR, and any conceivable digital circuit!

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:

ABXOR Output
000
011
101
110

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:

XOR Gate ──→ SUM bit
AND Gate ──→ CARRY bit
0 + 0 = Sum 0, Carry 0
0 + 1 = Sum 1, Carry 0
1 + 0 = Sum 1, Carry 0
1 + 1 = Sum 0, Carry 1 (Binary 10₂)

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.

Crucial Distinction: ALU ≠ CPU

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

  1. Logic Gates form the foundational layer of digital decision making.
  2. AND (all 1s required), OR (any 1 suffices), NOT (inverts value).
  3. XOR (1 when inputs differ) is the heart of binary arithmetic.
  4. NAND and NOR are Universal Gates capable of synthesizing all other gates.
  5. Pairing XOR with AND creates a Half Adder that computes single-bit sums.
  6. Combining adders and boolean gates builds the ALU—the calculation core of the CPU.
🚀 Next Lesson

Lesson 07 — How Computers Remember Data: Latches, Flip-Flops & RAM

In the next lesson, we discover:

Transistor Logic Feedback Latch Flip-Flop Register RAM

And learn how continuous electrical feedback enables circuits to store a 1 or 0 indefinitely.