Subscribe to the Techs-on-Call monthly mailing list E-mail Techs-on-Call
Jul 24 2009

Understanding How A Computer Works -- Part 1: The CPU

Posted by Wade Burchette at 7:00 PM General

Computers have come a long ways. At one time, they were as big as a house. Now a microchip the size of a postage stamp is many thousands of times more powerful. And many thousands of times more complicated. This is the first of a x series on how a computer works. Each article will build on the last one because some concepts will require a knowldedge of earlier concepts. The articles will be:

  • Part 1: The CPU (this blog entry)
  • Part 2: The Boot Process
  • Part 3: Early Apple Computers and MS-DOS
  • Part 4: Windows 1 to Windows 3.11
  • Part 5: Windows 95 Based Operating Systems
  • Part 6: Windows NT Based Operating Systems
  • Part 7: Windows Vista Based Operating Systems
  • Part 8: Unix and Linux Operating Systems
  • Part 9: MacIntosh

A Simple Overview of the CPU

The CPU has been likened to a human brain, but that is not a correct metaphor. The CPU only blindly performs instructions in the order received. It is up to clever programmers to make the CPU seem like a brain. Fortunately, the operating system was created to make the entire process easier. The operating system, which will be discussed in more detail later, provides programmers optimized tools so that programmers do not need to re-invent the wheel, so to speak. Still, there are some common features on all CPU's that make your computer work.

Modern CPU's contain millions of tiny transistors. Transistors work off electricity and the transistors have a limit as to voltage they can handle. To communicate with the CPU, you must set the voltage to a certain level at a certain time. This time is determined by an internal clock measured in Hertz. There are 60 Hertz per minute; modern CPU's have a speed generally around 1.5 to 4 GHz, or over 1,500,000,000 operations per second. For each Hertz, the CPU looks at the voltage on the line to determine if the electricity is above or below a certain level. Because electricity is never precise, the CPU can only look to see if the voltage is above a certain level or below that level. If the electricity is above a certain level, that data is a 1. Below that level, that data is 0. This is called binary.

Each CPU has a specific action assigned to a specific combination of 1's and 0's. This is called an instruction. The total instructions that a CPU has is called an instruction set.

The first CPU by Intel, the 4004, was 4-bit. This meant that its instructions were a combination of four 1's and 0's. For example, 1100 could an instruction and 1011 could be another. There were 8 possible instructions. The CPU in the Apple and IBM PC was 8-bit. Those CPU's had 256 possible instructions. The Intel 80286 and 80386 was 16-bit, for 65,535 possible instructions. The Intel 80486 and all the Pentiums except the very last Pentium 4's were 32-bit CPU's, for 4,294,967,295 possible instructions. Then AMD made a 64-bit CPU for the Athlon 64's and beyond, which Intel adopted for the Pentium 4's, Core 2 and beyond. A 64-bit CPU has 18,446,744,073,709,551,616 possible instructions. However, the CPU never assigns an instruction to every possible value. There are gaps in the order of 1's and 0's in order to reduce human error when programming for the CPU.

The instruction sets are standardized. And they are patented. The most widely used instruction set is called x86, after Intel's 8086 CPU. Most of Intel's and all of AMD's CPU's extended that original x86 instruction set. This made all newer CPU's fully compatible with older programs. To distinguish extended instruction sets apart, they may be referenced with the number of bits after it. For example, x86-16 is the 16-bit version, x86-32 the 32-bit, and x86-64 the 64-bit. However, in an attempt to make things less confusing, Microsoft began calling the x86-64 instruction set x64. AMD, the creator of it, called AMD64 and that is how it referenced in some programming languages. Intel, so as not seem like an imitator, called it EM64T.

There are extensions to the standard instruction set. These have a very specific purpose and as such and thus will not be required to use the CPU. An example of this is Intel's MMX. These were additional CPU instructions to help with math, audio, and video. Intel added even more math, audio, and video instructions with SSE. SSE was updated several times and denoted with a number after it, such as SSE2. AMD has proposed the latest extension which they are calling SSE5.

