Name:
Location: Nashville, Tennessee, United States

I joined the ancient order of Magicians when I was in my early Twenties, this is my first attempt to share some of what that group believes.

Friday, May 05, 2006

The Brain of a Computer

A computer's Brain

The computer's brain is a control center that converts data input to information output. This control center is called the central processing unit (CPU), a highly complex, extensive set of electronic circuitry that executes stored program instructions. All computers, large and small, must have a central processing unit. The central processing unit consists of two parts: The control unit and the arithmetic/logic unit. Each part has a specific function.
Before we discuss the control unit and the arithmetic/logic unit in detail, we need to consider data storage and its relationship to the central processing unit. Computers use two types of storage: Primary storage and secondary storage. The CPU interacts closely with primary storage, or main memory, referring to it for both instructions and data. In this entry we will only discuss memory in the context of the central processing unit. Just don't forget that memory is not part of the CPU.
First you must realize that a computer's main memory holds data only temporarily, at the time the computer is executing a program. Secondary storage can hold permanent or semi-permanent data on some external medium. Floppy disks CD-ROMs and DVD are secondary storage devices, as are hard disk drives. The physical attributes of secondary storage devices determine the way data is organized on them and so will be discussed in another entry. (Eventually)
For now let's consider the components of the central processing unit.
The Control Unit
The control unit of the CPU contains circuitry that uses electrical signals to direct the entire computer system to carry out, or execute, stored program instructions. Like a military commander, the control unit does not execute program instructions; rather, it gives other parts of the system orders which result in the smooth(?) execution of the program. The control unit must communicate with both the arithmetic/logic unit and memory.
The Arithmetic/Logic Unit
The arithmetic/logic unit (ALU) contains the electronic circuitry that executes all arithmetic and logical operations.
The arithmetic/logic unit can perform four kinds of arithmetic operations, or mathematical calculations: addition, subtraction, multiplication, and division. If you have studied math at any sort of advanced level, you may know that all of these operations are basically the same. As its name implies, the arithmetic/logic unit also performs logical operations. A logical operation is usually a comparison. The unit can compare numbers, letters, or special characters. (if you saw my entry on memory, you may realize that to a computer, everything is numbers.) The computer can then take action based on the result of the comparison. This is a very important capability. It is by comparing that a computer is able to tell, for instance, whether there are unfilled seats on airplanes, whether charge- card customers have exceeded their credit limits, and whether one candidate for Congress has more votes than another. (at this point some of you are probably saying, " Hey, wait! a computer is just a high speed adding machine!". Well, point taken, it is.)
Logical operations can test for three conditions:
* Equal-to condition. In a test for this condition, the arithmetic/logic unit compares two values to determine if they are equal. For example: If the number of tickets sold equals the number of seats in the auditorium, then the concert is declared sold out.
* Less-than condition. To test for this condition, the computer compares values to determine if one is less than another. For example: If the number of speeding tickets on a driver's record is less than three, then insurance rates are $425; otherwise, the rates are $500.
* Greater-than condition. In this type of comparison, the computer determines if one value is greater than another. For example: If the hours a person worked this week are greater than 40, then multiply every extra hour by 1.5 times the usual hourly wage to compute overtime pay.
A computer can simultaneously test for more than one condition. In fact, a logic unit can usually discern six logical relationships: equal to, less than, greater than, less than or equal to, greater than or equal to, and not equal. ( Wow!)
The symbols that let you define the type of comparison you want the computer to perform are called relational operators. The most common relational operators are the equal sign(=), the less-than symbol(<), and the greater-than symbol(>).
* Registers: Temporary Storage Areas
Registers are temporary storage areas for instructions or data. They are not a part of memory; rather they are special additional storage locations that offer the advantage of blinding speed. Registers work under the direction of the control unit to accept, hold, and transfer instructions or data and perform arithmetic or logical comparisons at high speed. The control unit uses a data storage register the way a store owner uses a cash register. (As a temporary, convenient place to store what is used in transactions.)

