copyright 1995-2005 suzanne tomlinson and curt hill 1 cpu the central processing unit
TRANSCRIPT
Copyright 1995-2005 Suzanne Tomlinson and Curt Hill 1
CPU CPU
The Central Processing The Central Processing UnitUnit
Copyright 1995-2005 Suzanne Tomlinson and Curt Hill 2
Computer DiagramComputer Diagram
Bus
Memory
Peripheral StorageDiskTape
CD/DVDNetwork
HCIKeyboardDisplayPointers
Cache
CPU
Copyright 1995-2005 Suzanne Tomlinson and Curt Hill 3
How the Pieces ConnectHow the Pieces Connect The CPU connects to all other pieces The CPU connects to all other pieces
of the computer through the Busof the computer through the Bus Memory is short term storageMemory is short term storage Peripherals (such as disk) are used Peripherals (such as disk) are used
for long term storagefor long term storage The bus is a group of communication The bus is a group of communication
lines between the CPU and other lines between the CPU and other piecespieces
Copyright 1995-2005 Suzanne Tomlinson and Curt Hill 4
CPU and CacheCPU and Cache
The CPU has increased in speed The CPU has increased in speed much faster than anything elsemuch faster than anything else
The cache is a short term memory The cache is a short term memory that keeps recently used itemsthat keeps recently used items
It keeps the CPU busy and off the It keeps the CPU busy and off the busbus
Copyright 1995-2005 Suzanne Tomlinson and Curt Hill 5
Two Principal Sections of Two Principal Sections of CPUCPU
Arithmetic/Logic UnitArithmetic/Logic Unit– Performs arithmetic (addition, Performs arithmetic (addition,
subtraction, multiplication and division)subtraction, multiplication and division)– Compares two items of data to determine Compares two items of data to determine
if equal, or which is larger (works on if equal, or which is larger (works on numbers or letters) called a logic numbers or letters) called a logic operationoperation
Control UnitControl Unit– Directs the flow of electronic traffic Directs the flow of electronic traffic
(coordinates computer's operation)(coordinates computer's operation)
Copyright 1995-2005 Suzanne Tomlinson and Curt Hill 6
Control UnitControl Unit
Controls ALU and MemoryControls ALU and Memory Fetches and decodes instructionsFetches and decodes instructions Directs data transfersDirects data transfers Has the ALU do operationsHas the ALU do operations Contains two important registers:Contains two important registers:
– Program Counter (PC)Program Counter (PC)– Instruction Register (IR)Instruction Register (IR)
Copyright 1995-2005 Suzanne Tomlinson and Curt Hill 7
RegistersRegisters Special temporary storage Special temporary storage
locations that act as locations that act as high-speedhigh-speed staging (loading) areasstaging (loading) areas
Part of the CPU, not main memoryPart of the CPU, not main memory Usually under direction of the Usually under direction of the
control unitcontrol unit Several types are availableSeveral types are available Each has a different purposeEach has a different purpose Some are accessible to Some are accessible to
programmerprogrammer
Copyright 1995-2005 Suzanne Tomlinson and Curt Hill 8
CPUCPU
Control Unit
Registers
Arithmetic Logic Unit
Registers
Copyright 1995-2005 Suzanne Tomlinson and Curt Hill 9
Register TypesRegister Types Program CounterProgram Counter Instruction RegisterInstruction Register StatusStatus AccumulatorAccumulator AddressAddress SegmentSegment IndexIndex General purposeGeneral purpose Stack PointerStack Pointer Floating pointFloating point
Copyright 1995-2005 Suzanne Tomlinson and Curt Hill 10
The IBM 360/370The IBM 360/370
16 General Purpose 32 bit16 General Purpose 32 bit– All integer arithmeticAll integer arithmetic– Indexing (except R0)Indexing (except R0)– Even/Odd pairs for 64 bitEven/Odd pairs for 64 bit
Program Status WordProgram Status Word– Program counter and status registerProgram counter and status register
8 Floating point registers8 Floating point registers Lots of inaccessible registersLots of inaccessible registers
Copyright 1995-2005 Suzanne Tomlinson and Curt Hill 11
Intel 8080Intel 8080 An 8 bit processor with 16 bit address An 8 bit processor with 16 bit address
space (64K)space (64K)– Itself an extension of 8008 and 4040Itself an extension of 8008 and 4040
Four 16 bit registers each partitioned Four 16 bit registers each partitioned into a High and Low 8 bitinto a High and Low 8 bit
AX (AL and AH) does most of arithmeticAX (AL and AH) does most of arithmetic BX is the Base registerBX is the Base register CX is Count registerCX is Count register DX is Data registerDX is Data register
– Connects to AX for double lengthConnects to AX for double length Stack PointerStack Pointer
Copyright 1995-2005 Suzanne Tomlinson and Curt Hill 12
Intel 8086Intel 8086 Four 16 bit general purpose (AX-DX)Four 16 bit general purpose (AX-DX)
– AX evolved from accumulatorAX evolved from accumulator Pointer and indexPointer and index
– Stack Pointer (SP)Stack Pointer (SP)– Base Pointer (BP)Base Pointer (BP)– Source Index (SI)Source Index (SI)
SegmentSegment– Code SegmentCode Segment– Stack SegmentStack Segment– Data SegmentData Segment– Extra SegmentExtra Segment
Copyright 1995-2005 Suzanne Tomlinson and Curt Hill 13
8086 Segments8086 Segments
Code Segment
Data Segment
Stack Segment
Stack Pointer
Code
Data
Stack
1 M
64K
64K
64K
Copyright 1995-2005 Suzanne Tomlinson and Curt Hill 14
Intel 80386 through Intel 80386 through PentiumsPentiums
Serious attempt to maintain Serious attempt to maintain upward compatibilityupward compatibility– Each model adds capabilitiesEach model adds capabilities
Register sizes increase to 32 bitRegister sizes increase to 32 bit AX becomes low order 16 bits of AX becomes low order 16 bits of
the 32 bit EAX the 32 bit EAX The maximum addressable The maximum addressable
memory increases memory increases Virtual memory has hardware Virtual memory has hardware
supportsupport
Copyright 1995-2005 Suzanne Tomlinson and Curt Hill 15
MemoryMemory Also called "main memory" or Primary Also called "main memory" or Primary
(internal) storage(internal) storage Closely associated with CPU but Closely associated with CPU but
physically separatedphysically separated Holds or storesHolds or stores
– Data and program instructions awaiting Data and program instructions awaiting processingprocessing
– Intermediate resultsIntermediate results– Processed output (ready to be Processed output (ready to be
transmitted to secondary storage or output transmitted to secondary storage or output devicedevice
Copyright 1995-2005 Suzanne Tomlinson and Curt Hill 16
Memory CharacteristicsMemory Characteristics
VolatileVolatile– Loses value when power is removedLoses value when power is removed
Has no historyHas no history– Only the last value is retained Only the last value is retained
Always has a valueAlways has a value– May be unknownMay be unknown
Each cell has a numbered addressEach cell has a numbered address
Copyright 1995-2005 Suzanne Tomlinson and Curt Hill 17
How can a piece of data be How can a piece of data be retrieved from memory?retrieved from memory?
Control Unit finds instructions or Control Unit finds instructions or data by the use of data by the use of addressesaddresses
Analogy - departmental mail boxes– Two things to noteTwo things to note
» One item only may be storedOne item only may be stored» Addresses are always numbersAddresses are always numbers
Tells where stored
Copyright 1995-2005 Suzanne Tomlinson and Curt Hill 18
Memory CommandsMemory Commands Memory interprets two commands:Memory interprets two commands:
– Read and WriteRead and Write Read requires an addressRead requires an address
– Returns the contentsReturns the contents Write requires an address and a Write requires an address and a
valuevalue– Changes the address to contain the Changes the address to contain the
valuevalue Unit is one byte (8 bits)Unit is one byte (8 bits)
– Several units may be ganged togetherSeveral units may be ganged together– 2, 4, 8 bytes2, 4, 8 bytes
Copyright 1995-2005 Suzanne Tomlinson and Curt Hill 19
Memory ExampleMemory Example
0 05
1 135
2 20
3 42
4 0
5 180
Copyright 1995-2005 Suzanne Tomlinson and Curt Hill 20
MemoryMemory
Short term storage of data occurs Short term storage of data occurs herehere
All data must be represented in All data must be represented in memorymemory
The organization of memory The organization of memory determines the data determines the data representationrepresentation
Copyright 1995-2005 Suzanne Tomlinson and Curt Hill 21
Data RepresentationData Representation
Binary - number system with two statesBinary - number system with two states– Two states (On or Off)Two states (On or Off)
Bits (BInary digiTS) each 0 or 1Bits (BInary digiTS) each 0 or 1 Organization (small to large)Organization (small to large)
– Bit (individual 1 or 0)Bit (individual 1 or 0)– Byte (made up of 7 or 8 bits and Byte (made up of 7 or 8 bits and
represents a character)represents a character)– Word (how much a computer can handle Word (how much a computer can handle
at one time - multiple bytes)at one time - multiple bytes)
Copyright 1995-2005 Suzanne Tomlinson and Curt Hill 22
ByteByte Represents a single character of dataRepresents a single character of data 7 or 8 bits (depending on code)7 or 8 bits (depending on code) Used to indicate machines' storage Used to indicate machines' storage
capacitycapacity– Kilobyte (KB) - equal to 1024 bytesKilobyte (KB) - equal to 1024 bytes– Megabyte (MB) - equals 1024Megabyte (MB) - equals 102422 bytes = bytes =
1,048,5761,048,576– Gigabyte (GB) - equals 1024Gigabyte (GB) - equals 102433 bytes bytes– Terabyte (TB) - equals 1024Terabyte (TB) - equals 102444 bytes bytes– Petabyte (PB) - equals 1024Petabyte (PB) - equals 102455 bytes bytes
Copyright 1995-2005 Suzanne Tomlinson and Curt Hill 23
WordWord
The number of bits that constitutes a The number of bits that constitutes a common unit of datacommon unit of data
Length varies by computerLength varies by computer– Common word lengthsCommon word lengths
»16 bits16 bits (micros, 286 and before)(micros, 286 and before)»32 bits32 bits (Pentiums, Power PC, (Pentiums, Power PC,
mainframes)mainframes)»64 bits64 bits (newer AMD micros, (newer AMD micros,
supercomputers)supercomputers)
Copyright 1995-2005 Suzanne Tomlinson and Curt Hill 24
DigitizationDigitization
Nothing can be processed by a Nothing can be processed by a computer unless it can be computer unless it can be converted to digital representationconverted to digital representation
Graphics – pixelsGraphics – pixels– CompressionCompression
Sounds – samplingSounds – sampling Music - MIDIMusic - MIDI Characters – character codesCharacters – character codes
Copyright 1995-2005 Suzanne Tomlinson and Curt Hill 25
Character CodesCharacter Codes
Mechanism to represent character Mechanism to represent character data numericallydata numerically
BCDBCD EBCDICEBCDIC ASCIIASCII UNICODEUNICODE
Copyright 1995-2005 Suzanne Tomlinson and Curt Hill 26
Machine CyclesMachine Cycles
Series of operations involved in the execution Series of operations involved in the execution of a single machine-level instructionof a single machine-level instruction
System clock - timing mechanism that System clock - timing mechanism that governs transmission of instructions and datagoverns transmission of instructions and data
Also known as Fetch-Execute CycleAlso known as Fetch-Execute Cycle Made up of two parts: Made up of two parts: I-cycle and E-cycleI-cycle and E-cycle Microcode - mechanism to tailor the Microcode - mechanism to tailor the
instruction set instruction set
Copyright 1995-2005 Suzanne Tomlinson and Curt Hill 27
Fetch-Execute cycle: I-Fetch-Execute cycle: I-cyclecycle
Take program counter and fetch Take program counter and fetch next instruction from memory next instruction from memory
Decode the particular instructionDecode the particular instruction Increment program counter to Increment program counter to
point at next instructionpoint at next instruction Fetch operandsFetch operands This part called I-cycle or I-timeThis part called I-cycle or I-time
Copyright 1995-2005 Suzanne Tomlinson and Curt Hill 28
Fetch-Execute Cycle: E-Fetch-Execute Cycle: E-cyclecycle
Execute the instructionExecute the instruction Store results (if needed)Store results (if needed) Go back to beginning and do it Go back to beginning and do it
againagain This is called the E-cycle or E-timeThis is called the E-cycle or E-time
Copyright 1995-2005 Suzanne Tomlinson and Curt Hill 29
Machine InstructionsMachine Instructions
ArithmeticArithmetic ComparisonComparison Input and OutputInput and Output JumpsJumps
Copyright 1995-2005 Suzanne Tomlinson and Curt Hill 30
Processing Speeds of Processing Speeds of cycle timescycle times
MillisecondsMilliseconds– Thousandths of a secondThousandths of a second
MicrosecondsMicroseconds– Millionths of a secondMillionths of a second
NanosecondsNanoseconds– Billionths of a secondBillionths of a second
PicosecondsPicoseconds– Trillionths of a secondTrillionths of a second
Copyright 1995-2005 Suzanne Tomlinson and Curt Hill 31
Speed RatingsSpeed Ratings Older micros rated in megahertz MHzOlder micros rated in megahertz MHz
– One MHz represents a million clock ticks per One MHz represents a million clock ticks per secondsecond» Original Apple ran at 1 MHzOriginal Apple ran at 1 MHz» Original IBM PC ran at 4.77 MHzOriginal IBM PC ran at 4.77 MHz
– Today - 2000 to 4500Today - 2000 to 4500» 2000 MHz is 2 GHz2000 MHz is 2 GHz
In mainframes rated in mipsIn mainframes rated in mips– One mip equals million instructions per secondOne mip equals million instructions per second
In supercomputers rates in mflopsIn supercomputers rates in mflops– One mflop equals million floating-point One mflop equals million floating-point
operations per secondoperations per second
Copyright 1995-2005 Suzanne Tomlinson and Curt Hill 32
Instruction FormatInstruction Format There are various components in each There are various components in each
machine language instructionmachine language instruction Operation codeOperation code
– Defines which instructionDefines which instruction OperandsOperands
– May be impliedMay be implied– RegisterRegister– Immediate dataImmediate data– Memory locationMemory location
Other thingsOther things– Masks or flagsMasks or flags– LengthsLengths
Copyright 1995-2005 Suzanne Tomlinson and Curt Hill 33
Instructions sizesInstructions sizes Instructions may be multiple sizes Instructions may be multiple sizes
or single sizesor single sizes Single sizeSingle size
– Easier to interpretEasier to interpret– Wastes bits Wastes bits
Multiple sizesMultiple sizes– More complicated CPU designMore complicated CPU design– Better packing in memoryBetter packing in memory