Copyright © 2003 by Prentice Hall Module 5 Central Processing Unit 1. Binary representation of data...

20
Copyright © 2003 by Copyright © 2003 by Prentice Hall Prentice Hall Module 5 Module 5 Central Processing Central Processing Unit Unit 1. Binary representation of data 1. Binary representation of data 2. The components of the CPU 2. The components of the CPU 3. CPU and Instruction set 3. CPU and Instruction set 4. Important features of CPUs 4. Important features of CPUs

Transcript of Copyright © 2003 by Prentice Hall Module 5 Central Processing Unit 1. Binary representation of data...

Copyright © 2003 by Prentice HallCopyright © 2003 by Prentice Hall

Module 5Module 5Central Processing UnitCentral Processing Unit

1. Binary representation of data1. Binary representation of data

2. The components of the CPU2. The components of the CPU

3. CPU and Instruction set 3. CPU and Instruction set

4. Important features of CPUs4. Important features of CPUs

22Module 5: CPUModule 5: CPU

Data representationData representationAll modern digital equipment work on binary digits, i.e., All modern digital equipment work on binary digits, i.e., 0, 1, based on the two states of a circuitry, e.g.0, 1, based on the two states of a circuitry, e.g.High voltage (ON): 1 Low voltage (Off) : 0 High voltage (ON): 1 Low voltage (Off) : 0

Why? Why? Simple, reliable, and available technologySimple, reliable, and available technology

CPU can only understand 0 and 1CPU can only understand 0 and 1

Data must be represented in binary form before it is Data must be represented in binary form before it is processed by a CPU processed by a CPU

How to representation number?How to representation number? Binary (base 2) number, containing only two digits, 0 and 1Binary (base 2) number, containing only two digits, 0 and 1

How to represent characters?How to represent characters?English text for exampleEnglish text for example

33Module 5: CPUModule 5: CPU

Binary numberBinary numberIn decimal (base 10) we indicate place values by the In decimal (base 10) we indicate place values by the order of digitsorder of digits135 = (1*10135 = (1*1022) + (3*10) + (3*1011) + (5*10) + (5*1000))

In binary number (base 2) representation, only two digits In binary number (base 2) representation, only two digits 0 and 1 are used, in a similar way as decimal numbers. 0 and 1 are used, in a similar way as decimal numbers.

10011 = (1*210011 = (1*244)+(0*2)+(0*233)+(0*2)+(0*222)+(1*2)+(1*211)+(1*2)+(1*200)) = 16 + 0 + 0 + 2 + 1= 16 + 0 + 0 + 2 + 1 = 19= 19

Octal number: base 8 representation, using eight digits: Octal number: base 8 representation, using eight digits: 0, 1, 2, …, 70, 1, 2, …, 7Hexadecimal number: base 16 representation, using Hexadecimal number: base 16 representation, using sixth digits: 0,1,2, 3, …, 9, A, B, C, D, E, F sixth digits: 0,1,2, 3, …, 9, A, B, C, D, E, F

44Module 5: CPUModule 5: CPU

Conversion between binary and decimalConversion between binary and decimal 10112 = (1x20)+(1x21)+(0x22)+(1x23)

= 1+2+0+8

= 11

Decimal to binary: repeatedly divide the quotient by 2, read Decimal to binary: repeatedly divide the quotient by 2, read the remainders backwardthe remainders backward

1110=10112 1910 = 100112

Q R

11/2 5 1

5/2 2 1

2/2 1 0

1/2 0 1

Q R

19/2 9 1

9/2 4 1

4/2 2 0

2/2 1 0

1/2 0 1

55Module 5: CPUModule 5: CPU

One binary digit can represents two numbers, One binary digit can represents two numbers, 0, 10, 1

Two binary digits can represent four numbers Two binary digits can represent four numbers 00, 01, 10, 1100, 01, 10, 11

0 1 2 30 1 2 3

Three binary digits can represent ___numbersThree binary digits can represent ___numbers

Fixed length binary representationFixed length binary representation

66Module 5: CPUModule 5: CPU

Example of 4 binary digits numbersExample of 4 binary digits numbers

77Module 5: CPUModule 5: CPU

Binary number factsBinary number facts

