CPUs & RAM Explained — How Computers Actually Think and Remember
Source: Dev.to
The CPU (Central Processing Unit)
The CPU is the component responsible for executing instructions. Every calculation, comparison, loop, condition, or function call in your code eventually becomes an operation executed by the CPU.
What the CPU Does
- Performs mathematical operations
- Moves data between memory locations
- Makes decisions (branching)
- Coordinates the execution of programs
Transistors: The Fundamental Building Block
A transistor is an electronic switch that can:
- Allow electricity to pass
- Block electricity
By combining billions of transistors, CPUs can perform:
- Addition, subtraction, multiplication
- Logical comparisons
- Data movement and storage
Every instruction—e.g., C = A + B—is broken down into electrical operations performed by transistors.
CPU Speed
CPU speed is usually expressed as frequency, measured in Hertz (Hz):
- 1 Hz = one electrical cycle per second
- 1 MHz = one million cycles per second
- 1 GHz = one billion cycles per second
Higher frequency means more cycles per second and more instructions executed per second, but it also draws more current, generating heat. Because temperature limits performance, CPUs require:
- Fans
- Heat sinks
- Advanced cooling systems
Manufacturing Process
CPUs are built primarily from silicon (element 14), the main component of sand. The process:
- Purify sand and form a crystal wafer.
- Use extreme ultraviolet (EUV) lithography (developed mainly by ASML) to “print” transistors at an atomic scale, often placing them just 10–25 atoms apart.
This is one of the most advanced manufacturing processes humanity has created.
RAM (Random Access Memory)
RAM is the CPU’s working memory, storing:
- Variables
- Intermediate calculations
- Program state
- Data currently in use
RAM is fast but temporary; when the computer turns off, RAM is cleared.
Memory Hierarchy
| Layer | Location | Speed | Capacity |
|---|---|---|---|
| Registers / Cache | Inside the CPU | 1–20 ns | Very limited |
| RAM | Separate chips | ~70 ns | Larger, but still limited |
| Secondary Storage | External (SSD/HDD) | Much slower | Very large, permanent |
Data must be loaded into RAM before the CPU can use it.
Key rule: The CPU cannot execute code directly from disk—everything must pass through RAM first.
CPU Architectures
Different architectures are optimized for various goals:
| Architecture | Typical Use | Optimization |
|---|---|---|
| x86 | General‑purpose computing (desktops, laptops) | Simpler instruction sets |
| ARM | Mobile devices & many modern laptops | Energy efficiency (battery life) |
| Server‑grade (e.g., Xeon) | High‑performance environments | Scalability, reliability |
Each architecture reflects a different philosophy of computation.
Performance Improvements
Manufacturers increase performance by:
- Shrinking transistors (smaller process nodes)
- Raising clock speed (within thermal limits)
- Adding multiple cores
Each core is effectively a mini‑CPU capable of executing instructions independently.
Core Variants (e.g., Intel Core i3, i5, i7)
Differences arise from:
- Number of enabled cores
- Cache size
- Power limits
Chips are tested extensively, and their final classification depends on how many cores pass quality control.
Assembly Language and Compilation
Assembly language is the closest human‑readable representation of what the CPU actually understands.
During compilation:
- High‑level code (C#, Java, Python, etc.) → assembly
- Assembly → machine instructions
When the CPU executes code such as:
; Example pseudo‑assembly
MOV R1, #1 ; A = 1
MOV R2, #2 ; B = 2
ADD R3, R1, R2 ; C = A + B
It:
- Allocates memory addresses in RAM
- Loads values into registers
- Executes arithmetic using transistors
- Stores the result back into memory
All software—no matter how abstract—eventually becomes electrical activity.
Why Understanding CPUs and RAM Matters
- Write more efficient code
- Identify performance bottlenecks
- Reason about memory usage
- Debug low‑level issues
- Design better systems
Abstractions are powerful, but mastery comes from understanding what lies beneath them. The CPU doesn’t “think” like a human; it switches transistors on and off billions of times per second, guided by your code. RAM doesn’t “remember” intelligently; it temporarily holds electrical states so the CPU can work efficiently. Together, they form the physical foundation of everything we build in software.