Computers6 Ch4 1

31
Mongolia International University The Central Processing Unit The Central Processing Unit Chapter 4 Chapter 4 B.M.H B.M.H

description

Chapter 4 (Part I)

Transcript of Computers6 Ch4 1

Page 1: Computers6 Ch4 1

Mongolia International University

The Central Processing UnitThe Central Processing Unit

Chapter 4Chapter 4

B.M.HB.M.H

Page 2: Computers6 Ch4 1

Computers MIU

Learning ObjectivesLearning Objectives

CPUCPU RegisterRegister MemoryMemory ComputerComputer’’s execution of s execution of

instructions instructions Data RepresentationData Representation

Page 3: Computers6 Ch4 1

Computers MIU

The CPU (Central Processing The CPU (Central Processing Unit)Unit)

A control centerA control center Converts Converts data inputdata input to to information outputinformation output

A highly complex, extensive set of A highly complex, extensive set of electronic circuitryelectronic circuitry Executes stored program instructionsExecutes stored program instructions

Two partsTwo parts The control unitThe control unit The arithmetic/logic unitThe arithmetic/logic unit

Intel pentium processor

Page 4: Computers6 Ch4 1

Computers MIU

Page 5: Computers6 Ch4 1

Computers MIU

The Control UnitThe Control Unit

Contains circuitry Contains circuitry uses electrical signals to direct the uses electrical signals to direct the

entire computer system to carry out entire computer system to carry out stored program instructionsstored program instructions

Does not execute program Does not execute program instructions;instructions; directs other parts of the system directs other parts of the system

execute program instructionsexecute program instructions Communicates with both the ALU Communicates with both the ALU

and memoryand memory

CPU

Page 6: Computers6 Ch4 1

Computers MIU

The Arithmetic/Logic Unit The Arithmetic/Logic Unit (ALU)(ALU)

Contains the electronic circuitry Contains the electronic circuitry that executes all arithmetic and logical that executes all arithmetic and logical

operationsoperations Arithmetic operations Arithmetic operations (mathematical calculation)(mathematical calculation)

Addition, Subtraction, Multiplication, Division Logical operations Logical operations (comparisons)(comparisons)

: Compare numbers, letters, or special characters to test the three conditions

Equal-to, Less-than, Greater-than condition

CPU

Page 7: Computers6 Ch4 1

Computers MIU

Logical operationsLogical operations

In addition to three basic conditionIn addition to three basic conditionThe computer can test forThe computer can test for Less-than-or-equal-to conditionLess-than-or-equal-to condition Greater-than-or-equal-to conditionGreater-than-or-equal-to condition Less-than-or-greater-than conditionLess-than-or-greater-than condition

: Not-equal-to

Relational operatorRelational operator The symbol that programmers use to tell the The symbol that programmers use to tell the

computer computer which type of comparison to performwhich type of comparison to perform The most common : =, <, >The most common : =, <, >

CPU

Page 8: Computers6 Ch4 1

Computers MIU

Data storage and the CPUData storage and the CPU

Two major types of storageTwo major types of storage Primary storage (memory)Primary storage (memory)

Holds data only temporarily A program is working directly with it

Secondary storageSecondary storage Holds permanent or semipermanent data on some external medium, such as a disk, until it is needed for processing by the computer

The CPU interacts closely with memoryThe CPU interacts closely with memoryreferring to it for both instructions and datareferring to it for both instructions and data

Page 9: Computers6 Ch4 1

Computers MIU

RegistersRegisters

Special storage areas for instructions and dataSpecial storage areas for instructions and data located within the CPU itselflocated within the CPU itself offer the advantage of speedoffer the advantage of speed; special-purpose, high-speed, temporary; special-purpose, high-speed, temporary

Work under the direction of the control unitWork under the direction of the control unit To accept, hold, and transfer instructions or To accept, hold, and transfer instructions or

