Central processing unit facts for kids
A central processing unit (CPU) is like the brain of a computer. It's a super important part that sends signals to control all the other parts of the computer. Just like your brain tells your body what to do, the CPU tells the computer what to do!
The CPU is an electronic machine that follows a list of tasks, called instructions. It reads these instructions one by one and carries them out. A whole list of instructions that a CPU can run is called a computer program.
The speed of a CPU is measured by its clock rate, which tells you how many cycles it can do per second. This is measured in hertz (Hz). Modern CPUs are incredibly fast, so we often use gigahertz (GHz). One GHz means 1,000,000,000 (one billion) cycles every second!
Most CPUs you find in home computers are microprocessors. The main companies that make them are Intel and Advanced Micro Devices (AMD). Other companies like ARM and IBM also make CPUs. Many of these are used in special devices like mobile phones, cars, or game consoles.
Contents
- What Are the Types of CPUs?
- How CPUs Store Data: Registers
- CPU Memory: RAM
- Speeding Things Up: Cache
- Connecting Parts: Buses
- CPU Languages: Instruction Sets
- What Can a CPU Do?
- Making CPUs Faster: Instruction Pipelines
- Smart Memory Management: MMUs and Virtual Memory
- Many Brains in One: Multiple Cores
- Who Makes CPUs?
- Further Information
- Images for kids
- See also
What Are the Types of CPUs?
Over time, engineers have created many different ways to design computers. Today, most desktop computers use either 32-bit or 64-bit CPUs.
32-bit vs. 64-bit CPUs
A 32-bit CPU is best at handling data that is 32 bits in size. Think of a bit as a tiny piece of information, like an on/off switch. So, a 32-bit CPU works with groups of 32 of these switches at a time. A 64-bit CPU is even better, handling data that is 64 bits in size. It can also usually handle 32-bit data easily.
The size of data a CPU works with best is called its word size. Older CPUs from the 1970s, 80s, and early 90s often had 8-bit or 16-bit word sizes. Many modern embedded systems (like in smart devices) still use these smaller word sizes.
Microprocessors and Microcontrollers
Most CPUs today are microprocessors. This means the entire CPU is built onto a single chip. Some chips even include other parts, making them a complete "computer on a chip." These are called microcontrollers.
How CPUs Store Data: Registers
When a CPU runs a program, it needs a place to quickly store the data it's actively working on. This special storage is called a register. A CPU usually has many registers.
Registers are super fast to access, meaning the CPU can read from and write to them almost instantly. Because of this speed, registers are built right into the CPU chip itself.
CPU Memory: RAM
Storing all data in registers would make CPUs too complex and very expensive. So, registers only hold the data the CPU is using right now. The rest of the program's data is stored in RAM (memory). Except for microcontrollers, RAM is usually on separate chips outside the CPU.
Memory Addresses and Limits
When the CPU needs data from RAM, it sends out an address for that data. Every byte (a small group of bits) in RAM has its own unique memory address. Often, the size of these addresses matches the CPU's word size. For example, a 32-bit CPU uses 32-bit addresses.
Because the size of addresses is limited, the total amount of memory a CPU can use is also limited. A 32-bit processor can usually handle up to 4 GB (gigabytes) of RAM. This is because 232 (2 multiplied by itself 32 times) is about 4 billion, which is roughly 4 GB of unique addresses. A 64-bit processor can handle a massive amount, up to 16 EB (exabytes), which is around 16 billion GB! However, the operating system might limit how much RAM is actually used.
Most information stored in RAM is volatile. This means it disappears when the computer is turned off.
Speeding Things Up: Cache
Modern RAM is much slower than the CPU's registers. This can slow down programs. To make memory access faster, a special, super-fast type of memory called a cache is placed between the RAM and the main parts of the CPU.
The cache is usually part of the CPU chip itself. It's much more expensive per byte than RAM, so it's also much smaller. The cache stores a copy of data from RAM that the CPU is likely to use often. This includes data that was just used or data located near recently used data.
Multi-Level Caching
Sometimes, there's even a "cache for the cache"! This is called multi-level caching. You might see an L1 cache, L2 cache, and so on. The L1 cache is the fastest and closest to the CPU. The L2 cache is a bit slower and further away, acting as a cache for the L1. This system helps the CPU get data as quickly as possible.
Connecting Parts: Buses
Computer buses are like the highways inside a computer. They are the wires the CPU uses to talk to RAM and other parts. Almost all CPUs have at least two main buses:
- A data bus is used to send and receive data.
- An address bus is used to send out the addresses of the data the CPU wants.
Other buses inside the CPU carry data to its different internal sections.
CPU Languages: Instruction Sets
An instruction set is the specific language a CPU understands directly. These languages are also called machine code or binary. They tell the CPU exactly what to do, like "load this data from memory into a register" or "add these two numbers together." Each instruction has a special code made of 0s and 1s.
Programs written in languages like C and C++ can't be run directly by the CPU. They must be translated into machine code first. A compiler is a computer program that does this translation.
Machine code (all 0s and 1s) is hard for humans to read. So, programmers often use assembly language instead. Assembly language uses text commands, like "LD A,0" to load the value 0 into register A. A program called an assembler translates assembly language into machine code.
What Can a CPU Do?
Here are some basic things a CPU can do:
- Read data from memory and write data back to memory.
- Add one number to another.
- Compare two numbers to see if one is bigger.
- Move a number from one place to another (like from a register to memory).
- Jump to a different part of the instruction list, but only if a certain condition is true (for example, if one number is bigger than another).
Even very complex programs are built from many simple instructions like these. This works because each instruction happens incredibly fast. Many modern CPUs can perform over 1 billion (1,000,000,000) instructions every second! The more a CPU can do in a given time, the faster it is. CPU speed can be measured in MIPS (Million Instructions Per Second) or Flops (Floating-point operations per second).
A CPU is made of tiny electronic switches called logic gates; it has no moving parts. The CPU connects electronically to other computer parts, like the video card or the BIOS. Programs can control these peripherals by sending numbers to special memory locations.
Making CPUs Faster: Instruction Pipelines
Each instruction a CPU runs usually involves several steps. For example, to increase a number in a register, a simple CPU might:
- Read the instruction from memory.
- Figure out what the instruction means (decode it).
- Add one to the number in the register.
Different parts of the CPU handle these different steps. Often, the CPU can work on different steps of different instructions at the same time. This is called pipelining and makes the CPU much faster. It's like an assembly line where many instructions are "inside the pipeline" at once, each at a different stage of completion.
Smart Memory Management: MMUs and Virtual Memory
Modern CPUs often use a memory management unit (MMU). An MMU is a special part that changes the addresses a program uses into different "real" addresses in RAM. When an MMU is used, the addresses in a program are usually not the actual physical addresses where the data is stored. This is called virtual memory.
Here are some reasons why MMUs are helpful:
- An MMU can "hide" the memory of other programs from a running program. This means programs can't read or change each other's memory, which makes the computer more secure and stable.
- Many MMUs can make certain parts of memory non-writeable (you can't change it), non-readable (you can't see it), or non-executable (you can't run code from it). This helps prevent errors and improves security.
- MMUs allow different programs to see memory in different ways. This is useful for sharing code between programs or making sure a program's main code always starts at the same virtual address.
- MMUs can make code from shared libraries appear at different addresses each time a program runs. This is called address space randomization and makes it harder for hackers to exploit weaknesses.
- Advanced programs can use MMUs to avoid copying data between different memory locations, saving time and resources.
Many Brains in One: Multiple Cores
In the early 2000s, Multi-core processors became common. This means a single CPU chip actually contains many processors (called "cores") built into it. Each core can run instructions independently, allowing the computer to do many things at once. Some powerful processors can have dozens of cores, like the AMD Epyc 7601, which has thirty-two!
Who Makes CPUs?
Here are some of the companies that make computer CPUs:
Further Information
Images for kids
-
EDVAC, one of the first computers that could store programs.
See also
In Spanish: Unidad central de procesamiento para niños