12 CPU Structure and Function Computer Organization.
-
Upload
tracy-harvey -
Category
Documents
-
view
254 -
download
0
Transcript of 12 CPU Structure and Function Computer Organization.
![Page 1: 12 CPU Structure and Function Computer Organization.](https://reader030.fdocuments.net/reader030/viewer/2022033018/5697bf7d1a28abf838c84b13/html5/thumbnails/1.jpg)
12CPU Structure and Function
Computer Organization
![Page 2: 12 CPU Structure and Function Computer Organization.](https://reader030.fdocuments.net/reader030/viewer/2022033018/5697bf7d1a28abf838c84b13/html5/thumbnails/2.jpg)
CPU StructureCPU must:
Fetch instructionsInterpret instructionsFetch dataProcess dataWrite data
![Page 3: 12 CPU Structure and Function Computer Organization.](https://reader030.fdocuments.net/reader030/viewer/2022033018/5697bf7d1a28abf838c84b13/html5/thumbnails/3.jpg)
CPU With Systems Bus
![Page 4: 12 CPU Structure and Function Computer Organization.](https://reader030.fdocuments.net/reader030/viewer/2022033018/5697bf7d1a28abf838c84b13/html5/thumbnails/4.jpg)
CPU Internal Structure
![Page 5: 12 CPU Structure and Function Computer Organization.](https://reader030.fdocuments.net/reader030/viewer/2022033018/5697bf7d1a28abf838c84b13/html5/thumbnails/5.jpg)
RegistersCPU must have some working space
(temporary storage)Called registersNumber and function vary between
processor designsOne of the major design decisionsTop level of memory hierarchy
![Page 6: 12 CPU Structure and Function Computer Organization.](https://reader030.fdocuments.net/reader030/viewer/2022033018/5697bf7d1a28abf838c84b13/html5/thumbnails/6.jpg)
User Visible RegistersGeneral PurposeDataAddressCondition Codes
![Page 7: 12 CPU Structure and Function Computer Organization.](https://reader030.fdocuments.net/reader030/viewer/2022033018/5697bf7d1a28abf838c84b13/html5/thumbnails/7.jpg)
General Purpose Registers (1)
May be true general purposeMay be restrictedMay be used for data or addressingData
AccumulatorAddressing
Segment
![Page 8: 12 CPU Structure and Function Computer Organization.](https://reader030.fdocuments.net/reader030/viewer/2022033018/5697bf7d1a28abf838c84b13/html5/thumbnails/8.jpg)
General Purpose Registers (2)
Make them general purposeIncrease flexibility and programmer optionsIncrease instruction size & complexity
Make them specializedSmaller (faster) instructionsLess flexibility
![Page 9: 12 CPU Structure and Function Computer Organization.](https://reader030.fdocuments.net/reader030/viewer/2022033018/5697bf7d1a28abf838c84b13/html5/thumbnails/9.jpg)
How Many GP Registers?Between 8 - 32Fewer = more memory referencesMore does not reduce memory references
and takes up processor real estateSee also RISC
![Page 10: 12 CPU Structure and Function Computer Organization.](https://reader030.fdocuments.net/reader030/viewer/2022033018/5697bf7d1a28abf838c84b13/html5/thumbnails/10.jpg)
How big?Large enough to hold full addressLarge enough to hold full wordOften possible to combine two data
registersC programmingdouble int a;long int a;
![Page 11: 12 CPU Structure and Function Computer Organization.](https://reader030.fdocuments.net/reader030/viewer/2022033018/5697bf7d1a28abf838c84b13/html5/thumbnails/11.jpg)
Condition Code RegistersSets of individual bits
e.g. result of last operation was zeroCan be read (implicitly) by programs
e.g. Jump if zeroCan not (usually) be set by programs
![Page 12: 12 CPU Structure and Function Computer Organization.](https://reader030.fdocuments.net/reader030/viewer/2022033018/5697bf7d1a28abf838c84b13/html5/thumbnails/12.jpg)
Control & Status RegistersProgram CounterInstruction Decoding RegisterMemory Address RegisterMemory Buffer Register
Revision: what do these all do?
![Page 13: 12 CPU Structure and Function Computer Organization.](https://reader030.fdocuments.net/reader030/viewer/2022033018/5697bf7d1a28abf838c84b13/html5/thumbnails/13.jpg)
Program Status WordA set of bitsIncludes Condition CodesSign of last resultZeroCarryEqualOverflowInterrupt enable/disableSupervisor
![Page 14: 12 CPU Structure and Function Computer Organization.](https://reader030.fdocuments.net/reader030/viewer/2022033018/5697bf7d1a28abf838c84b13/html5/thumbnails/14.jpg)
Supervisor ModeIntel ring zeroKernel modeAllows privileged instructions to executeUsed by operating systemNot available to user programs
![Page 15: 12 CPU Structure and Function Computer Organization.](https://reader030.fdocuments.net/reader030/viewer/2022033018/5697bf7d1a28abf838c84b13/html5/thumbnails/15.jpg)
Other RegistersMay have registers pointing to:
Process control blocks (see O/S)Interrupt Vectors (see O/S)
N.B. CPU design and operating system design are closely linked
![Page 16: 12 CPU Structure and Function Computer Organization.](https://reader030.fdocuments.net/reader030/viewer/2022033018/5697bf7d1a28abf838c84b13/html5/thumbnails/16.jpg)
Example Register Organizations
![Page 17: 12 CPU Structure and Function Computer Organization.](https://reader030.fdocuments.net/reader030/viewer/2022033018/5697bf7d1a28abf838c84b13/html5/thumbnails/17.jpg)
Instruction CycleRevisionStallings Chapter 3
![Page 18: 12 CPU Structure and Function Computer Organization.](https://reader030.fdocuments.net/reader030/viewer/2022033018/5697bf7d1a28abf838c84b13/html5/thumbnails/18.jpg)
Indirect CycleMay require memory access to fetch
operandsIndirect addressing requires more memory
accessesCan be thought of as additional instruction
subcycle
![Page 19: 12 CPU Structure and Function Computer Organization.](https://reader030.fdocuments.net/reader030/viewer/2022033018/5697bf7d1a28abf838c84b13/html5/thumbnails/19.jpg)
Instruction Cycle with Indirect
![Page 20: 12 CPU Structure and Function Computer Organization.](https://reader030.fdocuments.net/reader030/viewer/2022033018/5697bf7d1a28abf838c84b13/html5/thumbnails/20.jpg)
Instruction Cycle State Diagram
![Page 21: 12 CPU Structure and Function Computer Organization.](https://reader030.fdocuments.net/reader030/viewer/2022033018/5697bf7d1a28abf838c84b13/html5/thumbnails/21.jpg)
Data Flow (Instruction Fetch)Depends on CPU designIn general:
FetchPC contains address of next instructionAddress moved to MARAddress placed on address busControl unit requests memory readResult placed on data bus, copied to MBR,
then to IRMeanwhile PC incremented by 1
![Page 22: 12 CPU Structure and Function Computer Organization.](https://reader030.fdocuments.net/reader030/viewer/2022033018/5697bf7d1a28abf838c84b13/html5/thumbnails/22.jpg)
Data Flow (Data Fetch)IR is examinedIf indirect addressing, indirect cycle is
performedRight most N bits of MBR transferred to MARControl unit requests memory readResult (address of operand) moved to MBR
![Page 23: 12 CPU Structure and Function Computer Organization.](https://reader030.fdocuments.net/reader030/viewer/2022033018/5697bf7d1a28abf838c84b13/html5/thumbnails/23.jpg)
Data Flow (Fetch Diagram)
![Page 24: 12 CPU Structure and Function Computer Organization.](https://reader030.fdocuments.net/reader030/viewer/2022033018/5697bf7d1a28abf838c84b13/html5/thumbnails/24.jpg)
Data Flow (Indirect Diagram)
![Page 25: 12 CPU Structure and Function Computer Organization.](https://reader030.fdocuments.net/reader030/viewer/2022033018/5697bf7d1a28abf838c84b13/html5/thumbnails/25.jpg)
Data Flow (Execute)May take many formsDepends on instruction being executedMay include
Memory read/writeInput/OutputRegister transfersALU operations
![Page 26: 12 CPU Structure and Function Computer Organization.](https://reader030.fdocuments.net/reader030/viewer/2022033018/5697bf7d1a28abf838c84b13/html5/thumbnails/26.jpg)
Data Flow (Interrupt)SimplePredictableCurrent PC saved to allow resumption after
interruptContents of PC copied to MBRSpecial memory location (e.g. stack
pointer) loaded to MARMBR written to memoryPC loaded with address of interrupt
handling routineNext instruction (first of interrupt handler)
can be fetched
![Page 27: 12 CPU Structure and Function Computer Organization.](https://reader030.fdocuments.net/reader030/viewer/2022033018/5697bf7d1a28abf838c84b13/html5/thumbnails/27.jpg)
Data Flow (Interrupt Diagram)
![Page 28: 12 CPU Structure and Function Computer Organization.](https://reader030.fdocuments.net/reader030/viewer/2022033018/5697bf7d1a28abf838c84b13/html5/thumbnails/28.jpg)
PrefetchFetch accessing main memoryExecution usually does not access main
memoryCan fetch next instruction during execution
of current instructionCalled instruction prefetch
![Page 29: 12 CPU Structure and Function Computer Organization.](https://reader030.fdocuments.net/reader030/viewer/2022033018/5697bf7d1a28abf838c84b13/html5/thumbnails/29.jpg)
Improved PerformanceBut not doubled:
Fetch usually shorter than executionPrefetch more than one instruction?
Any jump or branch means that prefetched instructions are not the required instructions
Add more stages to improve performance
![Page 30: 12 CPU Structure and Function Computer Organization.](https://reader030.fdocuments.net/reader030/viewer/2022033018/5697bf7d1a28abf838c84b13/html5/thumbnails/30.jpg)
PipeliningFetch instructionDecode instructionCalculate operands (i.e. EAs)Fetch operandsExecute instructionsWrite result
Overlap these operations
![Page 31: 12 CPU Structure and Function Computer Organization.](https://reader030.fdocuments.net/reader030/viewer/2022033018/5697bf7d1a28abf838c84b13/html5/thumbnails/31.jpg)
Two Stage Instruction Pipeline
![Page 32: 12 CPU Structure and Function Computer Organization.](https://reader030.fdocuments.net/reader030/viewer/2022033018/5697bf7d1a28abf838c84b13/html5/thumbnails/32.jpg)
Timing Diagram for Instruction Pipeline Operation
![Page 33: 12 CPU Structure and Function Computer Organization.](https://reader030.fdocuments.net/reader030/viewer/2022033018/5697bf7d1a28abf838c84b13/html5/thumbnails/33.jpg)
The Effect of a Conditional Branch on Instruction Pipeline Operation
![Page 34: 12 CPU Structure and Function Computer Organization.](https://reader030.fdocuments.net/reader030/viewer/2022033018/5697bf7d1a28abf838c84b13/html5/thumbnails/34.jpg)
Six Stage Instruction Pipeline
![Page 35: 12 CPU Structure and Function Computer Organization.](https://reader030.fdocuments.net/reader030/viewer/2022033018/5697bf7d1a28abf838c84b13/html5/thumbnails/35.jpg)
Alternative Pipeline Depiction
![Page 36: 12 CPU Structure and Function Computer Organization.](https://reader030.fdocuments.net/reader030/viewer/2022033018/5697bf7d1a28abf838c84b13/html5/thumbnails/36.jpg)
Speedup Factorswith InstructionPipelining
![Page 37: 12 CPU Structure and Function Computer Organization.](https://reader030.fdocuments.net/reader030/viewer/2022033018/5697bf7d1a28abf838c84b13/html5/thumbnails/37.jpg)
Dealing with BranchesMultiple StreamsPrefetch Branch TargetLoop bufferBranch predictionDelayed branching
![Page 38: 12 CPU Structure and Function Computer Organization.](https://reader030.fdocuments.net/reader030/viewer/2022033018/5697bf7d1a28abf838c84b13/html5/thumbnails/38.jpg)
Multiple StreamsHave two pipelinesPrefetch each branch into a separate
pipelineUse appropriate pipeline
Leads to bus & register contentionMultiple branches lead to further pipelines
being needed
![Page 39: 12 CPU Structure and Function Computer Organization.](https://reader030.fdocuments.net/reader030/viewer/2022033018/5697bf7d1a28abf838c84b13/html5/thumbnails/39.jpg)
Prefetch Branch TargetTarget of branch is prefetched in addition
to instructions following branchKeep target until branch is executedUsed by IBM 360/91
![Page 40: 12 CPU Structure and Function Computer Organization.](https://reader030.fdocuments.net/reader030/viewer/2022033018/5697bf7d1a28abf838c84b13/html5/thumbnails/40.jpg)
Loop BufferVery fast memoryMaintained by fetch stage of pipelineCheck buffer before fetching from memoryVery good for small loops or jumpsc.f. cacheUsed by CRAY-1
![Page 41: 12 CPU Structure and Function Computer Organization.](https://reader030.fdocuments.net/reader030/viewer/2022033018/5697bf7d1a28abf838c84b13/html5/thumbnails/41.jpg)
Loop Buffer Diagram
![Page 42: 12 CPU Structure and Function Computer Organization.](https://reader030.fdocuments.net/reader030/viewer/2022033018/5697bf7d1a28abf838c84b13/html5/thumbnails/42.jpg)
Branch Prediction (1)Predict never taken
Assume that jump will not happenAlways fetch next instruction 68020 & VAX 11/780VAX will not prefetch after branch if a page
fault would result (O/S v CPU design)Predict always taken
Assume that jump will happenAlways fetch target instruction
![Page 43: 12 CPU Structure and Function Computer Organization.](https://reader030.fdocuments.net/reader030/viewer/2022033018/5697bf7d1a28abf838c84b13/html5/thumbnails/43.jpg)
Branch Prediction (2)Predict by Opcode
Some instructions are more likely to result in a jump than thers
Can get up to 75% successTaken/Not taken switch
Based on previous historyGood for loops
![Page 44: 12 CPU Structure and Function Computer Organization.](https://reader030.fdocuments.net/reader030/viewer/2022033018/5697bf7d1a28abf838c84b13/html5/thumbnails/44.jpg)
Branch Prediction (3)Delayed Branch
Do not take jump until you have toRearrange instructions
![Page 45: 12 CPU Structure and Function Computer Organization.](https://reader030.fdocuments.net/reader030/viewer/2022033018/5697bf7d1a28abf838c84b13/html5/thumbnails/45.jpg)
Branch Prediction Flowchart
![Page 46: 12 CPU Structure and Function Computer Organization.](https://reader030.fdocuments.net/reader030/viewer/2022033018/5697bf7d1a28abf838c84b13/html5/thumbnails/46.jpg)
Branch Prediction State Diagram
![Page 47: 12 CPU Structure and Function Computer Organization.](https://reader030.fdocuments.net/reader030/viewer/2022033018/5697bf7d1a28abf838c84b13/html5/thumbnails/47.jpg)
Dealing With Branches
![Page 48: 12 CPU Structure and Function Computer Organization.](https://reader030.fdocuments.net/reader030/viewer/2022033018/5697bf7d1a28abf838c84b13/html5/thumbnails/48.jpg)
Intel 80486 Pipelining Fetch
From cache or external memory Put in one of two 16-byte prefetch buffers Fill buffer with new data as soon as old data consumed Average 5 instructions fetched per load Independent of other stages to keep buffers full
Decode stage 1 Opcode & address-mode info At most first 3 bytes of instruction Can direct D2 stage to get rest of instruction
Decode stage 2 Expand opcode into control signals Computation of complex address modes
Execute ALU operations, cache access, register update
Writeback Update registers & flags Results sent to cache & bus interface write buffers
![Page 49: 12 CPU Structure and Function Computer Organization.](https://reader030.fdocuments.net/reader030/viewer/2022033018/5697bf7d1a28abf838c84b13/html5/thumbnails/49.jpg)
80486 Instruction Pipeline Examples
![Page 50: 12 CPU Structure and Function Computer Organization.](https://reader030.fdocuments.net/reader030/viewer/2022033018/5697bf7d1a28abf838c84b13/html5/thumbnails/50.jpg)
Pentium 4 Registers
![Page 51: 12 CPU Structure and Function Computer Organization.](https://reader030.fdocuments.net/reader030/viewer/2022033018/5697bf7d1a28abf838c84b13/html5/thumbnails/51.jpg)
EFLAGS Register
![Page 52: 12 CPU Structure and Function Computer Organization.](https://reader030.fdocuments.net/reader030/viewer/2022033018/5697bf7d1a28abf838c84b13/html5/thumbnails/52.jpg)
Control Registers
![Page 53: 12 CPU Structure and Function Computer Organization.](https://reader030.fdocuments.net/reader030/viewer/2022033018/5697bf7d1a28abf838c84b13/html5/thumbnails/53.jpg)
MMX Register MappingMMX uses several 64 bit data typesUse 3 bit register address fields
8 registersNo MMX specific registers
Aliasing to lower 64 bits of existing floating point registers
![Page 54: 12 CPU Structure and Function Computer Organization.](https://reader030.fdocuments.net/reader030/viewer/2022033018/5697bf7d1a28abf838c84b13/html5/thumbnails/54.jpg)
Mapping of MMX Registers to Floating-Point Registers
![Page 55: 12 CPU Structure and Function Computer Organization.](https://reader030.fdocuments.net/reader030/viewer/2022033018/5697bf7d1a28abf838c84b13/html5/thumbnails/55.jpg)
Pentium Interrupt ProcessingInterrupts
MaskableNonmaskable
ExceptionsProcessor detectedProgrammed
Interrupt vector tableEach interrupt type assigned a numberIndex to vector table256 * 32 bit interrupt vectors
5 priority classes
![Page 56: 12 CPU Structure and Function Computer Organization.](https://reader030.fdocuments.net/reader030/viewer/2022033018/5697bf7d1a28abf838c84b13/html5/thumbnails/56.jpg)
PowerPC User Visible Registers
![Page 57: 12 CPU Structure and Function Computer Organization.](https://reader030.fdocuments.net/reader030/viewer/2022033018/5697bf7d1a28abf838c84b13/html5/thumbnails/57.jpg)
PowerPC Register Formats