BitsBits RangeRange

88 0 to 20 to 288-1=-1=255255

1616 0 to 20 to 21616-1= 65 535-1= 65 535

3232 0 to 20 to 23232-1= 4 294 967 295-1= 4 294 967 295

6464 0 to 20 to 26464-1=18 446 744 073 709 551 615-1=18 446 744 073 709 551 615

It takes more digits to represent a number in binary than it does in decimal

88Module 5: CPUModule 5: CPU

Coding schemesCoding schemes

Provide a common way of representing a Provide a common way of representing a character of datacharacter of data

Common SchemesCommon Schemes ASCII, 7 bits: ASCII, 7 bits: Unicode, 16 bits: Unicode, 16 bits: EBCDIC, 8 bits: EBCDIC, 8 bits:

99Module 5: CPUModule 5: CPU

ASCIIASCII

Stands for American Standard Code for Stands for American Standard Code for Information InterchangeInformation Interchange

Most widely used standardMost widely used standard

Used on virtually all personal computersUsed on virtually all personal computers

1010Module 5: CPUModule 5: CPU

ASCII coding schemeASCII coding scheme7 bits, 127 different symbols7 bits, 127 different symbolsExamplesExamples

Dec Binary Dec Binary SymbolsSymbols

048 0110000 0048 0110000 0 049 0110001 1049 0110001 1 050 0110010 2050 0110010 2 051 0110011 3051 0110011 3 052 0110100 4052 0110100 4 053 0110101 5053 0110101 5 054 0110110 6054 0110110 6 055 0110111 7055 0110111 7 056 0111000 8056 0111000 8 057 0111001 9057 0111001 9 058 0111010 : (colon)058 0111010 : (colon) 059 0111011 ; (semi-colon)059 0111011 ; (semi-colon) 060 0111100 < (less than)060 0111100 < (less than) 061 0111101 = (equal sign)061 0111101 = (equal sign) 062 0111110 > (greater than)062 0111110 > (greater than) 063 0111111 ? (question mark)063 0111111 ? (question mark) 064 1000000 @ (AT symbol)064 1000000 @ (AT symbol)

065 1000001 A065 1000001 A 066 1000010 B066 1000010 B 067 1000011 C067 1000011 C 068 1000100 D068 1000100 D 069 1000101 E069 1000101 E 070 1000110 F070 1000110 F 071 1000111 G071 1000111 G 072 1001000 H072 1001000 H 073 1001001 I073 1001001 I 074 1001010 J074 1001010 J 075 1001011 K075 1001011 K 076 1001100 L076 1001100 L 077 1001101 M077 1001101 M 078 1001110 N078 1001110 N 079 1001111 O079 1001111 O 080 1010000 P080 1010000 P 081 1010001 Q081 1010001 Q 082 1010010 R082 1010010 R 083 1010011 S083 1010011 S 084 1010100 T084 1010100 T 085 1010101 U085 1010101 U 086 1010110 V086 1010110 V 087 1010111 W087 1010111 W 088 1011000 X088 1011000 X 089 1011001 Y089 1011001 Y 090 1011010 Z090 1011010 Z

1111Module 5: CPUModule 5: CPU

UnicodeUnicode

Designed to accommodate alphabets of Designed to accommodate alphabets of more than 256 charactersmore than 256 characters

Uses 16 bits to represent one characterUses 16 bits to represent one character 65,536 possible values65,536 possible values

Requires twice as much space to store Requires twice as much space to store datadata

1313Module 5: CPUModule 5: CPU

WordWord

The number of bits the CPU processes as The number of bits the CPU processes as a unita unit Typically a whole number of bytesTypically a whole number of bytes The larger the word, the more powerful the The larger the word, the more powerful the

computercomputer Personal computers typically 32 or 64 bits in Personal computers typically 32 or 64 bits in

lengthlength

1414Module 5: CPUModule 5: CPU

The units for information storage sizesThe units for information storage sizes

One kilobyte (1 KB) = 1024 (2One kilobyte (1 KB) = 1024 (21010) bytes = 2) bytes = 213 13 bitsbits Memory capacity of older personal computersMemory capacity of older personal computers