Computers usually assign special roles to certain registers, such as:
o An accumulator, which collects the result of computations.
o An address register, which keeps track of where a given instruction or piece of data is stored in memory. Each storage location in memory is identified by an address, just as each house on a street has an address. (this is why Random Access Memory or RAM works, because each piece of data has an address)
o A storage register, which temporarily holds data taken from or about to be sent to memory.
o A general-purpose register, which is used for several functions.

* Memory and Storage
Memory is also known as primary storage, primary memory, main storage, internal storage, main memory, and RAM (Random Access Memory); all these terms are used interchangeably by people in computer circles. Memory is the part of the computer that holds data and instructions for processing. Although closely associated with the central processing unit, memory is separate from it. Memory stores program instructions or data for only as long as the program they pertain to is in operation. Keeping these items in memory when the program is not running is not feasible for at least three reasons:
o Most types of memory only store items while the computer is turned on; data is destroyed when the machine is turned off.
o If more than one program is running at once (often the case on large computers and sometimes on small computers), a single program can not lay exclusive claim to memory.
o There wouldl eventually not be room in memory to hold the processed data, as more and more programs ran and data was put into memory. Almost everyone who uses a computer is familiar with the message " your computer is dangerously low on resources". which means it is running out of memory to use.
How do data and instructions get from an input device into memory? The control unit sends them. Likewise, (hopefully)when the time is right, the control unit sends these items from memory to the arithmetic/logic unit, where an arithmetic operation or logical operation is performed. After being processed, the information is sent to memory, where it is held until it is ready to he released to an output unit. (when this messes up, you see a message like, Program so-and-so tried to write to a protected area of memory and has been closed.)
The chief characteristic of memory is that it allows fast access to instructions and data, no matter where the items are within it. We will discuss the physical components of memory-memory some other time.
To see how registers, memory, and second storage all work together, let us use the analogy of making a cake. In our kitchen we have:
o a refrigerator where we store our Milk and Eggs.
o a counterspace where everything is laid out prior to making the cake.
o a mixing bowl for the ingredients;
o a recipe that details what items to use and how much of them;
o we may have small containers for items that are reserved during the process.
o a cake pan where the finished product will be held;
o an oven where the ingredients become the cake..
The process of making the cake is then to take each ingredient, measure it, mix it according to the recipe, place the batter in the cake pan and either bake it or set it back in the refriigerator until it is time to bake the cake. The refrigerator is the equivalent of secondary (disk) storage. It can store batter for long periods of time. The counter top is the equivalent of the computer's motherboard - everything is done on the counter (inside the computer). The mixing bowl; is the ALU- the work gets done there. The recipe is the control unit - it tells you what to do to fill the mixing bowl(ALU). Space on the counter top is the equivalent of RAM memory - all ingredients are placed on the counter top for fast access. Note that the counter top (RAM) is faster to access than the fridge (disk), but can not hold as much, and can not hold it for long periods of time. The small containers where we temporarily store reserved items are equivalent to the registers. The small containers are pre-measured and are very fast to access, but can not hold much. The mixing bowl is like a temporary register, it is for storing the batter prior to baking(putting data back on a disk) or for taking to the baking pan(outputting the data to an output device). Once in the baking pan, instructions are executed and the cake is made in the oven. (I/O devices).
Now for a more technical example. let us look at how a program can use all three types of storage. Suppose the program calculates an employees wage. The data representing the hours worked and the data for the rate of pay are placed in their respective registers. Any other data related to the salary calculation, whether overtime hours, bonuses, deductions, or something else, is waiting nearby in memory. The data for other employees is still in secondary storage. As the CPU finishes calculations about one employee, the data about the next employee can be brought from secondary storage into memory and eventually into the registers.
Modern computers are designed with a hierarchy for memory due primarily to cost. The cheapest way to get the functionality has been to have the most expensive types of memory as the smallest quantity. However, as RAM becomes cheaper, faster, and even permanent, we may see disks disappear as an internal storage device. Should the very fastest memory ever become cheap to make, (level 1 Cache) we could see computers with as much Random Access Memory as a Hard Disk Drive. We already see Gigabytes of Ram, and the early HDD's didn't have that much storage space. Removable disks, such as CD's and DVD's will probably remain in use as a means to physically transfer volumes of data into the computer and it is certain, due to the nature of PC use, Hard Disk Drives of Terabyte size will soon become the norm. So long as people want 'their own copy' of things, Hard disk drives will continue to exist, but within the next five years most new computer designs will not include floppy drives unless these are special ordered. It is also just possible that portable computers will eventually replace PC's, since they will be equal in function and capacity, but it is not certain, due to the durability of PC's and the fragile nature of Laptops/Notebooks.
How the CPU Executes Program Instructions
Let us examine the way the central processing unit executes a computer program. We'll look at how just one instruction in the program is executed. In fact, most older computers can execute only one instruction at a time, though they execute it very quickly. Many personal computers can execute instructions in less than one-billionth of a second, whereas those speed demons known as supercomputers can execute instructions in even less time.
. Before an instruction can be executed, program instructions and data must be placed into memory from an input device or a secondary storage device (the process is further complicated by the fact that the data will probably make a temporary stop in a register). Then, once the necessary data and instruction are in memory, the central processing unit performs the following four steps for each instruction:
1. The control unit fetches the instruction from memory. (yes, fetch is the technical term)
2. The control unit decodes the instruction and directs that the necessary data be moved from memory to the arithmetic/logic unit. These first two steps together are called instruction time, or I-time.
3. The arithmetic/logic unit executes the arithmetic or logical instruction. Which means the ALU is given control and performs the actual operation on the data. (adding machine stuff)
4. Thc arithmetic/logic unit stores the result of this operation in memory or in a register. Steps 3 and 4 together are called execution time, or E-time.
The control unit eventually directs memory to release the result to an output device or a secondary storage device. The combination of I-time and E-time is called the machine cycle. Each central processing unit has an internal clock (RTC) that produces pulses at a fixed rate to synchronize all computer operations. A single machine-cycle instruction may be made up of a substantial number of sub-instructions, each of which normally take at least one clock cycle. Each type of central processing unit is designed to understand a specific group of instructions called the instruction set. Just as there are many different languages that people understand, so each different type of CPU has an instruction set it understands. Therefore, one CPU-such as the one for a Compaq personal computer-cannot understand the instruction set from another CPU-say, for a Macintosh. This bit of wisdom came about because the inventors of Computers wanted to keep their machines secret and not let anyone else have any part of the market. Now we have to make sure that programs are 'compatible' and that they will not only run with our CPU but with our operating system and our specific hardware configuration. Kind of like having a car that will run on only one type of road.
It is one thing to have instructions and data somewhere in memory and quite another for the control unit to be able to find them. This is accomplished as follows:
The location in memory for each instruction and each piece of data is identified by an address,like the mailboxes in front of an apartment house. And, like the mailboxes, the address numbers of the locations remain the same, but the contents (instructions and data) of the locations may change. That is, new instructions or new data may be placed in the locations when the old contents no longer need to be stored in memory. Like a mailbox, a memory location can hold only a fixed amount of data; an address can hold only a fixed number of bytes.
Here's how a program manipulates data in memory. A payroll program, for example, may give instructions to put the rate of pay in some location called 3 and the number of hours worked in another location called 6. To compute the employee's salary, then, instructions tell the computer to multiply the data in location 3 by the data in location 6 and move the result to location 8. The choice of locations is arbitrary - any locations that are not already spoken for can be used. Programmers using programming languages, however, no longer have to worry about the actual address numbers, because each data address is referred to by a name. The name is called a symbolic address. In this example, the symbolic address names would be Rate, Hours, and Salary.

0 Comments:

Post a Comment

<< Home