When the CPU needs to reference the memory or RAM, it does so by referencing the address of a particular memory cell. Unless you are using a very expensive operating system, memory address generally use the same number of 1's and 0's as the instructions. Therefore, a 32-bit CPU use thirty-two 1's and 0's for an instruction and to address memory. In general, memory can send a lot of data rapidly but after it does so must go through a refresh cycle. All the instructions need to perform the desired tasks are found in the memory.

Each CPU has its own internal memory. There are 2 different types. One is called cache and the other called a register. Each is required.

The cache memory has 1 to 3 levels, denoted L1 to L3. Only L1 (or Level 1) cache is required. Cache memory is much much smaller than RAM because it is very difficult to make. When the CPU needs some more instructions, it goes to the L1 cache to get it. L1 cache is essentially a buffer for the RAM since RAM sends data in short bursts. L2 and L3 cache also store data from RAM, but not always data the CPU requested. L2 and L3 cache store commonly used or recently used data. Really, when the CPU is requesting additional data from RAM, it first looks in the L2 then L3 cache to see if the data is there first. L2 and L3 cache operate much faster than RAM, with L2 cache being the fastest. While not true with older CPU's, L2 cache is as fast as the CPU. Because cache memory is difficult to make, oftentimes some of it comes out defective while the rest of the CPU works just fine. Instead of throwing away the CPU, the manufacturer will disable some or all of the L2 or L3 cache and sell the CPU at a lower price. To keep the budget CPU separate from the fully functioning CPU, it has a different name: AMD Sempron or Intel Celeron.

A register is a special type of memory. They hold specific data that the CPU needs for program reference or is currently using. For example, each CPU has a register for math operations. When the CPU needs to do some math, the numbers are put into two different registers and the result is stored in a register. These registers generally use the same number of 1's and 0's as the CPU does for instructions and memory addressing. Another register holds what memory address the CPU is using. Another register may hold fixed constants, such as the value of PI. And there are many more.

The primary job of the CPU is to process commands as it receives them. The computer seems interactive thanks to careful and skilled programming. A CPU does not directly interact with the hard drive, USB ports, sound adapter, video adapter, and most other computer components. Some CPU's do directly interact with the RAM, but not all of them do. Other chips are responsible for communication between devices and the CPU. These chips are called the northbridge and southbridge. Together they are called a chipset.

The northbridge controls handles data communication between the CPU and the southbridge, specific expansion slots, and in some instances the RAM. The northbridge determines what CPU the system will use. Because of that, quite often the chipset will be called only by the northbridge name.

The southbridge handles communication between devices where speed is not as essential. A southbridge may work with several northbridge chips. It is the southbridge that controls USB devices, FireWire devices, hard drives, sound, the clock, power management, and a few other internal devices.

Whenever the CPU needs to communicate another device or a device needs to communicate with the CPU, it goes through the appropriate chipset. The communication methods are standardized to maintain compatibility between different systems.

Many modern CPU's have multiple cores. The easiest way to think about this is to think of it as more than one CPU on the same chip. The cache memory and some other internal features may be shared, but the system has multiple working CPU. Because this feature is now just starting to become common, older programs were not made to take advantage of this. But newer programs may and will use having multiple processors to its advantage. The result is, of course, a much more responsive computer and much better performance, even when a program does not take advantage of multiple processors.

Modern CPU's also generate a tremendous amount of heat. So much heat that without any cooling, they would generate enough heat to burn themselves out is less than a second. All modern CPU's need a heatsink and a fan. Heat is a by-product of wasted energy. There is a push to make the CPU's much more energy efficient. One computer in a room makes little difference in how hot the room gets. But in offices with hundreds of computers, the heat build-up can be major. And if a computer's energy use was reduced by just 1%, in an office with hundreds of computers, the energy savings would add up quickly. The days when a CPU only needs a heatsink are long gone. But the future generation of CPU's will have more processing power while using less energy.