datadata To perform arithmetic or logical comparisons To perform arithmetic or logical comparisons

atat high speed.high speed.

Page 10: Computers6 Ch4 1

Computers MIU

RegistersRegisters The kinds of Register

MBRMBR(Memory Buffer Register): all data come and go (Memory Buffer Register): all data come and go through this.through this.

MARMAR(Memory Address Register): for registering address (Memory Address Register): for registering address IRIR(Instruction Register): for registring current (Instruction Register): for registring current

implementing dataimplementing data

IRIR(Index Register): Decide corresponding address during (Index Register): Decide corresponding address during excuting instruction.excuting instruction.

GPRGPR(General Purpose Register): for general purpose(General Purpose Register): for general purpose BRBR(Base Register):register having base address of (Base Register):register having base address of

programprogram

Page 11: Computers6 Ch4 1

Computers MIU

Storage ComparisonStorage Comparison

RegistersRegisters Hold data that is Hold data that is immediatelyimmediately related to operation related to operation

being executedbeing executed

MemoryMemory Stores data that will be used Stores data that will be used in the near futurein the near future

Secondary storageSecondary storage Holds data that may be needed Holds data that may be needed

later in the same program execution or perhaps at some more remote time in the future

Page 12: Computers6 Ch4 1

Computers MIU

MemoryMemory

The part of computer The part of computer that holds data and instructions for that holds data and instructions for

processing.processing. Only stores them as long as the program is in Only stores them as long as the program is in

operationoperation Closely associated with the CPU, but separate from Closely associated with the CPU, but separate from

it.it.

Known as Known as primary storage (or memory), main storage (or primary storage (or memory), main storage (or

memory), internal storagememory), internal storage Manufactures often use the term Manufactures often use the term RAM RAM

Page 13: Computers6 Ch4 1

Computers MIU

MemoryMemory

Characteristics Characteristics Fast speed : Allow very fast access to Fast speed : Allow very fast access to

instructions and datainstructions and data Temporary : Most of types of memory store Temporary : Most of types of memory store

items only while the computer is turned on.items only while the computer is turned on.

Page 14: Computers6 Ch4 1

Mongolia International University

How the CPU executes How the CPU executes program instructions program instructions

Page 15: Computers6 Ch4 1

Computers MIU

Before an instructions Before an instructions executionsexecutions

In Memory In Memory The The necessary program instruction and datanecessary program instruction and data

must be placed from must be placed from input device or a input device or a secondary storage devicesecondary storage device

Then the CPU Then the CPU performs the four steps for each instruction performs the four steps for each instruction

Page 16: Computers6 Ch4 1

Computers MIU

Page 17: Computers6 Ch4 1

Computers MIU

Page 18: Computers6 Ch4 1

Computers MIU

Machine cycleMachine cycle

The four steps for each instructionThe four steps for each instruction

[ Instruction time (or I-time) ][ Instruction time (or I-time) ]1.1. The CU - fetches the instruction from memory and The CU - fetches the instruction from memory and - put it into a resister- put it into a resister2.2. The CU - decodes the instruction and The CU - decodes the instruction and - determines the memory location of the data - determines the memory location of the data

[ Execution time (or E-time) ][ Execution time (or E-time) ]3.3. The CU - moves the data from memory to registers in the The CU - moves the data from memory to registers in the

ALU. ALU. The ALU - executes the arithmetic or logical instruction.The ALU - executes the arithmetic or logical instruction.4.4. The CU - stores the result of this operation in memory or in a The CU - stores the result of this operation in memory or in a

registerregister

Always

Page 19: Computers6 Ch4 1

Computers MIU

Machine cycleMachine cycle

The combination of I-time and E-timeThe combination of I-time and E-time System clockSystem clock

produces pulsesproduces pulses at a fixed rate to synchronize all computer operations

Page 20: Computers6 Ch4 1

Computers MIU

Each location(of instruction and data) has address numberex) mailbox in front of apartment house

