How Microprocessors Work (original) (raw)

microprocessor

Microprocessors are at the heart of all computers. Jorg Greuel/Getty Images

The computer you are using to read this page uses a microprocessor to do its work. The microprocessor is the heart of any normal computer, whether it is a desktop machine, a server or a laptop. There are many types of microprocessors, but they all do approximately the same thing in approximately the same way.

A microprocessor — also known as a CPU or central processing unit — is a complete computation engine that is fabricated on a single chip. The first microprocessor was the Intel 4004, introduced in 1971. The 4004 was not very powerful — all it could do was add and subtract, and it could only do that 4 bits at a time. But it was amazing that everything was on one chip. Prior to the 4004, engineers built computers either from collections of chips or from discrete components ( transistors wired one at a time). The 4004 powered one of the first portable electronic calculators.

If you have ever wondered what the microprocessor in your computer is doing, or if you have ever wondered about the differences between types of microprocessors, then read on. In this article, you will learn how fairly simple digital logic techniques allow a computer to do its job, whether it's playing a game or spell checking a document!

Contents

  1. Microprocessor Progression: Intel
  2. Microprocessor Logic
  3. Microprocessor Memory
  4. Microprocessor Instructions
  5. Microprocessor Performance and Trends
  6. 64-bit Microprocessors

Microprocessor Progression: Intel

Introduced by Intel in 1974, the 8080 microprocessor was the first microprocessor powerful enough to build a computer around. Science & Society Picture Library/Getty Images

The first microprocessor to make it into a home computer was the Intel 8080, a complete 8-bit computer on one chip, introduced in 1974. The first microprocessor to make a real splash in the market was the Intel 8088, introduced in 1979 and incorporated into the IBM PC (which first appeared around 1982). If you are familiar with the PC market and its history, you know that the PC market moved from the 8088 to the 80286 to the 80386 to the 80486 to the Pentium series to the Core series to the Xeon series. All of these microprocessors are made by Intel and all of them are improvements on the basic design of the 8088.

Since 2004, Intel has introduced microprocessors with multiple cores and millions more transistors. But even these microprocessors follow the same general rules as earlier chips.

An Intel Core i9 processor can have up to eight cores, each of which can execute any piece of code that ran on the original 8088, only about 6,700 times faster! Each core can handle multiple threads of instructions, allowing the computer to manage tasks more efficiently.

Intel's product range has widened substantially from the 1970s. As of this writing, the company still makes Pentium and Core CPUs for computers, but higher-performance PCs and servers may use the Xeon chip. In addition, Intel offers the Celeron and Atom processor lines. Celeron is aimed at entry-level computer users, and Atom processors are better for mobile devices and devices that are part of the Internet of Things.

While Intel still has a large portion of the market, it has more than its fair share of competitors. AMD competes with Intel in the PC processor market, but also does big business in graphics processor chips that are popular with PC gamers. Nvidia, famous for its graphics chips, also manufactures CPUs. In 2020, Apple introduced its M-series chips, which are replacing the Intel chips Apple was using for its Macintosh computers. Samsung may also be working on its own proprietary processor designs. Many more companies build processors for other electronics uses, like cars and smart home products. The market is getting more and more competitive.

Microprocessor Logic

The Intel Pentium 4 processor was Intel's fastest processor when it was introduced in 2001. Intel/Newsmakers

To understand how a microprocessor works, it is helpful to look inside and learn about the logic used to create one. In the process you can also learn about assembly language — the native language of a microprocessor — and many of the things that engineers can do to boost the speed of a processor.

A microprocessor executes a collection of machine instructions that tell the processor what to do. Based on the instructions, a microprocessor does three basic things:

There may be very sophisticated things that a microprocessor does, but those are its three basic activities. The following diagram shows an extremely simple microprocessor capable of doing those three things:

This diagram shows a simple microprocessor and its components and capabilities.

HowStuffWorks

This is about as simple as a microprocessor gets. This microprocessor has:

Let's assume that both the address and data buses are 8 bits wide in this example.

Here are the components of this simple microprocessor:

