- Foundation
- About 16 min
- 5 practice questions
Inside the computer: CPU, ALU, control unit and memory
Name the parts of the CPU and their jobs, tell RAM from ROM and cache from secondary storage, and convert between bits, bytes, KB, MB, GB and TB.
If something looks wrong, please tell us.
When people say 'the computer is thinking', they mean the central processing unit is working. In this lesson you open the box: first the CPU, the part that processes, then memory and storage, the parts that remember. You will also learn the units used to measure memory.
The CPU and its parts
The central processing unit (CPU), also called the processor, is often called the brain of the computer. In modern computers it is a single chip, the microprocessor. It has three main parts.
| Part | Job |
|---|---|
| Arithmetic Logic Unit (ALU) | Does arithmetic (add, subtract, multiply, divide) and logical operations (comparisons such as greater than, less than, equal to). |
| Control Unit (CU) | Directs and coordinates all parts of the computer. It fetches each instruction, works out what it means and tells the other parts what to do. It does not calculate by itself. |
| Registers | Very small, very fast storage places inside the CPU that hold the instruction and data being worked on right now. |
The CPU repeats a machine cycle for every instruction: fetch the instruction from memory, decode it, execute it and store the result. The speed at which it ticks through these steps is its clock speed, measured in hertz; a gigahertz (GHz) is a thousand million cycles per second.
The machine cycle
- Fetch Get the instruction from memory.
- Decode Work out what the instruction means.
- Execute Carry out the instruction.
- Store Keep the result.
Then back to step 1: Fetch
Worked example 1: following one instruction
A program says: 'add 15 and 27, then check whether the answer is more than 40'. Step 1: the control unit fetches the instruction from memory and decodes it. Step 2: the ALU adds 15 + 27 = 42. Step 3: the ALU compares 42 with 40 and finds that 42 is greater, a logical operation. Step 4: the result is held in a register and then written to memory. The CU directed every step but did no arithmetic itself.
Primary memory: RAM and ROM
| Feature | RAM (Random Access Memory) | ROM (Read Only Memory) |
|---|---|---|
| Keeps data without power? | No: it is volatile | Yes: it is non-volatile |
| Read and write? | Read and write | Mainly read; written by the maker |
| What it holds | The programs and data in use right now | Start-up instructions (firmware such as the BIOS) |
| Kinds | SRAM (fast, used for cache) and DRAM (main memory, needs constant refreshing) | PROM (written once), EPROM (erased by ultraviolet light), EEPROM (erased electrically; flash memory is a kind of it) |
Cache memory is a small, very fast memory placed between the CPU and RAM. It keeps the data and instructions the CPU uses most often, so the CPU does not wait for the slower RAM.
Secondary storage
Secondary storage keeps data permanently, even with the power off, and holds far more than RAM, but it is slower. Examples: the hard disk drive (HDD), which stores data magnetically on spinning platters; the solid state drive (SSD), which uses flash chips and has no moving parts; optical discs (CD, DVD, Blu-ray) read by a laser; pen drives and memory cards; and magnetic tape, used for backups.
- Registers (fastest, smallest, costliest per byte)
- Cache memory
- RAM (main memory)
- SSD and hard disk
- Optical discs and magnetic tape (slowest, largest, cheapest per byte)
This order is the memory hierarchy: speed and cost per byte fall as you go down, and capacity rises.
The memory hierarchy
- Registers Fastest, smallest, costliest per byte.
- Cache memory
- RAM (main memory)
- SSD and hard disk
- Optical discs and magnetic tape Slowest, largest, cheapest per byte.
Units of memory
| Unit | Equal to |
|---|---|
| Bit | A single binary digit, 0 or 1 (the smallest unit) |
| Nibble | 4 bits |
| Byte | 8 bits (enough for one character) |
| Kilobyte (KB) | 1024 bytes |
| Megabyte (MB) | 1024 KB |
| Gigabyte (GB) | 1024 MB |
| Terabyte (TB) | 1024 GB |
| Petabyte (PB) | 1024 TB |
In this course 1 KB = 1024 bytes, the convention used for computer memory, because 1024 is 2 raised to the power 10. Some contexts, such as the decimal (SI) system and many storage-drive labels, use 1 KB = 1000 bytes; the names kibibyte (KiB) and mebibyte (MiB) are sometimes used for the 1024-based units.
Worked example 2: converting units
How many bytes are there in 2 MB? Step 1: 2 MB = 2 × 1024 KB = 2048 KB. Step 2: 2048 KB = 2048 × 1024 bytes = 2,097,152 bytes. How many bits are there in 4 KB? 4 KB = 4 × 1024 = 4096 bytes, and 4096 × 8 = 32,768 bits. Rule: going to a smaller unit, multiply; going to a larger unit, divide.
CPU = ALU (calculates and compares) + CU (directs) + registers (hold current work). RAM is volatile, ROM is non-volatile. 8 bits = 1 byte; then each step up is × 1024: KB, MB, GB, TB.
Key takeaways: the ALU calculates and compares, the CU controls, registers hold what is being worked on. RAM loses its contents without power, ROM keeps them. Cache sits between CPU and RAM. Secondary storage is permanent, large and slower. Memory units grow by 1024 at each step after the byte.
Check your understanding
-
1. Which part of the CPU carries out comparisons such as 'is A greater than B'?
- Control unit
- Cache memory
- Arithmetic logic unit
- Hard disk
Show answer
Answer: C. The arithmetic logic unit does both arithmetic and logical operations, and a comparison is a logical operation. The control unit directs work but does not calculate; cache and the hard disk store data.
-
2. Which memory loses its contents when the power is switched off?
- RAM
- ROM
- Hard disk
- DVD
Show answer
Answer: A. RAM is volatile: it needs power to keep data. ROM, hard disks and DVDs are non-volatile and keep their data without power.
-
3. A small, very fast memory placed between the CPU and main memory to hold frequently used data is called:
- ROM
- Secondary memory
- Optical disc
- Cache memory
Show answer
Answer: D. Cache memory sits between the CPU and RAM and keeps the most used data close to the processor. ROM holds start-up instructions; secondary memory and optical discs are slower, permanent storage.
-
4. Taking 1 KB = 1024 bytes, how many bytes are there in 3 KB?
- 3,000
- 3,072
- 3,024
- 30,720
Show answer
Answer: B. 3 KB = 3 × 1024 bytes = 3,072 bytes. The value 3,000 would apply only with the decimal convention of 1000 bytes per KB, which the question does not use.
-
5. Which type of ROM can be erased with ultraviolet light and then reprogrammed?
- PROM
- EEPROM
- EPROM
- DRAM
Show answer
Answer: C. EPROM (Erasable Programmable ROM) is erased by ultraviolet light. PROM can be written only once, EEPROM is erased electrically, and DRAM is a kind of RAM, not ROM.
Sign in to keep track of the lessons you finish.