TOPIC 2 :  The Central Processing Unit

2.1	Parts of CPU
2.2	Registers
2.3	Memory
2.4	How the CPU executes program instructions
2.5	Storage locations and addresses
2.6	Data representation
2.7	Microprocessor
2.8	Memory components
2.9 	 	RAM and ROM
2.10	Computer processing speeds
2.11	RISC technology
2.12 	Parallel processing

Introduction

The central processing unit (CPU), is a highly complex , extensive set of electronic circuitry that executes stored program instructions. All computers, large and small, must have a central processing unit. Central processing unit consists of two parts: 

ARITHMETIC/ LOGIC UNIT

THE CONTROL UNIT

Each part has a specific function.

Computers use two types of storage: 

Primary storage and secondary storage. The CPU interacts closely with primary storage, or memory, referring to it both instructions and data. Memory holds data only temporarily, at the time the computer executing a program. Secondary storage hold permanent or semipermanent data on some external magnetic or optical medium.

2.1	Two parts of CPU

The Control Unit

The control unit contains circuitry that uses electrical signals to direct the entire computer system to carry out, or execute, stored program instructions. Like an orchestra leader, the control unit does not execute program instructions; rather, it directs other parts of the system to do so. The control unit must communicate with 
both the arithmetic/logic unit and memory.

The Arithmetic/Logic Unit

The arithmetic/logic unit (ALU) contains the 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. Besides, the ALU also performs logical operations. A logical operation is usually a comparison. The unit can compare numbers, letters, or special characters. The computer can then take action based on the result of the comparison. This is the very important capability. It is by comparing that a computer is able to tell, for  instance, whether there are unfilled seats on airplanes and whether charge-card customers have exceeded their credit limits.

Logical operations can test for three conditioned:

Equal-to condition. In a test for this condition, the ALU unit compares two values to determine if they are equal.

Less-than condition. To test for this condition, the computer compares values to determine if one is less than another. 

Greater-than condition. The computer determines if one value is greater than another.

Computer can simultaneously test for more than one condition. In logic unit can usually discern six logical relationships :        equal-to
						less than
						greater than
						less-greater than
						less than or equal to 
						greater than or equal to

The symbols that let you define the type of comparison you want the computer to perform are called relational operators.

2.2	Registers : Temporary Storage Areas

Registers are temporary storage areas for instruction or data and perform arithmetic and logical comparisons at high speed. Computers usually assign special roles to certain registers, including :

i) 	an accumulator, which collects the result of computations
ii) 	an address register, which keeps track 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.
iii) 	a storage register, which temporarily hold data taken from or about to be sent to memory
iv) 	A general-purpose register, which is used for several functions - arithmetic operations, for example.

Registers hold data immediately related to the operation being executed. Memory is used to hold data that will be used in the near future. Secondary storage holds data that may be needed later. 

For example: 
How a payroll program uses all three types of storage ?
The program calculates the salary of an employee. The data representing the hours worked and the data for the rate of the pay are ready in their respective registers. Other data related to the salary calculation - overtime hours, bonuses, deductions, and so forth - is waiting nearby in memory. The data for other employees is available in secondary storage. As the computer finishes calculations about one employee, the data about the next employee is brought from secondary storage into memory and eventually into the registers.

2.3 	Memory

Memory is also known as primary storage, primary memory, main storage, internal storage, and  main memory. 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 three reasons:

i) 	Most types of memory only store items while the computer is turned on; data is destroyed when the machine is turned off.
ii) 	If more than one program is running at once, a single program cannot lay exclusive claim to memory
iii) 	There may not be room in memory to hold the processed data.

How do data and instructions get from an input device into memory ?
The control unit sends them. 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 be released to an output unit.

The main characteristic of memory is that it allows very fast access to instructions and data, no matter where the items are within it.

2.4 	How the CPU executes program instructions ?

Most computers today can execute only one instruction at a time, though they execute it very quickly. 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 central processing unit performs the following four steps for each instruction:

