Text on Hardware This explains the basic, and not so basic, functions of RAM, the CPU, a little into ROM, and provides examples and reasons as to why its bad to touch them when you're filled with static. And how to get rid of the static. Hardware is what makes your computer your computer. It's the boards, etc inside it that you cant see. Examples of this are the Monitor, Keyboard, and the CPU inside it. I'm mainly going to explain RAM, and the CPU. But a few other things along the way. Disk - Say you want to sit down in the morning, and write a letter. Where is the program you're going to write it? Probably you're thinking "it's stored on the hard disk." Yes, and this is how they do it. Disks used magnetic recording media, much like the material used to record speech and music on cassette tapes, to store data in a way so that it doesn't lose it when the power goes off. How exactly is this info. stored? We don't have to go into extreme detail here, but it's important to understand a few things. A disk contains one or more circular "platters", which are extremely flat and smooth pieces of glass or metal, covered with a material that can be very rapidly and accurately magnetized in either of two directions, "north" and "south." To store huge amounts of data, each platter is divided into many millions of small regions, each other which can be magnetized in either direction independent of other regions. The magnetization is detected and modified by "recording heads," similar in principle to those used in tape cassette decks. However, in conrtast to the cassette heads, which make contact with the tape while they are recording or playing back music or pseech, the dik heads "fly" a few millionths of an inch away from the platters, which rotate at an extremely high velocity. Why not touch the two? Well..if you do that, theres a term for this, head crash, which burns out both the disk and whatever touch it. Such is life. The seperately magnetizable regions used to tore information are arranged in groups called "sectors," which are in turn arranged in concentric circles called "tracks." All tracks on one side of a given platter (a recording surface) can be accessed by a recording head dedicated to thta recording surface; each sector is used to store some number of "bytes" of the data, generally a few hundred to a few thousand. "Byte" is a coined word meaning a group of 8 binary digits, or "bits." You may ask why the data isn't stored in the more familiar decimal system, which of course uses the digits 0 - 9. This is not an arbitrary decision; on the contrary, there are a couple of very good reasons that data on a disk are stored using the binary system, in which each digit has only two possible states, 0 and 1. One of these reasons is easy to understand, it's a lot easier to determine the state of something when you have only two options, 0 and 1, then when you have 0 - 9. Another reason is that the binary system is the natural system for data torage using electronic circuitry, which is used to tore data in the rest of the computer. While magnetic storage devices have been around in one form or another since the very early days of computing, the advances in technology just in the last 10 years have been taggering. To comprehend just how large these advances have beenm we need to define the term used to describe storage capacities: The Megabyte. The standard engineering meaning of Mega is "multiply by 1 million," which would make a Megabyte equal to 1 million bytes. As we have just seen, however, the natural number system in the computer field is binary. Therefore, "one Megabyte" is often used instead to specify the nearest "round" number in the binary system, which is 2^20 (2 to the 20th power), or 1,048,576 bytes. You're probly saying that you already know a Megabyte isn't really a milion, so is it enough to take your word? It also probly worries you that you cant "round" a number, when there's only a 1 and 0. Well, the ^ symbol is a command way of saying "to the power of" so 2^20 would be 2 to the power of 20; that is 20 2's multiplied together. This is a "round" number in binary just as 10 * 10 * 10 is a "round" number in decimal. Now, to exercise my point on how far we've come in a short amount of time, in 1985 a 20 Megabyte disk was 900$ (45$ per megabyte); its "access time," which measures how long it takes to retrieve data, was approximately 100 milliseconds (milli=1/1000 of a second). In 1997 a 6510 Megabyte disk cost as little as 499$. Or approximately 7 cents a Megabyte, while it gave 650 times as much storage per dollar, this disk had an access time of 14 milliseconds, which is approximately 7 times as fast as the old disk. Of course, this understates the amount of progress in technology in both economic and technical terms. You see, while 14 milliseconds isnt very long by humand standards, it is a long time indeed to a modern computer. This will become more evident as we examine the next crucial part of a computer, the RAM. RAM - RAM is the working storage of the computer, where data and programs are stored while we're using them is called RAM, which is an acronym for Random Access Memory. For example, your word processor is stored in RAM while you're using it. The document you're writing on is likely to be there as well unless it's too lard to fit all at once, in which case parts of it will be gotten from the disk as needed. Since we have already seen thta both the word prcoessor and the document are stored on the disk in the first place, why not leave them there and use them in place, rather than copying them into RAM? The, in a word, is speed. RAM is physically composed of millions of microscopic switches on a small piece of silicon known as a "chip": a 4 megabit RAM chip has approximately 4 million of them. Each of these switches can be either on or off, we consider a switch that is "on" to be storing a 1, and a switch to be "off" to be storing a 0. Just as in storing information on a disk, where it was easier to magnetize a region in either of two directions, it's a lot easier to make a switch that can be turned on or off reliably and quickly than one part that can be set to any value from 0 - 9 reliably and quickly. This is particulary important when your manufacturing millions of them on a silicon chip the size of you're fingernal. A main difference between disk and RAM is what steps are needed to access the two. In the case of the disk, the head has to be moved to the right track (an operation known as a "seek"), and then we have to wait for the platter to spin so that the region we want to access is under the head (called "rotational delays"). On the other hand, with RAM, the entire process is electronic; we can read or write any byte immediatly as long as we have to supply a unique number called its "memory address" or just "address" for short. What is an address good for? Well, each byte of RAM has a seperate address, which doesn't change, and a value, which does. In case the notion of an address of a byte of memory on a piece of silicon is too abstract, it might help to think of an address as a set of directions as to how to find the byte being addressed, much like directions to osmeone's house. For example, "Go threee streets down, then turn left. It's the second house on the right". With such directions, the house number woulldn't need to be written on the house. Similarly, the memory storage areas in RAM are addressed by position; you can think of the address as telling the hardware which sreet and house you want, by giving directions similar in concept to the preceding example. Therefore, it's not necessary to encode the addresses into the RAM explicitly. Each byte of RAM corresponds to a microscoping region of the RAM chip. As to what they look like, have you ever seen a printed circuit board, such as the ones inside your computer? Imagine the lines on that circuit board reduced thousands of times in size to microscopic dimensions, and you'll have an idea of what a RAM chip looks like. Since RAM has no moving parts, storing and retrieving data in RAM is much faster than waiting for the mechanical motion of a disk platter turning. As we've just seen, disk access times are measured in milliseconds. However, RAM access times are measured in nanoseconds; nano means one billionth. In early 1997, a typical speed for RAM was 70 ns, which means that it is possible to read a given data item from RAM about 200,00 times as quickly as from a disk. In that case, why not use diks only for permanent storage, and read everything into RAM in the morning when we turn on the machine? The reason is simple. COST. In early 1997, the cost of 16 Megabytes of RAM was around 80$. For that same amount of money, you could have bought over 1,100 Megabytes of dik space. Therefor, we must reserve RAM for tasks where speed is all important. Such as running your word precessing program and holding a letter while you're working on it. Also, since RAM is an electronic storage medium (rather than a magnetic one), it does not maintain it's contents when the power is turned off. This means that if you had a power failure while working with data only in RAM, you woul lose everything you had been doing. This is not merely a theoretical problem, by the way; if you don't remember to save what you're doing in your word processor once in awhile, you might lose a whole day's work from a power outage of a few seconds. Such crashes are not unlikely if you use a certain popular PC graphically oriented operating evironments whose names start with "W." We need to develop a better picture of how RAM is used. As I've mentioned before, you can think of RAM as consisting of a large number of bytes, each of which has a unique identifer called an address. This address can be used to specify which byte we mean, so the program might specify that it wants to read the value in byte 148257, or change the value in byte 666666. The values changed in RAM depend on what program is loaded in it. They also change while the program is executing. RAM is used to store both the program itself and the values it manipulates. This is all very well, but it doesn't answer the question of how the program actually uses or changes values in RAM, or performs arithmetic and other operations; that's the job of the CPU, which we will take up next. The CPU - The CPU is the "active" component in the computer. Like RAM, it is physically composed of millions of microscopic transistors on a chip; however, the organization of these transistors in a CPU is much more complex than on a RAM chip, as the latter's functions are limited to the storage and retrieval of data. The CPU, on the other hand, is capable of performing dozens or hundreds of different fundamental operations called "machine instructions", or "instructions" for short. While each instruction performs a very simple function, the tremendous power of the computer lies in the fact that the CPU can perform, or execute, tens or hundreds of millions of these instructions per second. These instructions fall into a number of categoris: instructions that perform arithmetic operations such as adding, suctracting, multiplying, and dividing; instructions that move information from one place to another in RAMl instructions that compare two quantites to help make a determination as to which instructions need to be executed next and instructions that implement that decision; and other, more specialized types of instructions. Of course, adding two numbers together requires that the numbers be available for use. Possibly the most straightforward way of making them available is to store them in and retrieve them from RAM whenever they are needed, and indeed this is done sometimes. However, as fast as RAM is compared to disk drives, not to mention human beings, it's still pretty slow compared to modern CPUs. For example, a 66Mhz which can execute up to 66 million instructions per second, or one instructions every 16 ns's. To see why RAM is so bottleneck, let's calculate how long it would take to execute an instruction if all the data had to come from and go back to RAM. A typical instruction would have to read some data from RAM, and write its result back there; first, though, the instruction itself has to be loaded, or fetched, into the CPU before it can be executed. Let's suppose we hae an instruction in RAM, reading one data item also in RAM, and writing the result back to RAM. Then the minimum timing to do such an instruction could be calculated as below: Time Function ----------------------------------------------------- 70 ns Read instruction from RAM 70 ns Read data from RAM 16 ns Execute instruction 70 ns Write result back to RAM ------- 226 ns Total instruction execution of time. To effectively compute the MIPS of a CPU, we divide 1 second by the time it takes to execute on instruction. Given the assumptions in this example, the CPU could execute only about 4.5 million instructions per second, which is a far cry from the peak performance of 66 MIPS claimed by the manufacturer. If the manufacturer's clims have any relation to reality, there must be a better way. In fact, there is. As a result of a lot of research and development, both in avademia and in the semiconductor industry, it is possible to approach the rated performance of fact CUPs. Some of these techniqures have been around as long as we've had computer; others have fairly recently "trickled down" from supercomputers to microcomputer CPUs. One of the most important of these techniqures is the use of a number of different kinds of storage devices having different performance characteristics; the arrangement of these devices is called the "memory hieracrchy." Before we go any farther, you should know that a "cache" is a small amount of fast memory where frequently used data are stored temporarily. According to this definiton, RAM functions more or less as a cache for the disk; after all, we have to copy data from a slow disk into fast RAM before we can use it for anything. However, while this is a valid analogy, I should point out that the situations aren't quite parallel. Our programs usually read data from the disk into RAM explicitly; that is, we're aware of whether it's on the disk or in RAM, and we have to issue commands to transfer it from one place to the other. On the other hand, caches are "automatic" in their functioning. We don't have to worry about them, and our programs work in exactly the same way with them as without them, except faster. In any event, the basic idea is the same: to use a faster type of memory to speed up repetitive access to data usually stored on a slower storage device. We've already seen the the disk is necessary to store data and programs when the machine i turn off, while RAM is needed for its higher speed in accessing data and programs we're currently using. But why do we need the "external cache?" Actually, we've been around this track before, when we questioned why everything isn't loaded into RAM rather than being read from the disk as need; we're trading speed for cost. To have a cost-effective computer with good performance requires the designer to choose the correct amount of each storage medium. So just as with the disk vs. RAM trade-off before, the reason that we use the external ache is to imporve performace. While RAM can be accessed about 14 million times per secon, the external ache is made from a faster type of memory chips, which can be accessed about 30 million times per second. While not as exterme as the speed differention between disk and RAM, this difference is still significant. However, we can't afford to use external cache exclusively instead of RAM, ebecause it would be too expensive to do so. 1 Megabyte of external cache is about 180$, while for that same amount of money you could've bought about 16 Megabyte's of memory. Therefore, we must reserve external cache for taasks where speed is all-import, such as supplying frequently used data or programs to the CPU. The same analysis applies to the tradeoff between the external ache and the internal cache. The internal cache's characteristics are similar to those of the external cache, but to a greater degree; it's even smaller and faster, allowing access at the rated speed of the CPU. Both characteristics have to do with its privileged position on the same chip as the CPU; this reduces the delays in communication between the internal cache and the CPU but means tht chip area devoted to the cache has to compete with area for the CPU, as long as the total chip size is held constant. Unfortunately, we can't just increase the size of the chip to accommodate more internal cache because of the expense of doing so. larger chips are more difficult to make, which reduces their "yield," or the percentage of good chips. In addition, fewer of them fit on one "wafer," which is the unit of manufacturing. Both of these attributes make larger chips more expensive to make. To oversimplify a bit, here's how caching reduces the effects of slow RAM. Whenever a data item is requested by the CPU, there are three possibilities: 1 - It is already in the internal cache. In this case, the value is sent to the CPU without referring to RAM at all. 2 - It is in the external cache; in this case it would be promoted to the internal cache, and sent to the CPU at the same time. 3 - It is not in either the internal or external cache, in this case, it has to be entered into a location in the internal cache. If there is nothing in that cache location, the new item is simply added to the cache. However, if there is a data item already in that cache location, then the old item is displaced to the external cache, and the new item is written in its place. If the external cache location is empty, that ends the activity; if it is not empty, then the item previously in that location is written out to RAM and its slot is used for the one displaced from the internal cache. Another way to imporve performance that has been employed for many years is to create a smallnumbber of private storage areas, called "registers," that are on the same chip as the CPU itself. Programs use these registers to hold data items that are actively in use; data in registers can e accessed within the time allocated to instruction execution, rather than the much longer times needed to access data in RAM. This means that the time needed to access data in registers is predictable, unlike data that may have been displaced from the internal cache by more recent arrivals and thus must be reloaded from the external cache or even from RAM. Most CPU's have some dedicated rgisters, which aren't available to application programmers, but are reserved fro the operating system, or have special functions dictated by the hardware design; however, we will be concerned primarily with the gernal registers, which are available for our use. The general registers are used to holw working copies of data items called "variables," which otherwise reside in RAM during the execution of the program. These variables represent specific items of data that we wish to keep track of in our pograms, such as weights and numbers of items. You can put something in a variable, and it will stay there until you store something else there; you can also look at it to find out what's in it. As you might expect, several types of variables are used to hold different kinds of data; the first ones we will look at are variables representing whole numbers which are a subset of the category called numberic variables. As this suggest, there are also variables that represent numbers that can have fractional parts. Different types of variables require different amounts of RAM to store them, depending on the amount of data they contain; a very common type of numeric variable, known as a "short" requires 16 bits of RAM to hold any of 65536 different values, from -32768 to +32767, including 0. As we will see shortly, these oddlooking numbers are the result of using the binary system. By no coincendence at all, the early Intel CPUs such as the 8086 had general registers that contained 16 bis eachl these registers were named ax, bx, cx, dx, si, di, and bp. Why does it matter how many bits each register holds? Because the number of instructions it takes to process a variable is much less if the variable fits in a register; therefore, most programming languages, C++ included, relate the size of a variable to the size of the registers available to hold it. A "short" is exactly the right size to fit into a 16-bit register and therefor can be processed efficiently by the early Intel machines, whereas longer variables had to be handled in pieces, causing a great decline in efficiency of the program. Porgress marches on: more recent Intel CPUs, starting with the 80386, have 32-bit generale registers; these registers are called eax, ebx, ecx, edx, esi, edi, and ebp. You may have noticed that these names are simply the names of the old 16-bit registers with an "e" tacked onto the front. The reason for the name change is that when the Intelincreased the size of the registers to 32-bits with the advent of the 80386, it didn't want to change the behavior of previously existing programs that used the old names for the 16 bit registers. So the old names now refer to the bottom halves of the "real" (32-bit) registers. Instructions using these old names behave exactly as though they were accessing the 16-bit registers on earlier machines. To refer to the 320bit registers, you use the new names eax, ebx, and so on, for "extended" ax, "extended" bx, etc. That about does it for this file. After reading all that, you should pretty much know more than anyone on your block about hardware. Of course, there's other parts of computers too that I could go into..CD-ROM drives...new DVD drives...modems...bet there's plenty of stuff I could tell you about those....'Till next though. -phooey