Computer architecture Part IV Data Path and Control

80 29 0
Computer architecture Part IV Data Path and Control

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

Thông tin tài liệu

Part IV Data Path and Control Feb 2007 Computer Architecture, Data Path and Control Slide About This Presentation This presentation is intended to support the use of the textbook Computer Architecture: From Microprocessors to Supercomputers, Oxford University Press, 2005, ISBN 0-19-515455-X It is updated regularly by the author as part of his teaching of the upper-division course ECE 154, Introduction to Computer Architecture, at the University of California, Santa Barbara Instructors can use these slides freely in classroom teaching and for other educational purposes Any other use is strictly prohibited © Behrooz Parhami Edition Released Revised Revised Revised Revised First July 2003 July 2004 July 2005 Mar 2006 Feb 2007 Feb 2007 Computer Architecture, Data Path and Control Slide A Few Words About Where We Are Headed Performance = / Execution time simplified to / CPU execution time CPU execution time = Instructions × CPI / (Clock rate) Performance = Clock rate / ( Instructions × CPI ) Try to achieve CPI = with clock that is as high as that for CPI > designs; is CPI < feasible? (Chap 15-16) Design memory & I/O structures to support ultrahigh-speed CPUs (chap 17-24) Feb 2007 Define an instruction set; make it simple enough to require a small number of cycles and allow high clock rate, but not so simple that we need many instructions, even for very simple tasks (Chap 5-8) Computer Architecture, Data Path and Control Design hardware for CPI = 1; seek improvements with CPI > (Chap 13-14) Design ALU for arithmetic & logic ops (Chap 9-12) Slide IV Data Path and Control Design a simple computer (MicroMIPS) to learn about: • Data path – part of the CPU where data signals flow • Control unit – guides data signals through data path • Pipelining – a way of achieving greater performance Topics in This Part Chapter 13 Instruction Execution Steps Chapter 14 Control Unit Synthesis Chapter 15 Pipelined Data Paths Chapter 16 Pipeline Performance Limits Feb 2007 Computer Architecture, Data Path and Control Slide 13 Instruction Execution Steps A simple computer executes instructions one at a time • Fetches an instruction from the loc pointed to by PC • Interprets and executes the instruction, then repeats Topics in This Chapter 13.1 A Small Set of Instructions 13.2 The Instruction Execution Unit 13.3 A Single-Cycle Data Path 13.4 Branching and Jumping 13.5 Deriving the Control Signals 13.6 Performance of the Single-Cycle Design Feb 2007 Computer Architecture, Data Path and Control Slide 13.1 A Small Set of Instructions 31 R I op 25 rs 20 rt 15 rd 10 sh fn bits bits bits bits bits bits Opcode Source or base Source or dest’n Destination Unused Opcode ext imm Operand / Offset, 16 bits jta J Jump target address, 26 bits inst Instruction, 32 bits Fig 13.1 MicroMIPS instruction formats and naming of the various fields We will refer to this diagram later Seven R-format ALU instructions (add, sub, slt, and, or, xor, nor) Six I-format ALU instructions (lui, addi, slti, andi, ori, xori) Two I-format memory access instructions (lw, sw) Three I-format conditional branch instructions (bltz, beq, bne) Four unconditional jump instructions (j, jr, jal, syscall) Feb 2007 Computer Architecture, Data Path and Control Slide The MicroMIPS Instruction Set Copy Arithmetic Logic Memory access Control transfer Table 13.1 Feb 2007 Instruction Usage Load upper immediate Add Subtract Set less than Add immediate Set less than immediate AND OR XOR NOR AND immediate OR immediate XOR immediate Load word Store word Jump Jump register Branch less than Branch equal Branch not equal Jump and link System call lui rt,imm add rd,rs,rt sub rd,rs,rt slt rd,rs,rt addi rt,rs,imm slti rd,rs,imm and rd,rs,rt or rd,rs,rt xor rd,rs,rt nor rd,rs,rt andi rt,rs,imm ori rt,rs,imm xori rt,rs,imm lw rt,imm(rs) sw rt,imm(rs) j L jr rs bltz rs,L beq rs,rt,L bne rs,rt,L jal L syscall Computer Architecture, Data Path and Control op fn 15 0 10 0 0 12 13 14 35 43 Slide 32 34 42 36 37 38 39 12 13.2 The Instruction Execution Unit 31 beq,bne syscall R I 25 rs 20 rt 15 bits bits bits Opcode Source or base Source or dest’n rd 10 bits Destination sh fn 5 bits bits Unused Opcode ext bltz,jr jta j,jal rs,rt,rd PC imm Jump target address, 26 bits inst Instruction, 32 bits 22 instructions (rs) Reg file inst jta J 12 A/L, lui, lw,sw ALU Address Data Data cache (rt) imm op fn Control Fig 13.2 Abstract view of the instruction execution unit for MicroMIPS For naming of instruction fields, see Fig 13.1 Feb 2007 Operand / Offset, 16 bits Next addr Instr cache op Computer Architecture, Data Path and Control Slide 13.3 A Single-Cycle Data Path Incr PC Next addr jta Next PC ALUOvfl (PC) (rs) rs rt PC Instr cache inst rd 31 imm op Br&Jump Instruction fetch Fig 13.3 Feb 2007 Register writeback Ovfl Reg file ALU (rt) / 16 ALU out Data cache Data out Data in Func 32 SE / Data addr Register input fn RegDst RegWrite Reg access / decode ALUSrc ALUFunc ALU operation RegInSrc DataRead DataWrite Data access Key elements of the single-cycle MicroMIPS data path Computer Architecture, Data Path and Control Slide Const′Var Shift function Constant amount Amount 5 Variable amount 00 01 10 11 No shift Logical left Logical right Arith right Shifter Function class 32 LSBs Adder y or c0 32 k / c 31 x±y Shift Set less Arithmetic Logic imm 32 00 01 10 11 Shifted y x An ALU for MicroMIPS lui s MSB 32 32 Shorthand symbol for ALU Control c 32 x Func Add′Sub s ALU Logic unit AND OR XOR NOR 00 01 10 11 Ovfl y 32input NOR Zero Logic function Zero Ovfl Fig 10.19 A multifunction ALU with control signals (2 for function class, arithmetic, shift, logic) specifying the operation Feb 2007 Computer Architecture, Data Path and Control Slide 10 Hardware for Inserting Bubbles Stage Stage Stage Data hazard detector LoadPC (rs) rs Instr cache PC rt x2 Reg file (rt) Inst reg y2 Bubble Control signals from decoder All-0s t2 Controls or all-0s DataRead2 Fig 16.5 Data hazard detector for the pipelined MicroMIPS data path Feb 2007 Computer Architecture, Data Path and Control Slide 66 Augmentations to Pipelined Data Path and Control Branch predictor Next addr forwarders Hazard detector Stage Data cache forwarder Stage Stage Stage ALUOvfl PC Stage Next addr NextPC ALU forwarders inst Instr cache rs rt (rs) Ovfl Reg file imm SE Incr IncrPC Data cache ALU (rt) Data Data addr Address Func 1 rt rd 31 2 SeqInst Fig 15.10 Feb 2007 op RegDst Br&Jump fn ALUSrc RegWrite ALUFunc Computer Architecture, Data Path and Control DataRead RetAddr DataWrite RegInSrc Slide 67 16.3 Pipeline Branch Hazards Software-based solutions Compiler inserts a “no-op” after every branch (simple, but wasteful) Branch is redefined to take effect after the instruction that follows it Branch delay slot(s) are filled with useful instructions via reordering Hardware-based solutions Mechanism similar to data hazard detector to flush the pipeline Constitutes a rudimentary form of branch prediction: Always predict that the branch is not taken, flush if mistaken More elaborate branch prediction strategies possible Feb 2007 Computer Architecture, Data Path and Control Slide 68 16.4 Branch Prediction Predicting whether a branch will be taken • Always predict that the branch will not be taken • Use program context to decide (backward branch is likely taken, forward branch is likely not taken) • Allow programmer or compiler to supply clues • Decide based on past history (maintain a small history table); to be discussed later • Apply a combination of factors: modern processors use elaborate techniques due to deep pipelines Feb 2007 Computer Architecture, Data Path and Control Slide 69 Forward and Backward Branches Example 5.5 List A is stored in memory beginning at the address given in $s1 List length is given in $s2 Find the largest integer in the list and copy it into $t0 Solution Scan the list, holding the largest element identified thus far in $t0 lw addi loop: add beq add add add lw slt beq addi j done: Feb 2007 $t0,0($s1) $t1,$zero,0 $t1,$t1,1 $t1,$s2,done $t2,$t1,$t1 $t2,$t2,$t2 $t2,$t2,$s1 $t3,0($t2) $t4,$t0,$t3 $t4,$zero,loop $t0,$t3,0 loop # # # # # # # # # # initialize maximum to A[0] initialize index i to increment index i by if all elements examined, quit compute 2i in $t2 compute 4i in $t2 form address of A[i] in $t2 load value of A[i] into $t3 maximum < A[i]? if not, repeat with no change # if so, A[i] is the new # change completed; now repeat # continuation of the program Computer Architecture, Data Path and Control Slide 70 A Simple Branch Prediction Algorithm Taken Not taken Not taken Predict taken Taken Not taken Predict taken again Taken Predict not taken Not taken Predict not taken again Taken Fig 16.6 Four-state branch prediction scheme Example 16.1 L1: -10 iter’s -20 iter’s L2: br L2 -br L1 Feb 2007 Impact of different branch prediction schemes Solution Always taken: 11 mispredictions, 94.8% accurate 1-bit history: 20 mispredictions, 90.5% accurate 2-bit history: Same as always taken Computer Architecture, Data Path and Control Slide 71 Other Branch Prediction Algorithms Problem 16.3 Taken Not taken Not taken Part a Predict taken Taken Not taken Predict taken again Taken Part b Predict taken Taken Taken Not taken Predict not taken Not taken Taken Predict taken again Taken Predict not taken again Not taken Taken Predict not taken Not taken Predict not taken again Not taken Taken Not taken Not taken Fig 16.6 Predict taken Taken Not taken Predict taken again Taken Predict not taken Not taken Predict not taken again Taken Feb 2007 Computer Architecture, Data Path and Control Slide 72 Hardware Implementation of Branch Prediction Low-order bits used as index Addresses of recent branch instructions Target addresses History bit(s) Incremented PC Next PC Read-out table entry From PC Fig 16.7 Compare = Logic Hardware elements for a branch prediction scheme The mapping scheme used to go from PC contents to a table entry is the same as that used in direct-mapped caches (Chapter 18) Feb 2007 Computer Architecture, Data Path and Control Slide 73 16.5 Advanced Pipelining Deep pipeline = superpipeline; also, superpipelined, superpipelining Parallel instruction issue = superscalar, j-way issue (2-4 is typical) Stage Stage Stage Stage Stage Variable # of stages Stage q−2 Stage q−1 Stage q Function unit Instr cache Instr decode Operand prep Instr issue Function unit Function unit Instruction fetch Retirement & commit stages Fig 16.8 Dynamic instruction pipeline with in-order issue, possible out-of-order completion, and in-order retirement Feb 2007 Computer Architecture, Data Path and Control Slide 74 Performance Improvement for Deep Pipelines Hardware-based methods Lookahead past an instruction that will/may stall in the pipeline (out-of-order execution; requires in-order retirement) Issue multiple instructions (requires more ports on register file) Eliminate false data dependencies via register renaming Predict branch outcomes more accurately, or speculate Software-based method Pipeline-aware compilation Loop unrolling to reduce the number of branches Loop: Compute with index i Increment i by Go to Loop if not done Feb 2007 Loop: Compute with index i Compute with index i + Increment i by Go to Loop if not done Computer Architecture, Data Path and Control Slide 75 CPI Variations with Architectural Features Table 16.2 Effect of processor architecture, branch prediction methods, and speculative execution on CPI Architecture Methods used in practice CPI Nonpipelined, multicycle Strict in-order instruction issue and exec 5-10 Nonpipelined, overlapped In-order issue, with multiple function units 3-5 Pipelined, static In-order exec, simple branch prediction 2-3 Superpipelined, dynamic Out-of-order exec, adv branch prediction 1-2 Superscalar 2- to 4-way issue, interlock & speculation 0.5-1 Advanced superscalar 4- to 8-way issue, aggressive speculation 0.2-0.5 Need 100 for TIPS performance Need 10,000 for 100 TIPS Need 100,000 for PIPS Feb 2007 3.3 inst / cycle × Gigacycles / s ≅ 10 GIPS Computer Architecture, Data Path and Control Slide 76 Development of Intel’s Desktop/Laptop Micros In the beginning, there was the 8080; led to the 80x86 = IA32 ISA Half a dozen or so pipeline stages 80286 80386 80486 Pentium (80586) More advanced technology A dozen or so pipeline stages, with out-of-order instruction execution Pentium Pro Pentium II Pentium III Celeron More advanced technology Instructions are broken into micro-ops which are executed out-of-order but retired in-order Two dozens or so pipeline stages Pentium Feb 2007 Computer Architecture, Data Path and Control Slide 77 16.6 Dealing with Exceptions Exceptions present the same problems as branches How to handle instructions that are ahead in the pipeline? (let them run to completion and retirement of their results) What to with instructions after the exception point? (flush them out so that they not affect the state) Precise versus imprecise exceptions Precise exceptions hide the effects of pipelining and parallelism by forcing the same state as that of strict sequential execution (desirable, because exception handling is not complicated) Imprecise exceptions are messy, but lead to faster hardware (interrupt handler can clean up to offer precise exception) Feb 2007 Computer Architecture, Data Path and Control Slide 78 The Three Hardware Designs for MicroMIPS Incr PC Single-cycle Next addr jta Next PC ALUOvfl (PC) PC Instr cache inst rd 31 imm op Ovfl Reg file ALU (rt) / 16 30 / MSBs Inst Reg ALU out Data cache 1 rt rd 31 Cache (rs) Reg file Data Data Reg ALUZero ALUOvfl x Mux z Reg Zero Ovfl x Reg rs PC Data out Data in Func 32 SE / Data addr y Mux ×4 (rt) 32 y Reg SE / imm 16 / SysCallAddr jta Address (rs) rs rt 26 / Multicycle 30 ×4 ALU Func ALU out Register input fn Inst′Data Br&Jump RegInSrc DataRead DataWrite ALUSrc RegDst RegWrite ALUFunc 125 MHz CPI = Stage Stage inst Instr cache rs rt (rs) RegInSrc ALUSrcX RegWrite Stage ALUSrcY Stage Reg file Incr IncrPC JumpAddr 500 MHz CPI ≅ Data addr Data cache ALU imm SE PCSrc ALUFunc Ovfl (rt) Func 1 rt rd 31 2 SeqInst op Feb 2007 fn RegDst ALUOvfl PC 500 MHz CPI ≅ 1.1 IRWrite Stage Pipelined op MemWrite MemRead Next addr NextPC PCWrite Br&Jump RegDst fn ALUSrc RegWrite ALUFunc DataRead RetAddr DataWrite RegInSrc Computer Architecture, Data Path and Control Slide 79 Where Do We Go from Here? Memory Design: How to build a memory unit that responds in clock Input and Output: Peripheral devices, I/O programming, interfacing, interrupts Higher Performance: Vector/array processing Parallel processing Feb 2007 Computer Architecture, Data Path and Control Slide 80

Ngày đăng: 11/10/2021, 14:38

Mục lục

    A Few Words About Where We Are Headed

    IV Data Path and Control

    13.1 A Small Set of Instructions

    The MicroMIPS Instruction Set

    13.2 The Instruction Execution Unit

    13.3 A Single-Cycle Data Path

    An ALU for MicroMIPS

    13.5 Deriving the Control Signals

    Control Signals in the Single-Cycle Data Path

    Putting It All Together

Tài liệu cùng người dùng

  • Đang cập nhật ...

Tài liệu liên quan