1.	Fetches - The control unit fetches (gets) the instruction from memory.
2.	Decodes - The control unit decodes the instruction (decides what it means) 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.	Executes - The arithmetic/logic unit executes the arithmetic or logical instruction. That is, the ALU is given control and performs the actual operation on the data.
4.	Stores - The ALU 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 secondary device. The combination of I-time and E-time is called the machine cycle. 

Each central processing unit has an internal clock 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 subinstructions, each of which must 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 cannot understand the instruction set from another CPU. 

2.5 	   Storage Location and Addresses : How the Control Unit Finds 
Instructions and Data

As we already noted, instructions and data are somewhere in memory and the control unit able to find them. How does it do this ?

	The location in memory for each instruction and piece of data is identified by an address. That is, each location has an address number, 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. A memory location can hold only a fixed amount of data, an address can hold only one number or one word.

	Figure shows how a program manipulates data in memory. A payroll program, for example, may give instructions to put the rate of pay in location 3 and the number of hours worked in location 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 location is arbitrary - any locations that are not already spoken for can be used. Programmers using programming languages, however, do not 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 are Rate, Hours, and Salary.

2.6	

Data Representation : On / Off

Computers basically only know two things : on and off. This two-state on/off system is called a binary system. Using the two states, which can be represented by electricity turned on or off - the computer can construct sophisticated ways of representing data.
	The binary system has a base of 2. This means it contains only two digits, 0 and 1 , which correspond to the two states off and on. Combinations of 0s and 1s represent larger numbers.

BINARY EQUIVALENT OF DECIMAL NUMBERS 0-15

Decimal	Binary	
0	0000	
1	0001	
2	0010	
3	0011	
4	 0100	
5	0101	
6	0110	
7	0111	
8	1000	
9	1001	
10	1010	
11	1011	
12	1100	
13	1101	
14	1110	
15	1111	

Bits, Bytes and Words

Each 0 or 1 in the binary system is  called a bit ( for binary digit). The bit is the basic unit for storing data in computer memory - 0 means off, 1 means on. Notice that since a bit is always either on or off, a bit in  computer memory is always storing some kind of data. 
	Since single bits by themselves cannot store all the numbers, letters , and special characters (such as $ and ?) that a computer must process, the bits are put together in a group called a byte. There are usually 8 bits in a byte. Each byte usually represents one character of data - a letter, digit, or special character. 
	The number of bytes can be expressed as kilobytes. Kilo represents 2 to the tenth power (2 ), or 1024. Kilobytes is abbreviated KB. A kilobytes is 1024 bytes. Thus the memory of a 640K computer can store 640x1024 , or 655,360 bytes. Memory capacity may also be expressed in terms of megabytes (2   ). One megabyte, abbreviated  MB, means one million bytes. Gigabytes (abbreviated GB) - billions of bytes (2    )

	A computer word is defined as the number of bits that constitute a common unit of data, as defined by the computer system. The length of a word varies by computer. Common word lengths are 16 bits (for some personal computers), 32 bits (for mainframe computers, or newer personal computers), and 64 bits (for supercomputer).

Coding Schemes

A byte is a collection of bits and it represents a character of data. There are two most commonly used coding schemes for representing numbers , letters, and special characters: EBCDIC and ASCII.
	EBCDIC stands for Extended Binary Coded Decimal Interchange Code. Established by IBM and used in IBM mainframe computers, it uses 8 bits to represent a single character. The letter A , for instance, is represented by 11000001.
	Another code, ASCII, which stands for American Standard Code for Information Interchange, uses 7 bits for each character. For example, the letter A is represented by 10000001. The ASCII representation has been adopted as a standard government, and it is standard for a variety of computers - particularly minicomputers and personal computers by the US.
	One code that may be adopted on future computers is called Unicode. Unicode uses 16 bits to represent a character. This allows 65,536 different codes.

The Parity Bit

How do you know you data arrived safely ? Sometimes data is lost in transit, because of timing problems or hardware failure. To make sure the bits in a byte stay the way they are supposed to, another 0 or 1 bit is added to the byte before transmission. This extra bit is called a parity bit, or check bit. Thus in an 8-bit EBCDIC byte, the parity bit is the ninth bit.
	Here is how the system works: In an odd-parity system, a 0 or 1 is added to each EBCDIC byte before transmission so that the total number of 1 bits in each byte is an odd number. 

