Central processing unit
||This article does not have any sources. (February 2014)|
A central processing unit (CPU) is an important part of almost every computer. The CPU sends signals to control the other parts of the computer, almost like how a brain controls a body.
The CPU is an electronic machine that works on a list of things to do, called 'instructions'. It reads the list of instructions and does (executes) each one in order. A list of instructions that a CPU can read is a computer program. A machine that can perform the job of a CPU is often called a Turing machine by mathematicians.
The CPU market for desktop (home) computers is controlled by two companies: Intel and Advanced Micro Devices (usually shortened to AMD). There are other CPU manufacturers like ARM, IBM, VIA, MCST, ELVEES, SRISA, NTC Module, Sun Microsystems and others, but their CPUs usually have more specific uses (for example in mobile phones, cars, game consoles, or in the military).
Types of CPUs[change | change source]
There are mainly two different types of CPUs used in modern desktop systems: 32-bit CPUs and 64-bit CPUs. The instructions in a 32-bit CPU are good at handling data that is 32 bits in size (most instructions "think" in 32 bits in a 32-bit CPU). Likewise, a 64-bit CPU is good at handling data that is 64 bits in size (and is often good at handling 32-bit data too). The size of data that a CPU handles best is often called the word size of the CPU. Many older CPUs from the 70s, 80s and early 90s (and some modern small CPUs) have an 8-bit or 16-bit word size.
Registers[change | change source]
When the CPU runs a computer program, it needs somewhere to store the data that the instructions operate on (the data that they read and write). This storage is called a register, and a CPU usually has many registers. Registers must be very fast to access (to read and write). Therefore they are part of the CPU chip itself.
Memory[change | change source]
Storing all data in registers would usually make the CPU too complicated (and very expensive). Therefore, registers usually only store the data that the CPU is working on "right now". The rest of the data used by the program is stored outside the CPU in RAM (memory) in separate chips.
When the CPU wants to read or write some data in RAM, it outputs an address to that data. Each byte in RAM has an address. The size of addresses is often the same as the word size: A 32-bit CPU uses 32-bit addresses, etc. Because the size of addresses is limited, the maximum amount of memory is also limited.
A 32-bit processor can usually only handle up to 4 GB of RAM (unless extensions such as Intel's Physical Address Extension are used). This is the number of different bytes that can be selected using a 32-bit address (each bit can have two values - 0 and 1 - and 232 bytes is 4 GB). A 64-bit processor might be able to handle up to 16 EB (16 exabytes, around 16 billion GB, or 16 billion billion bytes) of RAM.
The amount of memory that a processor can handle does not only depend on the processor, but it also depends on the operating system used. For example, Windows 7 Starter Edition with a 64-bit processor can only handle up to 8 GB of memory. Compare that to Windows 7 Ultimate with a 64-bit processor which can handle up to 192 GB of memory.
Cache[change | change source]
On modern computers, RAM is much slower than registers, so accessing RAM slows down the program. To speed up memory accesses, a faster type of memory called a cache is often put between the RAM and the main parts of the CPU. The cache is usually a part of the CPU chip itself, and is much more expensive per byte than RAM.
The cache stores the same data as RAM, but is usually much smaller. Therefore all the data used by the program might not fit in the cache. The cache tries to store data that is likely to be used a lot. Examples include recently used data and data close in memory to recently used data.
Often it makes sense to have a "cache for the cache", just as it makes sense to have a cache for RAM. In multi-level caching, there are many caches, called the L1 cache, the L2 cache, and so on. The L1 cache is the fastest (and most expensive per byte) cache and is "closest" to the CPU. The L2 cache is one step away and is slower than the L1 cache, etc. The L1 cache can often be viewed as a cache for the L2 cache, etc.
Buses[change | change source]
Buses are the "wires" used by the CPU to communicate with RAM and other components in the computer. Almost all CPUs have at least a data bus - used to read and write data - and an address bus - used to output addresses.
Instruction sets[change | change source]
An instruction set (also called an ISA - Instruction Set Architecture) is a language understood directly by a particular CPU. These languages are also called machine code or binary. They say how you tell the CPU to do different things, like loading data from memory into a register, or adding the values from two registers. Each instruction in an instruction set has an encoding, which is how the instruction is written as a sequence of bits.
Programs written in programming languages like C and C++ can't be run directly by the CPU. They must be translated into machine code before the CPU can run them. A compiler is a computer program that does this translation.
Machine code is just a sequence of 0s and 1s, which makes it difficult for humans to read it. To make it more readable, machine code programs are usually written in assembly language. Assembly language uses text instead of 0s and 1s: You might write "LD A,0" to load the value 0 into register A for example. A program that translates assembly language into machine code is called an assembler.
Functionality[change | change source]
Here are some of the basic things a CPU can do:
- Read data from memory and write data to memory
- Add one number with another
- Test to see if one number is bigger than another
- Move a number from one place to another (for example, from one register to another)
- Jump to another place in the instruction list.
- Jump to another place in the instruction list, but only if some test is true (for example, only if one number is bigger than another).
Even very complicated programs can be made by combining many simple instructions like these. This is possible because each instruction takes a very short time to happen. Many CPUs today can do more than 1 billion (1,000,000,000) instructions in a single second. In general, the more a CPU can do in a given time, the faster it is. One way to measure a processor's speed is MIPS (Million Instructions Per Second). Flops (Floating-point operations per second) and CPU clock speed (usually measured in gigahertz) are also ways to measure how much work a processor can do in a certain time.
A CPU is built out of logic gates; it has no moving parts. The CPU of a computer is connected electronically to other parts of the computer, like the video card, or the BIOS. A computer program can control these peripherals by reading or writing numbers to special places in the computer's memory.
Instruction pipelines[change | change source]
Each instruction executed by a CPU is usually done in many steps. For example, the steps to run an instruction "INC A" (increase the value stored in register A by one) on a simple CPU could be this:
- Read the instruction from memory,
- decode the instruction (figure out what the instruction does), and
- add one to register A.
To run these steps, the CPU could have a separate module (separate electronics inside the CPU) that runs each step. The output from one module (for example, the bits of the instruction) would be the input to the next module (for example, the instruction decoder). A set of modules connected like this is called a pipeline. Pipelines can be found in many other places in electronics too, not just in CPUs.
Often it is possible to run some steps from different instructions at the same time, which makes the CPU faster. For example, we can read an instruction from memory at the same time that we decode another instruction, since those steps use different modules. This can be thought of as having many instructions "inside the pipeline" at once. In the best case, all of the modules are working on different instructions at once, but this is not always possible.
Multiple cores[change | change source]
Some newer processors have multiple cores. This means that they have many processors built on to the same chip so that they can run many instructions at once.
While the individual cores might be slower than a single core processor, all the cores can work together to go faster. This means that the GHz might be lower, however the overall speed of the processor will be higher.
To make an analogy, think of traffic lanes;
- One road having one lane, which takes up 50 cars in 10 minutes.
- Another road with two lanes will take 100 cars in the same 10 minutes and if one of the lanes has a problems cars can go to the other lane.
In today's modern computers, some processors may have up to eight cores and are available to all consumers, like the AMD FX-8350.
Manufacturers[change | change source]
The following companies make computer CPUs: