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

PartJob
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.
RegistersVery 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

  1. Fetch Get the instruction from memory.
  2. Decode Work out what the instruction means.
  3. Execute Carry out the instruction.
  4. 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

FeatureRAM (Random Access Memory)ROM (Read Only Memory)
Keeps data without power?No: it is volatileYes: it is non-volatile
Read and write?Read and writeMainly read; written by the maker
What it holdsThe programs and data in use right nowStart-up instructions (firmware such as the BIOS)
KindsSRAM (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.

  1. Registers (fastest, smallest, costliest per byte)
  2. Cache memory
  3. RAM (main memory)
  4. SSD and hard disk
  5. 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

  1. Registers Fastest, smallest, costliest per byte.
  2. Cache memory
  3. RAM (main memory)
  4. SSD and hard disk
  5. Optical discs and magnetic tape Slowest, largest, cheapest per byte.
Going down, speed and cost per byte fall and capacity rises.

Units of memory

UnitEqual to
BitA single binary digit, 0 or 1 (the smallest unit)
Nibble4 bits
Byte8 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. 1. Which part of the CPU carries out comparisons such as 'is A greater than B'?

    1. Control unit
    2. Cache memory
    3. Arithmetic logic unit
    4. 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. 2. Which memory loses its contents when the power is switched off?

    1. RAM
    2. ROM
    3. Hard disk
    4. 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. 3. A small, very fast memory placed between the CPU and main memory to hold frequently used data is called:

    1. ROM
    2. Secondary memory
    3. Optical disc
    4. 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. 4. Taking 1 KB = 1024 bytes, how many bytes are there in 3 KB?

    1. 3,000
    2. 3,072
    3. 3,024
    4. 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. 5. Which type of ROM can be erased with ultraviolet light and then reprogrammed?

    1. PROM
    2. EEPROM
    3. EPROM
    4. 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.

Privacy · Terms · Refunds · Delivery