One Megabyte (1 MB) = 2One Megabyte (1 MB) = 220 20 bytes bytes ≈≈ 10 1066 bytes (one million bytes) bytes (one million bytes)

Personal computer memory Personal computer memory Portable storage devices (diskette, CD-ROM)Portable storage devices (diskette, CD-ROM)

One gigabyte (1 GB) = 2One gigabyte (1 GB) = 230 30 bytes bytes ≈≈ 10 1099 bytes (one billion bytes) bytes (one billion bytes)

Storage devices (hard drives)Storage devices (hard drives) Mainframe and network server memoryMainframe and network server memory

One terabyte (1 TB) = 2One terabyte (1 TB) = 240 40 bytes bytes ≈≈ 10 101212 bytes (one trillion bytes) bytes (one trillion bytes)

Storage devices on very large systemsStorage devices on very large systems

1515Module 5: CPUModule 5: CPU

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

Consists of complex set of electronic circuitry Consists of complex set of electronic circuitry

Executes stored program instructionsExecutes stored program instructions

Three componentsThree components RegistersRegisters Control unitControl unit Arithmetic/Logic Unit Arithmetic/Logic Unit

(ALU)(ALU) Control Unit

ALU

Registers

Memory

CPU

1616Module 5: CPUModule 5: CPU

RegistersRegisters

Registers: temporary place for instructions and Registers: temporary place for instructions and data. All instructions and data must be placed in data. All instructions and data must be placed in registers before being executed and processedregisters before being executed and processed

High-speed temporary storage areasHigh-speed temporary storage areas Storage locations located within the CPUStorage locations located within the CPU

Work under direction of control unitWork under direction of control unit Accept, hold, and transfer instructions or dataAccept, hold, and transfer instructions or data Keep track of where the next instruction to be Keep track of where the next instruction to be

executed or needed data is storedexecuted or needed data is stored

1717Module 5: CPUModule 5: CPU

Control unitControl unit

Control unit: directs the computer system to Control unit: directs the computer system to execute stored program instructionsexecute stored program instructions

Must communicate with memory and ALUMust communicate with memory and ALU

Storage operationsStorage operations Moving data/instructions from/to register to/from Moving data/instructions from/to register to/from

registers registers Sends data and instructions from secondary storage Sends data and instructions from secondary storage

to memory as neededto memory as needed

1818Module 5: CPUModule 5: CPU

ALUALU

Executes all arithmetic and logical Executes all arithmetic and logical operationsoperations Arithmetic operationsArithmetic operations

Addition, subtraction, multiplication, divisionAddition, subtraction, multiplication, division

Logical operationsLogical operationsCompare numbers, letters, or special charactersCompare numbers, letters, or special charactersTests for one of three conditionsTests for one of three conditions

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

Branch to different instructionsBranch to different instructions

1919Module 5: CPUModule 5: CPU

MemoryMemory

Also known as primary storage and main Also known as primary storage and main memorymemory Often expressed as random-access memory Often expressed as random-access memory

(RAM)(RAM) Not part of the CPUNot part of the CPU

Holds data and instructions for processingHolds data and instructions for processing

Stores information only as long as the Stores information only as long as the program is in operationprogram is in operation

2020Module 5: CPUModule 5: CPU

The CPU and memoryThe CPU and memory

CPU cannot process data from disk or input CPU cannot process data from disk or input devicedevice It must first reside in memoryIt must first reside in memory Control unit retrieves data from disk and moves it into Control unit retrieves data from disk and moves it into

memorymemory

Items sent to ALU for processingItems sent to ALU for processing Control unit sends items to ALU, then sends back to Control unit sends items to ALU, then sends back to

memory after processingmemory after processing

Data and instructions held in memory until sent Data and instructions held in memory until sent to an output or storage device or program is shut to an output or storage device or program is shut downdown

2121Module 5: CPUModule 5: CPU

Data storage and the CPUData storage and the CPU

Two types of storage:Two types of storage: Primary storage (memory)Primary storage (memory)

Stores data temporarilyStores data temporarily

CPU refers to it for both program instructions and CPU refers to it for both program instructions and datadata

Secondary storageSecondary storageLong-term storageLong-term storage

Stored on external medium, such as a diskStored on external medium, such as a disk