Você está na página 1de 11

1

How Microprocessors Work


by Marshall Brain

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 ser%er or a laptop. The microprocessor you are using might be a 'entium! a /-! a 'ower'+! a 0parc or any of the many other brands and types of microprocessors! but they all do appro1imately the same thing in appro1imately the same way.

'hoto courtesy IBM +orporation 5nauthori&ed use not permitted.

CMOS 7S "Copper chip" on a stack of pennies

If you ha%e e%er wondered what the microprocessor in your computer is doing! or if you ha%e e%er wondered about the differences between types of microprocessors! then read on. In this article! you will learn how fairly simple digital logic techni2ues allow a computer to do its 3ob! whether its playing a game or spell checking a document4

Microprocessor History
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 4 4! introduced in "#$". The 4 4 was not %ery powerful -- all it could do was add and subtract! and it could only do that 4 bits at a time. But it was ama&ing that e%erything was on one chip. 'rior to the 4 4! engineers built computers either from collections of chips or from discrete components (transistors wired one at a time). The 4 4 powered one of the first portable electronic calculators. The first microprocessor to make it into a home computer was the Intel * * ! a complete *-bit computer on one chip! introduced in "#$4. The first microprocessor to make a real splash in the market was the Intel * **! introduced in "#$# and incorporated into the IBM '+ (which first appeared around "#*,). If you are familiar with the '+ market and its history! you know that the '+ market mo%ed from the * ** to the * ,*- to the * .*- to the * 4*- to the 'entium to the 'entium II to the 'entium III to the 'entium 4. All of these microprocessors are made by Intel and all of them are

Intel 4004 chip

Intel 8080

2
impro%ements on the basic design of the * **. The 'entium 4 can e1ecute any piece of code that ran on the original * **! but it does it about 6! times faster4

Microprocessor 'rogression7 Intel


The following table helps you to understand the differences between the different processors that Intel has introduced o%er the years.
8ame * * * ** * ,** .** 4*'entium 'entium II 'entium III 'entium 4 'entium 4 <'rescott< 9ate "#$4 "#$# "#*, "#*6 "#*# "##. "##$ "### , , 4 Transistors -! ,#! ".4! ,$6! "!, .!" $!6 #!6 4,! ",6! ! ! ! ! ! ! Microns . ".6 ".6 " .* ..6 .,6 ."* . # +lock speed , MH& 6 MH& - MH& "- MH& ,6 MH& - MH& ,.. MH& 46 MH& ".6 ;H& ..- ;H& 9ata width * bits "- bits *-bit bus "- bits ., bits ., bits ., bits -4-bit bus ., bits -4-bit bus ., bits -4-bit bus ., bits -4-bit bus ., bits -4-bit bus MI'0 .-4 ... " 6 , " :. :6" :"!$ :$!

+ompiled from The Intel Microprocessor =uick >eference ;uide and T0+' Benchmark 0cores

Information about this table7

?hat@s a +hipA
A chip is also called an integrated circuit. ;enerally it is a small! thin piece of silicon onto which the transistors making up the microprocessor ha%e been etched. A chip might be as large as an inch on a side and can contain tens of millions of transistors. 0impler processors might consist of a few thousand transistors etched onto a chip 3ust a few millimeters s2uare.

The ate is the year that the processor was first introduced. Many processors are reintroduced at higher clock speeds for many years after the original release date. !ransistors is the number of transistors on the chip. Bou can see that the number of transistors on a single chip has risen steadily o%er the years. Microns is the width! in microns! of the smallest wire on the chip. Cor comparison! a human hair is " microns thick. As the feature si&e on the chip goes down! the number of transistors rises. Clock spee is the ma1imum rate that the chip can be clocked at. +lock speed will make more sense in the ne1t section. "ata Wi th is the width of the AD5. An *-bit AD5 can addEsubtractEmultiplyEetc. two *-bit numbers! while a .,-bit AD5 can manipulate .,-bit numbers. An *-bit AD5 would ha%e to e1ecute four instructions to add two .,-bit numbers! while a .,-bit AD5 can do it in one instruction. In many cases! the e1ternal data bus is the same width as the AD5! but not always. The * ** had a "--bit AD5 and an *-bit bus! while the modern 'entiums fetch data -4 bits at a time for their .,-bit AD5s. MIPS stands for <millions of instructions per second< and is a rough measure of the performance of a +'5. Modern +'5s can do so many different things that MI'0 ratings lose a lot of their meaning! but you can get a general sense of the relati%e power of the +'5s from this column.

Crom this table you can see that! in general! there is a relationship between clock speed and MI'0. The ma1imum clock speed is a function of the manufacturing process and delays within the chip. There is also a relationship between the number of transistors and MI'0. Cor e1ample! the * ** clocked at 6 MH& but only e1ecuted at ... MI'0 (about one instruction per "6 clock cycles). Modern processors can often e1ecute at a rate of two instructions per

'hoto courtesy Intel +orporation Intel Penti&m 4 processor

clock cycle. That impro%ement is directly related to the number of transistors on the chip and will make more sense in the ne1t section.

Inside a Microprocessor
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 assem#l$ lan%&a%e -- the nati%e language of a microprocessor -- and many of the things that engineers can do to boost the speed of a processor. A microprocessor e1ecutes a collection of machine instructions that tell the processor what to do. Based on the instructions! a microprocessor does three basic things7

5sing its AD5 (ArithmeticEDogic 5nit)! a microprocessor can perform mathematical operations like addition! subtraction! multiplication and di%ision. Modern microprocessors contain complete floating point processors that can perform e1tremely sophisticated operations on large floating point numbers. A microprocessor can mo%e data from one memory location to another. A microprocessor can make decisions and 3ump to a new set of instructions based on those decisions.

There may be %ery sophisticated things that a microprocessor does! but those are its three basic acti%ities. The following diagram shows an e1tremely simple microprocessor capable of doing those three things7

This is about as simple as a microprocessor gets. This microprocessor has7


An a ress #&s (that may be *! "- or ., bits wide) that sends an address to memory A ata #&s (that may be *! "- or ., bits wide) that can send data to memory or recei%e data from memory An '" (read) and W' (write) line to tell the memory whether it wants to set or get the addressed location A clock line that lets a clock pulse se2uence the processor A reset line that resets the program counter to &ero (or whate%er) and restarts e1ecution

Det@s assume that both the address and data buses are * bits wide in this e1ample. Here are the components of this simple microprocessor7

>egisters A! B and + are simply latches made out of flip-flops. (0ee the section on <edge-triggered latches< in How Boolean Dogic ?orks for details.) The address latch is 3ust like registers A! B and +. The program counter is a latch with the e1tra ability to increment by " when told to do so! and also to reset to &ero when told to do so. The AD5 could be as simple as an *-bit adder (see the section on adders in How Boolean Dogic ?orks for details)! or it might be able to add! subtract! multiply and di%ide *-bit %alues. Det@s assume the latter here. The test register is a special latch that can hold %alues from comparisons performed in the AD5. An AD5 can normally compare two numbers and determine if they are e2ual! if one is greater than the other! etc. The test register can also normally hold a carry bit from the last stage of the adder. It stores these %alues in flip-flops and then the instruction decoder can use the %alues to make decisions. There are si1 bo1es marked <.-0tate< in the diagram. These are tri(state #&ffers. A tri-state buffer can pass a "! a or it can essentially disconnect its output (imagine a switch that totally disconnects the output line from the wire that the output is heading

Helpful Articles
If you are new to digital logic! you may find the following articles helpful in understanding this section7 How Bytes and Bits ?ork How Boolean Dogic ?orks How Flectronic ;ates ?ork toward). A tri-state buffer allows multiple outputs to connect to a wire! but only one of them to actually dri%e a " or a onto the line. The instruction register and instruction decoder are responsible for controlling all of the other components.

Although they are not shown in this diagram! there would be control lines from the instruction decoder that would7 Tell the A register to latch the %alue currently on the data bus Tell the B register to latch the %alue currently on the data bus Tell the + register to latch the %alue currently output by the AD5 Tell the program counter register to latch the %alue currently on the data bus Tell the address register to latch the %alue currently on the data bus Tell the instruction register to latch the %alue currently on the data bus Tell the program counter to increment Tell the program counter to reset to &ero Acti%ate any of the si1 tri-state buffers (si1 separate lines) Tell the AD5 what operation to perform Tell the test register to latch the AD5@s test bits Acti%ate the >9 line Acti%ate the ?> line +oming into the instruction decoder are the bits from the test register and the clock line! as well as the bits from the instruction register.

>AM and >GM


The pre%ious section talked about the address and data buses! as well as the >9 and ?> lines. These buses and lines connect either to >AM or >GM -- generally both. In our sample microprocessor! we ha%e an address bus * bits wide and a data bus * bits wide. That means that the microprocessor can address (,*) ,6- bytes of memory! and it can read or write * bits of the memory at a time. Det@s assume that this simple microprocessor has ",* bytes of >GM starting at address and ",* bytes of >AM starting at address ",*.

'OM chip

>GM stands for read-only memory. A >GM chip is programmed with a permanent collection

')M chip

of pre-set bytes. The address bus tells the >GM chip which byte to get and place on the data bus. ?hen the >9 line changes state! the >GM chip presents the selected byte onto the data bus. >AM stands for random-access memory. >AM contains bytes of information! and the microprocessor can read or write to those bytes depending on whether the >9 or ?> line is signaled. Gne problem with today@s >AM chips is that they forget e%erything once the power goes off. That is why the computer needs >GM. By the way! nearly all computers contain some amount of >GM (it is possible to create a simple computer that contains no >AM -- many microcontrollers do this by placing a handful of >AM bytes on the processor chip itself -- but generally impossible to create one that contains no >GM). Gn a '+! the >GM is called the BIG0 (Basic InputEGutput 0ystem). ?hen the microprocessor starts! it begins e1ecuting instructions it finds in the BIG0. The BIG0 instructions do things like test the hardware in the machine! and then it goes to the

7
hard disk to fetch the #oot sector (see How Hard 9isks ?ork for details). This boot sector is another small program! and the BIG0 stores it in >AM after reading it off the disk. The microprocessor then begins e1ecuting the boot sector@s instructions from >AM. The boot sector program will tell the microprocessor to fetch something else from the hard disk into >AM! which the microprocessor then e1ecutes! and so on. This is how the microprocessor loads and e1ecutes the entire operating system.

Microprocessor Instructions
F%en the incredibly simple microprocessor shown in the pre%ious e1ample will ha%e 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 assem#l$ lan%&a%e of the processor. An assem#ler can translate the words into their bit patterns %ery easily! and then the output of the assembler is placed in memory for the microprocessor to e1ecute. Here@s the set of assembly language instructions that the designer might create for the simple microprocessor in our e1ample7

*O)") mem - Doad register A from memory address *O)"+ mem - Doad register B from memory address CO,+ con - Doad a constant %alue into register B S)-.+ mem - 0a%e register B to memory address S)-.C mem - 0a%e register + to memory address )"" - Add A and B and store the result in + SU+ - 0ubtract A and B and store the result in + MU* - Multiply A and B and store the result in + "I- - 9i%ide A and B and store the result in + COM - +ompare A and B and store the result in test /UMP a r - Hump to an address /.0 a r - Hump! if e2ual! to address /,.0 addr - Hump! if not e2ual! to address /1 a r - Hump! if greater than! to address /1. a r - Hump! if greater than or e2ual! to address /* a r - Hump! if less than! to address /*. a r - Hump! if less than or e2ual! to address S!OP - 0top e1ecution

