the central processing unit

59
opyright © Prentice Hall 2000 The Central Processing Unit Chapter 3 Chapter 3 What Goes on Inside the What Goes on Inside the Computer Computer

Upload: darrel-patel

Post on 01-Jan-2016

62 views

Category:

Documents


3 download

DESCRIPTION

The Central Processing Unit. Chapter 3 What Goes on Inside the Computer. Functions of Computer Systems. Recall that there are four main functions of computer systems:. Secondary Storage. Output. Input. Processing. Processing. - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: The Central Processing Unit

1Copyright © Prentice Hall 2000

The Central Processing Unit

Chapter 3Chapter 3

What Goes on Inside the What Goes on Inside the ComputerComputer

Page 2: The Central Processing Unit

2Copyright © Prentice Hall 2000

Functions of Computer Systems

Recall that there are four main Recall that there are four main functions of computer systems:functions of computer systems:

Input Processing Output

SecondaryStorage

Page 3: The Central Processing Unit

3Copyright © Prentice Hall 2000

Processing

In this chapter, we will focus on the In this chapter, we will focus on the central processing unit central processing unit (CPU) in (CPU) in more detail.more detail.

Input Processing Output

SecondaryStorage

Page 4: The Central Processing Unit

4Copyright © Prentice Hall 2000

The CPU

The The CPUCPU interacts interacts closely with closely with memorymemory (primary (primary storage).storage).

CPU

MemoryMemory, Memory, however, is not however, is not part of the CPU.part of the CPU.

Page 5: The Central Processing Unit

5Copyright © Prentice Hall 2000

Parts of the CPU

The CPU consists of a variety of parts The CPU consists of a variety of parts including:including:

Control Unit ALU

Registers

• Control unitControl unit

• Arithmetic/logic Arithmetic/logic unit (ALU)unit (ALU)

• RegistersRegisters

Page 6: The Central Processing Unit

6Copyright © Prentice Hall 2000

The Control Unit…

directsdirects the other parts of the the other parts of the computer system to execute stored computer system to execute stored program instructions.program instructions.

The control unit The control unit communicates with the communicates with the ALU and memory.ALU and memory.

Control Unit

Page 7: The Central Processing Unit

7Copyright © Prentice Hall 2000

The Arithmetic/Logic Unit (ALU)…

performs performs mathematical mathematical operations operations as well as as well as logicallogical operations. operations.

ALU

Page 8: The Central Processing Unit

8Copyright © Prentice Hall 2000

Mathematical Operations

The ALU can perform four kinds of The ALU can perform four kinds of mathematical calculations:mathematical calculations:

• additionaddition• subtractionsubtraction• multiplicationmultiplication• divisiondivision

Page 9: The Central Processing Unit

9Copyright © Prentice Hall 2000

Logical Operations

The ALU can perform logical The ALU can perform logical operations.operations.

Logical operations can test for these Logical operations can test for these conditions:conditions:

• Equal-to (=)Equal-to (=)• Less-than (<)Less-than (<)• Greater-than (>)Greater-than (>)

Page 10: The Central Processing Unit

10Copyright © Prentice Hall 2000

Equal-to Condition

In a test for this condition, the ALU In a test for this condition, the ALU compares two values to determine compares two values to determine if they are if they are equalequal..

If =

Then =

Page 11: The Central Processing Unit

11Copyright © Prentice Hall 2000

Less-than Condition

In a test for this condition, the ALU In a test for this condition, the ALU compares values to determine if one compares values to determine if one value is value is less thanless than another. another.

If =

Then <

Page 12: The Central Processing Unit

12Copyright © Prentice Hall 2000

Greater-than Condition

In a test for this condition, the ALU In a test for this condition, the ALU compares values to determine if compares values to determine if one value is one value is greater thangreater than another. another.

If =

Then >

Page 13: The Central Processing Unit

13Copyright © Prentice Hall 2000

Registers…

are temporary are temporary storage areas storage areas for data or for data or instructions.instructions.

Registers

Data held Data held temporarily in temporarily in registers can be registers can be accessed at accessed at greater speeds greater speeds than data stored than data stored in memory.in memory.

Page 14: The Central Processing Unit

14Copyright © Prentice Hall 2000

Memory (Primary Storage)

Memory is the Memory is the part of the part of the computer that computer that stores data stores data and program and program instructions for instructions for processing.processing.

CPU

Memory

Page 15: The Central Processing Unit

15Copyright © Prentice Hall 2000

Memory…

