Pages

Friday, 21 October 2011

Microprocessor

CPU Core Components
A good PC technician needs to understand some basic CPU functions in order to support PCs, so let’s start with an analysis of how the CPU works. If you wanted to teach someone how an automobile engine works, you would use a relatively simple example engine, right? The same principle applies here. Let’s begin our study of the CPU using the granddaddy of all CPUs: the famous Intel 8088, invented in the late 1970s. Although this CPU first appeared over 25 years ago, it defined the idea of the modern microprocessor and contains the same basic parts used in even the most advanced CPUs today. Stick with me, my friend. Prepare to enter that little bit of magic called the CPU.

The Man in the Box
Let’s begin by visualizing the CPU as a man in a box. This is one clever guy in the box. He can perform virtually any mathematical function, manipulate data, and give answers very quickly. This guy is potentially very useful to us, but there’s a catch—he lives closed up in a tiny black box.

Imagine that we install a set of 16 light bulbs, 8 inside his box and 8 outside his box. Each of the 8 light bulbs inside the box connects to one of the 8 bulbs outside the box to form a pair. Each pair of light bulbs is always either on or off. You can control the 8 pairs of bulbs using a set of 8 switches outside the box, and the Man in the Box can also control them using an identical set of 8 switches inside the box. This light bulb communication device is called the external data bus (EDB).









Can you see how this will work? By creating on/off patterns with the light bulbs that represent different pieces of data or commands, you can send that information to the Man in the Box, and he can send information back in the same way—assuming that you agree ahead of time on what the different patterns of lights mean. To accomplish this, you need some sort of codebook that assigns meanings to the many different patterns of lights that the external data bus might display. Keep this thought in mind while we push the analogy a bit more.


Before going any further, make sure you’re clear on the fact that this is an analogy, not reality. There really is an external data bus, but you won’t see any light bulbs or switches on the CPU. You can, however, see little wires sticking out of the CPU

If you apply voltage to one of these wires, you in essence flip the switch. Get the idea? So if that wire had voltage, and if a tiny light bulb were attached to the wire, that light bulb would glow, would it not? By the same token, if the wire had no power, then the light bulb would not glow. That is why the switch-and-light bulb analogy may help you picture these little wires constantly flashing on and off.


Now that the external data bus enables you to communicate with the Man in the Box, you need to see how it works by placing voltages on the wires. This brings up a naming problem. It’s a hassle to say terms such as “on-off-off-off-on-on-off-off” when talking about which wires have voltage. Rather than saying that one of the external data bus wires is on or off, use the number 1 to represent on and the number 0 to represent  off . That way, instead of describing the state of the lights as “on-off-off-offon- on-off-off,” I can instead describe them by writing “10001100.”












Registers
The Man in the Box provides good insight into the workspace inside a CPU. The EDB gives you a way to communicate with the Man in the Box so you can give him work to do. But to do this work, he needs a worktable; in fact, he needs at least four worktables. Each of these four worktables has 16 light bulbs. These light bulbs are not in pairs; they’re just 16 light bulbs lined up straight across the table. Each light bulb is controlled by a single switch, operated only by the Man in the Box. By creating On/Off patterns like the ones on the EDB, the Man in the Box can work math problems using these four sets of light bulbs. In a real computer, these worktables are called registers







Registers provide the Man in the Box with a workplace for the problems you give him. All CPUs contain a large number of registers, but for the moment let’s concentrate on the four most commonly used ones: the general-purpose registers. Intel gave them the names AX, BX, CX, and DX. but before you close the lid on the box, you must give the Man one more tool. Remember the codebook we mentioned earlier? Let’s make one to enable us to communicate with him.























In this codebook, for example, 10000111 means Move the number 7 into the AX register.These commands are called the microprocessor’s machine language. The Intel 8088 CPU, invented in the late 1970s, actually used commands very similar to these, plus a few hundred others. Here are some examples of real machine language for the Intel 8088:

10111010 The next line of code is a number. Put that number into the DX register.
01000001 Add 1 to the number already in the CX register.
00111100 Compare the value in the AX register with the next line of code.

External Data Bus
One more reality check. We’ve been talking about tables with racks of light bulbs, but of course real CPU registers don’t use light bulbs to represent on/1 and off/0. Registers are tiny storage areas on the CPU, microscopic semiconductor circuits. When one of these circuits holds a charge, you can think of the light bulb as on; no charge, the light bulb is off. Figure 3-13 is a diagram of a real 8088 CPU, showing the wires that comprise the external data bus and the single clock wire. Because the registers are inside the CPU,