Then, if a 1 bit is lost in particular byte during transmission, the total number of 1 bits in that byte is even. Thus, the computer system is alerted, that something is wrong with that byte. Some computers use an odd-parity system and others use an even-parity system. The principle behind the two systems is the same, except that, in an even-parity system, the total number of 1 bits is even.

2.7	Personal Computer Chips

Microprocessor

A central processing unit, or processor, on a chip is a microprocessor, often called a logic chip when it is used to control specialized devices. Microprocessors usually contain four key components: a control unit and an arithmetic/logic unit, which together form the central processing unit, registers, buses, and a clock. (Clocks are often on a separate chip in personal computers). Notice that memory, which comes on its own chip or chips.

2.8  Memory Components

Historically, memory components have evolved from primitives vacuum tubes to today’s modern semiconductor .

Semiconductor storage

Most modern computers are semiconductor storage  because it has several advantages: reliability, compactness, low cost, and  power usage. Since semiconductor memory can be mass-produced economically, the cost of memory has been considerably reduced. Semiconductor storage has one major disadvantage: It is volatile - that is, semiconductor storage requires continues electric current to represent data. If the current is interrupted, the data is lost. 
	Semiconductor storage is made up of thousands of very small circuits - pathways for electric currents - on a silicon chip. A chip is described as monolithic because the circuits on a single chip compose an inseparable unit of storage. Each circuit etched on a chip can be in one of two states: either conducting an electric current or not - on or off. The two states can be used to represent the binary digits 1 and 0. As we noted earlier, these digits can be combined to represent characters, thus making the memory chip a storage bin for data and instructions.
	One important type of semiconductor design is called complementary metal oxide semiconductor (CMOS). This design is noted for using little electricity. This makes it useful for computers requiring low power consumption, such as portable computers.

2.9  RAM and ROM

Random-access memory (RAM) keeps the instruction and data for whatever program you happen to be using at the moment. RAM is usually volatile; this means that its contents are lost once the power is shut off. RAM can be erased or written over at will by the computer software.
	
	The more RAM in your computer, the larger the programs you can run. In recent years, the amount of RAM storage in a personal computer has increases dramatically. An early personal computer, for example, was advertised with “a full 4K RAM”. Now 8MB or even 16MB is common. More memory has became necessity because sophisticated personal computer software requires significant amounts of memory. You can augment your personal computer’s RAM by buying extra money chips to install in your memory board or by purchasing a single-in-line memory module (SIMM), a board that contains memory chips. The SIMM board plug into the computer’s main circuit board, which is more convenient than attaching individual chips. In general, the more memory your computer has, the more (bigger) tasks the computer can do. 
	RAM is often divided into two types: static RAM (SRAM) and dynamic RAM (DRAM). DRAM must be constantly refreshed (recharged) by the central processing unit or it will lose its contents. Although SRAM is faster, DRAM is used in most personal computer memory because of its size and cost advantages.

	Read-only memory (ROM) contains program and data that are permanently recorded into this type of memory at the factory ; they can be read and used, but they cannot be changed by the user. For example, a personal computer probably has a program for calculating square roots in ROM. ROM is nonvolatile - its contents do not disappear when the power is turned off.

	Using specialized tools called ROM burners, the instructions within some ROM chips can be changed. These chips are known as PROM chips, or programmable read-only memory chips. These are other variations on ROM chips, depending on the methods used to alter them. The business of programming and altering ROM chips is the province of the computer engineer.

2. 10  Speed and Power

What makes one computer faster than another ? Several factors are involved including microprocessor speed, bus line size, and the availability of cache. More sophisticated approaches to speed include flash memory, RISC computers, and parallel processing.

Computer Processing Speeds