If you ha%e read How + 'rogramming ?orks! then you know that this simple piece of + code will calculate the factorial of 6 (where the factorial of 6 I 64 I 6 J 4 J . J , J " I ", )7 a=1; f=1; while (a <= 5) { f = f * a; a = a + 1; } At the end of the program@s e1ecution! the %ariable f contains the factorial of 6.

Microprocessor Instructions7 Assembly Danguage


A C compiler translates this + code into assembly language. Assuming that >AM starts at address ",* in this processor! and >GM (which contains the assembly language program) starts at address ! then for our simple microprocessor the assembly language might look like this7
// Assume a is at address 128 // Assume F is at address 129 !"#$ 1 // a=1; 1 %A&'$ 128 2 !"#$ 1 // f=1; ( %A&'$ 129 ) *"A+A 128 // if a , 5 the -um. t/ 10 5 !"#$ 5 1 !"2 0 34 10 8 *"A+A 129 // f=f*a; 9 *"A+$ 128 1 25* 11 %A&'! 129 12 *"A+A 128 // a=a+1; 1( !"#$ 1 1) A++ 15 %A&'! 128 11 3526 ) // l//. 7a89 t/ if 10 %:"6

Microprocessor Instructions7 >GM


0o now the 2uestion is! <How do all of these instructions look in >GMA< Fach of these assembly language instructions must be represented by a binary number. Cor the sake of simplicity! let@s assume each assembly language instruction is gi%en a uni2ue number! like this7