Now that you have learned what components are involved in the process, try the following simple exercise to see how the process works. In this example, you tell the CPU to add 2 + 3. To do this, you must send a series of commands to the CPU—the CPU will act on each command, eventually giving you an answer. Refer to the codebook  to translate the instructions you’re giving the Man in the Box into binary commands.

Did you try it? Here’s how it works:
1. Place 10000000 on the external data bus (EDB).
2. Place 00000010 on the EDB.
3. Place 10010000 on the EDB.
4. Place 00000011 on the EDB.
5. Place 10110000 on the EDB.
6. Place 11000000 on the EDB.

When you finish Step 6, the value on the EDB will be 00000101, the decimal number 5 written in binary. Congrats! You just added 2 + 3 using individual commands from the codebook. This set of commands is known as a program, which is a series of commands sent to a CPU in a specific order for the CPU to perform work. Each discrete setting of the external data bus is a line of code. This program, therefore, has six lines of code.

Memory
Now that you’ve seen how the CPU executes program code, let’s work backward in the process for a moment and think about how the program code gets to the external data bus. The program itself is stored on the hard drive. In theory, you could build a computer that sends data from the hard drive directly to the CPU, but there’s a problem—the hard drive is too slow. Even the ancient 8088, with its clock speed of 4.77 MHz, could conceivably process several million lines of code every second. Modern CPUs crank out billions of lines every second. Hard drives simply can’t give the data to the CPU at a fast enough speed. Computers need some other device that takes copies of programs from the hard drive and then sends them, one line at a time, to the CPU quickly enough to keep up with its demands. Because each line of code is nothing more than a pattern of eight ones and zeroes, any device that can store ones and zeroes eight across will do. Devices that in any way hold ones and zeroes that the CPU accesses are known generically as memory.

Memory and RAM
Memory must store not only programs, but also data. The CPU needs to be able to read and write to this storage medium. Additionally, this system must enable the CPU to jump to any line of code as easily as to any other line of code that it stores. All of this must be done at or at least near the clock speed of the CPU. Fortunately, this magical device has existed for many years: random access memory (RAM).

In the PC world, RAM transfers and stores data to and from the CPU in byte-sized chunks. RAM is therefore arranged in byte-sized rows. Here are the terms used when talking about quantities of bits:

• Any individual 1 or 0 = a bit
• 4 bits = a nibble
• 8 bits = a byte
• 16 bits = a word
• 32 bits = a double word
• 64 bits = a paragraph or quad word

Computers use dynamic RAM (DRAM) for the main system memory. DRAM needs both a constant electrical charge and a periodic refresh of the circuits, otherwise it loses data—that’s what makes it dynamic, rather than static in content. The refresh can cause some delays, as the CPU has to wait for the refresh to happen, but modern CPU manufacturers have clever ways to get by this issue.

Address Bus
So far, the entire PC consists of only a CPU and RAM. But there needs to be some connection between the CPU and the RAM so they can talk to each other. To do so, extend the external data bus from the CPU so that it can talk to the RAM

How can you connect the RAM to the external data bus? This is not a matter of just plugging it into the external data bus wires! RAM is a spreadsheet with thousands and thousands of discrete rows, and you only need to look at the contents of one row of the spreadsheet at a time, right? So how do you connect RAM to the external data bus in such a way that the CPU can see any one given row, but still give the CPU the capability to look at any row in RAM? We need some type of chip between RAM and the CPU to make the connection. The CPU needs the ability to say which row of RAM it wants, and the chip should handle the mechanics of retrieving that row of data from RAM and putting it on the external data bus. Wouldn’t you know I just happen to have such a chip? This chip comes with many names, but for right now just call it the memory controller chip (MCC).






















The MCC contains special circuitry that enables it to grab the contents of any single line of RAM and place that data or command on the external data bus. This in turn enables the CPU to act on that code. Once the MCC is in place to grab any discrete byte of RAM, the CPU needs the capability to tell the MCC which line of code it needs. The CPU, therefore, gains a second set of wires, called the address bus, that enables it to communicate with the MCC. Different CPUs have different numbers of wires (which, you will soon see, is very significant). The 8088 had 20 wires in its address bus

1 comments:

Haris Mughal said...

nice info. I like it. You really do very hardwork for your blog. thanks for sharing.

Post a Comment