is also referred to is also referred to as as RAMRAM (random- (random-access memory).access memory).

CPU

MemoryRAM is RAM is temporarytemporary, , finitefinite, and more , and more expensiveexpensive than than secondary storage.secondary storage.

Page 16: The Central Processing Unit

16Copyright © Prentice Hall 2000

Executing Program Instructions

Before the CPU can execute Before the CPU can execute a program, program a program, program instructions and data must instructions and data must be placed into memory be placed into memory from an from an inputinput device or device or storagestorage device. device.

Input Processing

SecondaryStorage

Page 17: The Central Processing Unit

17Copyright © Prentice Hall 2000

Executing Program Instructions

Once the necessary data and Once the necessary data and instructions are in memory, the CPU instructions are in memory, the CPU performs the following steps for each performs the following steps for each instruction:instruction:

CPU

Memory

• FetchingFetching• DecodingDecoding• ExecutingExecuting• StoringStoring

Page 18: The Central Processing Unit

18Copyright © Prentice Hall 2000

Control Unit

ALU

Registers

Fetching Instructions

The control unit The control unit fetchesfetches (gets) (gets) the the instruction instruction from from memory.memory.

Memory

Page 19: The Central Processing Unit

19Copyright © Prentice Hall 2000

Decoding Instructions

The control unit The control unit decodes the decodes the instruction and instruction and directs that directs that the necessary the necessary data be data be moved from moved from memory to the memory to the ALU.ALU.

Control Unit ALU

Registers

Memory

Page 20: The Central Processing Unit

20Copyright © Prentice Hall 2000

Executing Arithmetic/Logic Operations

The ALU The ALU performs the performs the arithmetic or arithmetic or logical logical operation on operation on the data.the data.

Control Unit

ALU

Registers

Memory

Page 21: The Central Processing Unit

21Copyright © Prentice Hall 2000

Storing Results

The ALU stores The ALU stores the result of the result of its operation its operation on the data on the data in memory or in memory or in a register.in a register.

Control Unit

ALU

Registers

Memory

Page 22: The Central Processing Unit

22Copyright © Prentice Hall 2000

Executing Program Instructions

Eventually, the Eventually, the control unit sends control unit sends the results in the results in memory to an memory to an ououttput device or put device or secondary storage.secondary storage.

Output

SecondaryStorage

Control Unit

ALU

Registers

Memory

Page 23: The Central Processing Unit

23Copyright © Prentice Hall 2000

Instruction Time

The time it takes to fetch an instruction and The time it takes to fetch an instruction and decode it is called decode it is called instruction time.instruction time.

Memory

Control Unit

+Memory

Control Unit ALU

Page 24: The Central Processing Unit

24Copyright © Prentice Hall 2000

Execution Time

The time it takes to execute an ALU The time it takes to execute an ALU operation and then store the result is operation and then store the result is called called execution time.execution time.

+ALU

Memory

ALU

Registers

Page 25: The Central Processing Unit

25Copyright © Prentice Hall 2000

Machine Cycle

The combination of I-time and E-The combination of I-time and E-time is called the machine cycle.time is called the machine cycle.

E-time

Machine Cycle

I-time

Page 26: The Central Processing Unit

26Copyright © Prentice Hall 2000

Control Unit

Memory Locations and Addresses

The control unit The control unit can find data can find data and and instructions instructions because each because each location in location in memory has an memory has an addressaddress..

Memory

Page 27: The Central Processing Unit

27Copyright © Prentice Hall 2000

Storage Locations

Each location in Each location in memory is memory is identified by an identified by an addressaddress..

MemoryEach location has Each location has a unique address.a unique address.

Page 28: The Central Processing Unit

28Copyright © Prentice Hall 2000

Symbolic Addresses

The choice of the The choice of the location in location in memory is memory is arbitrary.arbitrary.

Memory

17

364

Pat

$

%

Addresses can Addresses can only hold oneonly hold one number number oror word. word.

Page 29: The Central Processing Unit

29Copyright © Prentice Hall 2000

Data Representation

The system in which all computer data is The system in which all computer data is represented and manipulated is called represented and manipulated is called the the binary system.binary system.

Page 30: The Central Processing Unit

30Copyright © Prentice Hall 2000

Binary System

The binary system has only The binary system has only two two digitsdigits to represent all values. to represent all values.

This corresponds to the This corresponds to the two statestwo states of a computer’s electrical system —of a computer’s electrical system —on and off.on and off.