Although all computers are fast, there is a wide diversity of computer speeds. The execution of an instruction on a very slow computer may be measured in less than a milisecond, which is one-thousandth of a second. Most computers can execute an instruction measured in microseconds, one-millionth of a second. Some modern computers have reached the nanosecond range - one-billionth of a second. Picosecond - one trillionth of a second.
	Microprocessor speeds are usually expressed in megahertz (MHz), millions of machine cycles per second. Thus, a personal computer listed at 25MHz has a processor capable of handling 25 million machine cycles per second. A top-speed personal computer will be many times faster.
	Another measure of computer speed is MIPS, which stands for one-million instructions per second. MIPS is often a more accurate measure than clock speed, because some computers can use each tick of the clock more differently than others. A third measure of speed is the megaflop, which one million floating-point operations per second. It measures the ability of the computer to perform complex mathematical operations.

Bus Lines

The computer term bus is borrowed from its common meaning - a mode of transportation. A bus line is a set of parallel electrical paths that internally transports data from one place to another within the computer system. The amount of data that can be carried at one time is called the bus width - the number of electrical paths. The greater the width - the more data can be carried at a time.
	In general, the larger the word size or bus, the more powerful the computer. A larger bus size means

1. 	The more data the computer can transfer at a time, making the computer faster.
2. 	 The larger the address numbers the computer can reference, allowing more memory.
3. 	 The greater the number and variety of instructions that the computer can support.

For example, the Intel 386 central processing unit processes data by using a 32 bit word size, but it comes in two versions. One version uses a 32-bit bus to communicate with memory; the other has only a 16-bit bus for memory. Obviously, sending data 32 bits at a time is more efficient than sending  it 16 bits at a time, so the computer with the 32-bit bus is more powerful (and more expensive!).

For example, a 486DX chip has a bus width of 32 whereas a 486SX chip uses a 32-bit bus within the processor but only 16-bit bus between the processor and memory. A buyer who cares about speed would prefer the DX chip, which carries exactly twice as much data and therefore is twice as fast as the SX chip.

Cache

A cache is a relatively amount of a very fast memory designed for the specific purpose of speeding up internal transfer of data and software instructions. The data and instruction s stored in cache are those that are most recently and frequently used. 
When the processor first requests data or instructions, these must be retrieved from main memory, which is delivered at a pace that is relatively slow compared to the microprocessor. As they are retrieved, those same data/instruction are stored in cache. The next time the microprocessor needs data or instructions, it looks first in cache; if the needed item can be found there, they can be transferred at the rate that far exceeds a trip from main memory. 
Of course, cache is not big enough to hold everything, so the wanted data or instructions may not be there. But there is a good chance that frequently used items will be in cache. That is, since the most frequently used data and instructions are kept in a handy place, the net result is an improvement in processing speed.

Flash Memory
	
	A speed has been the problem in accessing data from a secondary storage device such as a disk, slower than internal computer speeds. It seemed unimaginable that data might someday be stored on nonvolatile memory chip - nonvolatile RAM -close at hand. A breakthrough has emerged in the form of nonvolatile flash memory. Flash chips are currently being used in cellular phones and they are placing disks in some handheld computers.
	Flash memory chips are being produced in credit- cardlike packages, which are smaller than a disk drive, and require only half the power; that is why they are being used in notebook computers and the handheld personal digital assistants. Although flash memory is not yet commonplace, it seems likely that it will become  a mainstream component.

2.11  RISC Technology 

RISC - reduced instruction set computer - suggest that we could by with a little less. RISC offer only a small subset of instructions. On conventional computers (called CISC- complex instruction set computers), the instruction set is rarely used. Those instructions are underused, inefficient, and impediments to performance. RISC computers have more speed four to ten times than those of CISC computers. 

2.12  Parallel Processing

Parallel processing is a method of using several processor at the same time. Consider the description of computer processing you have seen so far. The processor gets an instruction from memory, acts on it, returns processed data to memory, and then repeats the process. This is conventional processing. The problem with the conventional computer is that the single electronic pathway, the bus line, acts like the bottleneck. The computer has a one-track mind because it is restricted to handling one piece of data at a time. For many applications, such as simulating the air flow around an entire airplane in flight, this is an exceedingly inefficient procedure. A better solution ? Many processors, each with its own memory unit, working at the same time: parallel processing.

	A number of parallel processors are being built and sold commercially. However, do not look for parallel processing in personal computers. So far, this technology is limited to larger computers.