Although they are not shown in this diagram, there would be control lines from the instruction decoder that would:

Coming into the instruction decoder are the bits from the test register and the clock line, as well as the bits from the instruction register.

Microprocessor Memory

The previous section talked about the address and data buses, as well as the RD and WR lines. These buses and lines connect either to RAM or ROM — generally both. In our sample microprocessor, we have an address bus 8 bits wide and a data bus 8 bits wide. That means that the microprocessor can address 256 bytes of memory, and it can read or write 8 bits of the memory at a time. Let's assume that this simple microprocessor has 128 bytes of ROM starting at address 0 and 128 bytes of RAM starting at address 128.

ROM stands for read-only memory. A ROM chip is programmed with a permanent collection of pre-set bytes. The address bus tells the ROM chip which byte to get and place on the data bus. When the RD line changes state, the ROM chip presents the selected byte onto the data bus.

RAM stands for random-access memory. RAM contains bytes of information, and the microprocessor can read or write to those bytes depending on whether the RD or WR line is signaled. One problem with today's RAM chips is that they forget everything once the power goes off. That is why the computer needs ROM.

By the way, nearly all computers contain some amount of ROM (it is possible to create a simple computer that contains no RAM — many microcontrollers do this by placing a handful of RAM bytes on the processor chip itself — but generally impossible to create one that contains no ROM). On a PC, the ROM is called the BIOS (Basic Input/Output System). When the microprocessor starts, it begins executing instructions it finds in the BIOS. The BIOS instructions do things like test the hardware in the machine, and then it goes to the hard disk to fetch the boot sector (see How Hard Disks Work for details). This boot sector is another small program, and the BIOS stores it in RAM after reading it off the disk. The microprocessor then begins executing the boot sector's instructions from RAM. The boot sector program will tell the microprocessor to fetch something else from the hard disk into RAM, which the microprocessor then executes, and so on. This is how the microprocessor loads and executes the entire operating system.

Microprocessor Instructions

Even the incredibly simple microprocessor shown in the previous example has a fairly large set of instructions that it can perform. The collection of instructions is implemented as bit patterns, each one of which has a different meaning when loaded into the instruction register. Humans are not particularly good at remembering bit patterns, so a set of short words are defined to represent the different bit patterns. This collection of words is called the assembly language of the processor. An assembler can translate the words into their bit patterns very easily, and then the output of the assembler is placed in memory for the microprocessor to execute.

Here's the set of assembly language instructions that the designer might create for the simple microprocessor in our example:

If you have read How C Programming Works, then you know that this simple piece of C code will calculate the factorial of 5 (where the factorial of 5 = 5! = 5 * 4 * 3 * 2 * 1 = 120):

a=1;f=1;while (a <= 5){ f = f * a; a = a + 1;}

At the end of the program's execution, the variable f contains the factorial of 5.

Assembly Language

A C compiler translates this C code into assembly language. Assuming that RAM starts at address 128 in this processor, and ROM (which contains the assembly language program) starts at address 0, then for our simple microprocessor the assembly language might look like this:

// Assume a is at address 128// Assume F is at address 1290 CONB 1 // a=1;1 SAVEB 1282 CONB 1 // f=1;3 SAVEB 1294 LOADA 128 // if a > 5 the jump to 175 CONB 56 COM7 JG 178 LOADA 129 // f=f*a;9 LOADB 12810 MUL11 SAVEC 12912 LOADA 128 // a=a+1;13 CONB 114 ADD15 SAVEC 12816 JUMP 4 // loop back to if17 STOP

ROM

So now the question is, "How do all of these instructions look in ROM?" Each of these assembly language instructions must be represented by a binary number. For the sake of simplicity, let's assume each assembly language instruction is given a unique number, like this:

The numbers are known as opcodes. In ROM, our little program would look like this:

// Assume a is at address 128// Assume F is at address 129Addr opcode/value0 3 // CONB 11 12 4 // SAVEB 1283 1284 3 // CONB 15 16 4 // SAVEB 1297 1298 1 // LOADA 1289 12810 3 // CONB 511 512 10 // COM13 14 // JG 1714 3115 1 // LOADA 12916 12917 2 // LOADB 12818 12819 8 // MUL20 5 // SAVEC 12921 12922 1 // LOADA 12823 12824 3 // CONB 125 126 6 // ADD27 5 // SAVEC 12828 12829 11 // JUMP 430 831 18 // STOP

You can see that seven lines of C code became 18 lines of assembly language, and that became 32 bytes in ROM.

Decoding

The instruction decoder needs to turn each of the opcodes into a set of signals that drive the different components inside the microprocessor. Let's take the ADD instruction as an example and look at what it needs to do:

  1. During the first clock cycle, we need to load the instruction. Therefore, the instruction decoder needs to:
  2. activate the tri-state buffer for the program counter
  3. activate the RD line
  4. activate the data-in tri-state buffer
  5. latch the instruction into the instruction register
  6. During the second clock cycle, the ADD instruction is decoded. It needs to do very little:
  7. set the operation of the ALU to addition
  8. latch the output of the ALU into the C register
  9. During the third clock cycle, the program counter is incremented (in theory this could be overlapped into the second clock cycle).

Every instruction can be broken down as a set of sequenced operations like these that manipulate the components of the microprocessor in the proper order. Some instructions, like this ADD instruction, might take two or three clock cycles. Others might take five or six clock cycles.

The number of transistors available has a huge effect on the performance of a processor. As seen earlier, a typical instruction in a processor like an 8088 took 15 clock cycles to execute. Because of the design of the multiplier, it took approximately 80 cycles just to do one 16-bit multiplication on the 8088. With more transistors, much more powerful multipliers capable of single-cycle speeds become possible.

More transistors also allow for a technology called pipelining. In a pipelined architecture, instruction execution overlaps. So even though it might take five clock cycles to execute each instruction, there can be five instructions in various stages of execution simultaneously. That way it looks like one instruction completes every clock cycle.

Many modern processors have multiple instruction decoders, each with its own pipeline. This allows for multiple instruction streams, which means that more than one instruction can complete during each clock cycle. This technique can be quite complex to implement, so it takes lots of transistors.

These days it seems like processors are everywhere, and that trend doesn't appear to be slowing. Researchers have found ways to make microprocessors flexible, enabling items such as smart clothing. Researchers have been working on ways to use light, rather than electricity, to operate processors. Probably the biggest change on the horizon is the development of quantum computers, which aren't restricted to using 1s and 0s to solve problems. While these computers can process more difficult problems more efficiently, it's unlikely you will see a quantum computer on your desktop anytime soon.

64-bit Microprocessors

Find out how 64-bit processors work and why they can handle an almost infinite amount of RAM. AMD

Sixty-four-bit processors have been with us since 1992, and in the 21st century they have become mainstream. These processors have 64-bit ALUs, 64-bit registers, 64-bit buses and so on.

One reason why the world needs 64-bit processors is because of their enlarged address spaces. Thirty-two-bit chips are often constrained to a maximum of 2 GB or 4 GB of RAM access. That seemed like a lot when most home computers used only 256 MB to 512 MB of RAM. But 21st-century home computers can process data (very complex data features lots of real numbers) faster. People doing video editing and people doing photographic editing on very large images benefit from this kind of computing power. High-end gamers also benefit from more detailed high-resolution games.

A 64-bit chip opens up more options because a 64-bit RAM address space is essentially infinite for the foreseeable future — 2^64 bytes of RAM is something on the order of a billion gigabytes of RAM. With a 64-bit address bus and wide, high-speed data buses on the motherboard, 64-bit machines also offer faster I/O (input/output) speeds to things like hard disk drives and video cards. These features can greatly increase system performance.

For more information on microprocessors and related topics, check out the following links.

Frequently Answered Questions

What is a microprocessor used for?

A microprocessor is a part of a computer that performs arithmetic and logic operations, which generally include adding, subtracting, transferring numbers from one area to another, and comparing two numbers.

What is a microprocessor also known as?

A microprocessor is also known as a central processing unit.

Lots More Information

Sources