Page 31: The Central Processing Unit

31Copyright © Prentice Hall 2000

Off/On Switches

The computer can represent data by The computer can represent data by constructing combinations of constructing combinations of off off oror on on switches.switches.

off onor

Page 32: The Central Processing Unit

32Copyright © Prentice Hall 2000

Zero or One?

The binary system can also be represented The binary system can also be represented by the digits by the digits zerozero and and oneone..

0 1or

Zero (off) and one (on) make up Zero (off) and one (on) make up the two digits in the binary system.the two digits in the binary system.

Page 33: The Central Processing Unit

33Copyright © Prentice Hall 2000

The Bit

Each 0 or 1 Each 0 or 1 in the in the binary binary system is system is called a called a bitbit..

one bit

two bits

three bits

Page 34: The Central Processing Unit

34Copyright © Prentice Hall 2000

The Byte

A group of 8 bitsA group of 8 bits is called a is called a bytebyte. .

0 0 0 0 01 1 1

Page 35: The Central Processing Unit

35Copyright © Prentice Hall 2000

One Character of Data

Each byte represents Each byte represents one character of one character of datadata (a letter, digit, or special (a letter, digit, or special character).character).

0 0 0 0 01 1 1

J=

Page 36: The Central Processing Unit

36Copyright © Prentice Hall 2000

Storing Bytes

Storage and memory capacity is Storage and memory capacity is expressed in the expressed in the number of bytesnumber of bytes they can hold:they can hold:

1 1 kilokilobyte = 2byte = 21010 or 1024 bytes or 1024 bytes1 1 megamegabyte = 2byte = 22020 or 1,048,576 bytes or 1,048,576 bytes1 1 gigagigabyte = 2byte = 23030 or 1,073,741,824 or 1,073,741,824 bytesbytes

Page 37: The Central Processing Unit

37Copyright © Prentice Hall 2000

Computer Word

A computer wordA computer word is defined as the is defined as the number of bits that constitute a number of bits that constitute a common unit of data.common unit of data.

Page 38: The Central Processing Unit

38Copyright © Prentice Hall 2000

Computer Word Length

Word length Word length varies by computer. For varies by computer. For example:example:

8 bits = 1 byte = one word length8 bits = 1 byte = one word length

64 bits = 8 bytes = one word length 64 bits = 8 bytes = one word length

Page 39: The Central Processing Unit

39Copyright © Prentice Hall 2000

Coding the Computer

A code for determining which group A code for determining which group of bits represent which characters of bits represent which characters on a keyboard is called on a keyboard is called ASCIIASCII..

Page 40: The Central Processing Unit

40Copyright © Prentice Hall 2000

ASCII

ASCII has been adopted, as the ASCII has been adopted, as the standard, by the U.S. government and standard, by the U.S. government and is found in a variety of computers.is found in a variety of computers.

0 0 0 0 01 1 1 J=ASCII-8 code Keyboard

character

Page 41: The Central Processing Unit

41Copyright © Prentice Hall 2000

Inside the Computer

The flat board within the personal The flat board within the personal computer that holds the computer computer that holds the computer circuitry is the circuitry is the motherboardmotherboard..

Page 42: The Central Processing Unit

42Copyright © Prentice Hall 2000

The Motherboard

The motherboard includes:The motherboard includes:• MicroprocessorMicroprocessor• Memory componentsMemory components

Page 43: The Central Processing Unit

43Copyright © Prentice Hall 2000

The Microprocessor…

is the CPU of the personal computer. is the CPU of the personal computer. It looks like a computer chip.It looks like a computer chip.

The microprocessor The microprocessor contains tiny contains tiny electronic switches electronic switches (transistors).(transistors).

Page 44: The Central Processing Unit

44Copyright © Prentice Hall 2000

Microprocessor Switches

If electric current passes through a If electric current passes through a transistor, the switch is transistor, the switch is onon..

If no current can pass, the switch is If no current can pass, the switch is offoff..

A combination of transistors can A combination of transistors can stand for a combination of bits.stand for a combination of bits.

Page 45: The Central Processing Unit

45Copyright © Prentice Hall 2000

Memory…

components are also chips.components are also chips.

This form of semiconductor This form of semiconductor memory stores data in binary memory stores data in binary form (off/on or zero/one).form (off/on or zero/one).

Storage can be Storage can be temporarytemporary (RAM) (RAM) or or permanentpermanent (ROM). (ROM).

Page 46: The Central Processing Unit

46Copyright © Prentice Hall 2000

RAM…

means random-access memory.means random-access memory.

RAM chips can be accessed RAM chips can be accessed easily and fast—regardless easily and fast—regardless of where the data is stored.of where the data is stored.

RAM is usually volatile storage in that if RAM is usually volatile storage in that if the power is shut off, the contents are the power is shut off, the contents are lost.lost.

Page 47: The Central Processing Unit

47Copyright © Prentice Hall 2000

ROM…

is read-only memory.is read-only memory.

ROM chips contain programs ROM chips contain programs and data that are permanently and data that are permanently etched on the chip.etched on the chip.

The contents do not disappear when The contents do not disappear when the power is turned off.the power is turned off.

Page 48: The Central Processing Unit

48Copyright © Prentice Hall 2000

Computer Speed and Power

Speed and power are determined Speed and power are determined by:by:

• Microprocessor speedMicroprocessor speed• Bus linesBus lines• CacheCache• Flash memoryFlash memory• RISCRISC• Parallel processingParallel processing

Page 49: The Central Processing Unit

49Copyright © Prentice Hall 2000

Microprocessor Speeds

Microprocessor speeds can be Microprocessor speeds can be measured in a variety of ways:measured in a variety of ways:

• MegahertzMegahertz• MIPSMIPS• MegaflopsMegaflops

Page 50: The Central Processing Unit

50Copyright © Prentice Hall 2000

Megahertz

One measure of microprocessor speed One measure of microprocessor speed is is megahertzmegahertz (MHz) which is one (MHz) which is one million machine cycles per second.million machine cycles per second.

Page 51: The Central Processing Unit

51Copyright © Prentice Hall 2000

MIPS

Another measure of microprocessor Another measure of microprocessor speed is speed is MIPSMIPS which is one million which is one million instructions per second.instructions per second.

Page 52: The Central Processing Unit

52Copyright © Prentice Hall 2000

Megaflops

Megaflops,Megaflops, or one million floating- or one million floating-point operations per second, is still point operations per second, is still another measure of another measure of microprocessor speed.microprocessor speed.

Page 53: The Central Processing Unit

53Copyright © Prentice Hall 2000

Bus Lines

A bus line is a set of parallel A bus line is a set of parallel electrical paths. A bus is like a electrical paths. A bus is like a mode of transportation for data.mode of transportation for data.

Page 54: The Central Processing Unit

54Copyright © Prentice Hall 2000

Bus Width

The amount of data that can be The amount of data that can be carried at one time is bus width carried at one time is bus width (wider = more data).(wider = more data).

Page 55: The Central Processing Unit

55Copyright © Prentice Hall 2000

Cache

Cache is a relatively small block of Cache is a relatively small block of very fast memory.very fast memory.

The data and instructions stored in The data and instructions stored in cache are those that are cache are those that are most most recently or most frequently usedrecently or most frequently used..

Cache speeds up the internal Cache speeds up the internal transfer of data and software transfer of data and software instructions.instructions.

Page 56: The Central Processing Unit

56Copyright © Prentice Hall 2000

Flash Memory

Accessing data and instructions from Accessing data and instructions from within the CPU is fast but not when within the CPU is fast but not when it comes from a secondary storage it comes from a secondary storage device.device.

Flash memory is Flash memory is nonvolatilenonvolatile (like (like secondary storage) but allows secondary storage) but allows fast fast accessaccess (like RAM). (like RAM).

Page 57: The Central Processing Unit

57Copyright © Prentice Hall 2000

RISC

New RISC computers have chips with New RISC computers have chips with fewer instructions as a means of fewer instructions as a means of making them run faster.making them run faster.

Older, slower machines have chips Older, slower machines have chips (called CISC) with instructions that (called CISC) with instructions that are seldom or never used.are seldom or never used.

Page 58: The Central Processing Unit

58Copyright © Prentice Hall 2000

Parallel Processing

Using several processors at the Using several processors at the same time (in parallel) greatly same time (in parallel) greatly increases processing speed.increases processing speed.

When parallel processing, the When parallel processing, the computer can be starting other computer can be starting other tasks before the sequence of fetch-tasks before the sequence of fetch-decode-execute-store is complete.decode-execute-store is complete.

Page 59: The Central Processing Unit

59Copyright © Prentice Hall 2000

Conclusion

Regardless of the design and Regardless of the design and processing strategy of a computer, processing strategy of a computer, its goal is the same: to turn raw its goal is the same: to turn raw data into useful information.data into useful information.