Address remains the same but the contents of locations may change when new instruction or data may be placed.

Fig4-4 shows how a program manipulates data in memory.

Storage Locations and Storage Locations and AddressesAddressesHow the control unit finds instructions and dataHow the control unit finds instructions and data

1 2 3

Rate

8

4

5 6

Hours

40

7 8

Salary

320

Employee’s salary

Instruction

Data in 3Ⅹ Data in 6

Move to 8

Page 21: Computers6 Ch4 1

Mongolia International University

Data RepresentationData Representation

Bits, Bytes and WordsBits, Bytes and Words

Coding SchemesCoding Schemes

Page 22: Computers6 Ch4 1

Computers MIU

Binary systemBinary system

Computers know only two things : on and off.Computers know only two things : on and off. Two state on/off system : Binary systemTwo state on/off system : Binary system

Has a base of ( ).Has a base of ( ). Contains only two digits, ( ) and ( ), which Contains only two digits, ( ) and ( ), which

correspond to the two states ( ) and ( ).correspond to the two states ( ) and ( ).

Decimal number systemDecimal number system Combination of 0s and 1s (ex. 0011, 0101)Combination of 0s and 1s (ex. 0011, 0101)

represent larger numbers.represent larger numbers.

Page 23: Computers6 Ch4 1

Computers MIU

Units:

bit Byte(8 bit) word(2 or 4 B)

KB(1,024 B) MB(1,024 KB) GB(1,024 MB)

0 1

N SNS

Physical Representation

+

1001102

32 4 2

3810=

32 16 8 4 2 1

Conversion(Bin → Dec) 0 1 2 3 4 5 6 7 8 91011121314151617

0 1 10 11 100 101 110 111 1000 1001 1010 1011 1100 1101 1110 11111000010001

0 1 2 3 4 5 6 7 8 9 A B C D E F1011

Dec Binary Hex

binary

digit28 = 2

56

Binary Equivalent of Decimal Numbers 0-17 Binary Equivalent of Decimal Numbers 0-17

Page 24: Computers6 Ch4 1

Computers MIU

Bits, Bytes, and WordsBits, Bytes, and Words

( ) ( ) Each 0 or 1 in the binary systemEach 0 or 1 in the binary system BiBinary diginary digitt Basic unit of storing data in computer memory: ( ) Basic unit of storing data in computer memory: ( )

means off, ( ) means on.means off, ( ) means on. ( )( )

The bits put together in a groupThe bits put together in a group A collection of bitsA collection of bits Most computers use ( )-bit bytes.Most computers use ( )-bit bytes. Each byte usually stores one character of data-letter, Each byte usually stores one character of data-letter,

digit, or special characterdigit, or special character

(ex. 00110000 : 0, 00101011 : + )(ex. 00110000 : 0, 00101011 : + )

Data RepresentationData Representation

Page 25: Computers6 Ch4 1

Computers MIU

The number of bytesThe number of bytes

The capacity of memory and storage The capacity of memory and storage is expressed in the number of ( ) that they contain.

TodayToday - PC Memory capacity : MB (128MB and more) - Secondary storage devices, mainframe memory : GB - Secondary storage on mainframes and network : TB

TermTerm AbbreviationAbbreviation Approximate Approximate NumberNumber

Exact NumberExact Number

KilobyteKilobyte KBKB 101033 2210 10 == 10241024

MegabyteMegabyte MBMB 101066 222020

GigabyteGigabyte GBGB 101099 224040

TerabyteTerabyte TBTB 10101212 228080

Bits, Bytes, and Bits, Bytes, and WordsWords Data RepresentationData Representation

Page 26: Computers6 Ch4 1

Computers MIU

( )( ) The size of registerThe size of register the number of bits the CPU processes as a unitthe number of bits the CPU processes as a unit The length varies by CPU.The length varies by CPU.