DGA9A - " DGA9B - , +G8B - . 0AKFB - 4 0AKF+ mem - 6 A99 - 05B - $ M5D - * 9IK - # +GM - " H5M' addr - "" HF= addr - ", H8F= addr - ". H; addr - "4 H;F addr - "6 HD addr - "HDF addr - "$ 0TG' - "*

9
The numbers are known as opco es. In >GM! our little program would look like this7 // Assume a is at address 128 // Assume F is at address 129 Addr /.8/de/;alue ( // !"#$ 1 1 1 2 ) // %A&'$ 128 ( 128 ) ( // !"#$ 1 5 1 1 ) // %A&'$ 129 0 129 8 1 // *"A+A 128 9 128 1 ( // !"#$ 5 11 5 12 1 // !"2 1( 1) // 34 10 1) (1 15 1 // *"A+A 129 11 129 10 2 // *"A+$ 128 18 128 19 8 // 25* 2 5 // %A&'! 129 21 129 22 1 // *"A+A 128 2( 128 2) ( // !"#$ 1 25 1 21 1 // A++ 20 5 // %A&'! 128 28 128 29 11 // 3526 ) ( 8 (1 18 // %:"6 Bou can see that se%en lines of + code became "* lines of assembly language! and that became ., bytes in >GM.