The larger the word, the more powerful the computer Today : 32 or 64 bits for most PC

Bits, Bytes, and WordsBits, Bytes, and WordsData RepresentationData Representation

Page 27: Computers6 Ch4 1

Computers MIU

Coding SchemesCoding Schemes

A byte can represent a character of dataA byte can represent a character of data Each byte contains ( ) bits, each of which Each byte contains ( ) bits, each of which

can hold a ( ) or 0.can hold a ( ) or 0. There are ( ) possible combination of 1s There are ( ) possible combination of 1s

and 0s in a byte.and 0s in a byte. ( ) or just code( ) or just code

: Assigns each one of those combinations to a : Assigns each one of those combinations to a specific character.specific character.

ASCIIASCII EBCDICEBCDIC UnicodeUnicode

Page 28: Computers6 Ch4 1

Computers MIU

ASCII, EBCDIC and ASCII, EBCDIC and UnicodeUnicode

ASCII codeASCII code American Standard Code for Information American Standard Code for Information

InterchangeInterchange The most widely used code Used on virtually all PCs and on many larger

system EBCDICEBCDIC

Extended Binary Coded Decimal Interchange Extended Binary Coded Decimal Interchange CodeCode Primarily on IBM and IBM-compatible mainframes

Textbook : Textbook : figure 4-7 on the page 4-108figure 4-7 on the page 4-108

Coding SchemesCoding Schemes

Page 29: Computers6 Ch4 1

Computers MIU

ASCII, EBCDIC and ASCII, EBCDIC and UnicodeUnicode

256-256-character capability of ASCII and EBCDICcharacter capability of ASCII and EBCDIC : sufficient for English and Western European languages: sufficient for English and Western European languages

: too small to handle the many different alphabets used : too small to handle the many different alphabets used throughout the rest of the worldthroughout the rest of the world

Unicode Unicode Designed to solve this problemDesigned to solve this problem Uses two bytes ( bits) to represent one characterUses two bytes ( bits) to represent one character The capability of representing 2The capability of representing 21616=65,536 =65,536

characters characters

- more than enough for all the world- more than enough for all the world’’s languagess languages Recognizes ASCII charactersRecognizes ASCII characters

Coding SchemesCoding Schemes

Page 30: Computers6 Ch4 1

Computers MIU

Short QuizShort Quiz1.1. ________ contains circuitry that uses electrical ________ contains circuitry that uses electrical

signals to direct the entire computer system to signals to direct the entire computer system to carry out stored program instructionscarry out stored program instructions

2.2. ________ contains the electronic circuitry that ________ contains the electronic circuitry that executes all arithmetic and logical operationsexecutes all arithmetic and logical operations

3.3. What are the four steps to executing instructions?What are the four steps to executing instructions?

4.4. What are the components of the CPU.What are the components of the CPU.

5.5. Your computer knows only two numbers, __ and Your computer knows only two numbers, __ and __. They mean ____ and _______. They mean ____ and _____

6.6. These two numbers are used in _______ code.These two numbers are used in _______ code.

7.7. One byte has how many bits?One byte has how many bits?

8.8. ALU stands for? ALU stands for?

9.9. What are 6 operations the ALU can do?What are 6 operations the ALU can do?

10.10. Bit stands for _______ digit?Bit stands for _______ digit?

Page 31: Computers6 Ch4 1

Computers MIU

ReviewReview

The CPUThe CPU’’s two parts are ( and ).s two parts are ( and ). Four kinds of arithmetic operations are Four kinds of arithmetic operations are

addition, subtraction, multiplication, divisionaddition, subtraction, multiplication, division Three kinds of Logical operationsThree kinds of Logical operations

Equal-to conditionEqual-to condition Less-than conditionLess-than condition Greater-than conditionGreater-than condition

( ) are special additional storage locations ( ) are special additional storage locations located within the CPU itself that offer the located within the CPU itself that offer the advantage of speedadvantage of speed