Microprocessor Instructions7 9ecoding


The instruction decoder needs to turn each of the opcodes into a set of signals that dri%e the different components inside the microprocessor. Det@s take the A99 instruction as an e1ample and look at what it needs to do7 ". 9uring the first clock cycle! we need to actually load the instruction. Therefore the instruction decoder needs to7 acti%ate the tri-state buffer for the program counter acti%ate the >9 line acti%ate the data-in tri-state buffer latch the instruction into the instruction register ,. 9uring the second clock cycle! the A99 instruction is decoded. It needs to do %ery little7 set the operation of the AD5 to addition

10
latch the output of the AD5 into the + register .. 9uring the third clock cycle! the program counter is incremented (in theory this could be o%erlapped into the second clock cycle).

F%ery instruction can be broken down as a set of se2uenced operations like these that manipulate the components of the microprocessor in the proper order. 0ome instructions! like this A99 instruction! might take two or three clock cycles. Gthers might take fi%e or si1 clock cycles.

Microprocessor 'erformance
The number of transistors a%ailable has a huge effect on the performance of a processor. As seen earlier! a typical instruction in a processor like an * ** took "6 clock cycles to e1ecute. Because of the design of the multiplier! it took appro1imately * cycles 3ust to do one "--bit multiplication on the * **. ?ith more transistors! much more powerful multipliers capable of single-cycle speeds become possible. More transistors also allow for a technology called pipelinin%. In a pipelined architecture! instruction e1ecution o%erlaps. 0o e%en though it might take fi%e clock cycles to e1ecute each instruction! there can be fi%e instructions in %arious stages of e1ecution simultaneously. That way it looks like one instruction completes e%ery clock cycle. Many modern processors ha%e 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 techni2ue can be 2uite comple1 to implement! so it takes lots of transistors.

Microprocessor Trends
The trend in processor design has primarily been toward full .,-bit AD5s with fast floating point processors built in and pipelined e1ecution with multiple instruction streams. The newest thing in processor design is -4-bit AD5s! and people are e1pected to ha%e these processors in their home '+s in the ne1t decade. There has also been a tendency toward special instructions (like the MML instructions) that make certain operations particularly efficient! and the addition of hardware %irtual memory support and D" caching on the processor chip. All of these trends push up the transistor count! leading to the multi-million transistor powerhouses a%ailable today. These processors can e1ecute about one billion instructions per second4

-4-bit 'rocessors
0i1ty-four-bit processors ha%e been with us since "##,! and in the ,"st century they ha%e started to become mainstream. Both Intel and AM9 ha%e introduced -4-bit chips! and the Mac ;6 sports a -4-bit processor. 0i1ty-four-bit processors ha%e -4-bit AD5s! -4-bit registers! -4-bit buses and so on.

11

'hoto courtesy AM9

Gne reason why the world needs -4-bit processors is because of their enlar%e a ress spaces. Thirty-two-bit chips are often constrained to a ma1imum of , ;B or 4 ;B of >AM access. That sounds like a lot! gi%en that most home computers currently use only ,6- MB to 6", MB of >AM. Howe%er! a 4-;B limit can be a se%ere problem for ser%er machines and machines running large databases. And e%en home machines will start bumping up against the , ;B or 4 ;B limit pretty soon if current trends continue. A -4-bit chip has none of these constraints because a -4-bit >AM address space is essentially infinite for the foreseeable future -- ,M-4 bytes of >AM is something on the order of a 2uadrillion gigabytes of >AM. ?ith a -4-bit address bus and wide! high-speed data buses on the motherboard! -4-bit machines also offer faster IEG (inputEoutput) speeds to things like hard disk dri%es and %ideo cards. These features can greatly increase system performance. 0er%ers can definitely benefit from -4 bits! but what about normal usersA Beyond the >AM solution! it is not clear that a -4-bit chip offers <normal users< any real! tangible benefits at the moment. They can process data (%ery comple1 data features lots of real numbers) faster. 'eople doing %ideo editing and people doing photographic editing on %ery large images benefit from this kind of computing power. High-end games will also benefit! once they are re-coded to take ad%antage of -4-bit features. But the a%erage user who is reading e-mail! browsing the ?eb and editing ?ord documents is not really using the processor in that way. In addition! operating systems like ?indows L' ha%e not yet been upgraded to handle -4-bit +'5s. Because of the lack of tangible benefits! it will be , " or so before we see -4-bit machines on e%ery desktop. +heck out F1tremeTech - -4-bit +'5s7 ?hat Bou 8eed to /now and Internet?eek - Athlon -4 8eeds A /iller App to learn more.

Você também pode gostar