Presentation is loading. Please wait.

Presentation is loading. Please wait.

CS 152 Computer Architecture and Engineering Lecture 8 Single-Cycle (Con’t) Designing a Multicycle Processor February 23, 2004 John Kubiatowicz (www.cs.berkeley.edu/~kubitron)

Similar presentations


Presentation on theme: "CS 152 Computer Architecture and Engineering Lecture 8 Single-Cycle (Con’t) Designing a Multicycle Processor February 23, 2004 John Kubiatowicz (www.cs.berkeley.edu/~kubitron)"— Presentation transcript:

1 CS 152 Computer Architecture and Engineering Lecture 8 Single-Cycle (Con’t) Designing a Multicycle Processor February 23, 2004 John Kubiatowicz (www.cs.berkeley.edu/~kubitron) lecture slides: http://inst.eecs.berkeley.edu/~cs152/

2 CS152 / Kubiatowicz Lec8.2 2/23/04©UCB Spring 2004 Recap: A Single Cycle Datapath °Rs, Rt, Rd and Imed16 hardwired into datapath from Fetch Unit °We have everything except control signals (underline) 32 ALUctr Clk busW RegWr 32 busA 32 busB 555 RwRaRb 32 32-bit Registers Rs Rt Rd RegDst Extender Mux 32 16 imm16 ALUSrc ExtOp Mux MemtoReg Clk Data In WrEn 32 Adr Data Memory 32 MemWr ALU Instruction Fetch Unit Clk Equal Instruction 0 1 0 1 01 Imm16RdRsRt nPC_sel

3 CS152 / Kubiatowicz Lec8.3 2/23/04©UCB Spring 2004 Recap: Flexible Instruction Fetch °Branch (nPC_sel = “Br”): if (Equal == 1) then PC = PC + 4 + SignExt[imm16]*4 ; else PC = PC + 4 °Other (nPC_sel = “+4”): PC=PC+4 °What is encoding of nPC_sel? Direct MUX select? Branch / not branch °Let’s choose second option Adr Inst Memory Adder PC Clk 00 Mux 4 nPC_sel imm16 Instruction 0 1 Equal nPC_MUX_sel

4 CS152 / Kubiatowicz Lec8.4 2/23/04©UCB Spring 2004 Recap: The Single Cycle Datapath during Add 32 ALUctr = Add Clk busW RegWr = 1 32 busA 32 busB 555 RwRaRb 32 32-bit Registers Rs Rt Rd RegDst = 1 Extender Mux 32 16 imm16 ALUSrc = 0 ExtOp = x Mux MemtoReg = 0 Clk Data In WrEn 32 Adr Data Memory 32 MemWr = 0 ALU Instruction Fetch Unit Clk Equal Instruction °R[rd] <- R[rs] + R[rt] 0 1 0 1 01 Imm16RdRsRt oprsrtrdshamtfunct 061116212631 nPC_sel= +4

5 CS152 / Kubiatowicz Lec8.5 2/23/04©UCB Spring 2004 Recap: The Single Cycle Datapath during Or Immediate 32 ALUctr = Or Clk busW RegWr = 1 32 busA 32 busB 555 RwRaRb 32 32-bit Registers Rs Rt Rd RegDst = 0 Extender Mux 32 16 imm16 ALUSrc = 1 ExtOp = 0 Mux MemtoReg = 0 Clk Data In WrEn 32 Adr Data Memory 32 MemWr = 0 ALU Instruction Fetch Unit Clk Equal Instruction °R[rt] <- R[rs] or ZeroExt[Imm16] 0 1 0 1 01 Imm16RdRsRt oprsrtimmediate 016212631 nPC_sel= +4

6 CS152 / Kubiatowicz Lec8.6 2/23/04©UCB Spring 2004 Recap: The Single Cycle Datapath during Load 32 ALUctr = Add Clk busW RegWr = 1 32 busA 32 busB 555 RwRaRb 32 32-bit Registers Rs Rt Rd RegDst = 0 Extender Mux 32 16 imm16 ALUSrc = 1 ExtOp = 1 Mux MemtoReg = 1 Clk Data In WrEn 32 Adr Data Memory 32 MemWr = 0 ALU Instruction Fetch Unit Clk Equal Instruction 0 1 0 1 01 Imm16RdRsRt °R[rt] <- Data Memory {R[rs] + SignExt[imm16]} oprsrtimmediate 016212631 nPC_sel= +4

7 CS152 / Kubiatowicz Lec8.7 2/23/04©UCB Spring 2004 Recap: The Single Cycle Datapath during Store 32 ALUctr = Add Clk busW RegWr = 0 32 busA 32 busB 555 RwRaRb 32 32-bit Registers Rs Rt Rd RegDst = x Extender Mux 32 16 imm16 ALUSrc = 1 ExtOp = 1 Mux MemtoReg = x Clk Data In WrEn 32 Adr Data Memory 32 MemWr = 1 ALU Instruction Fetch Unit Clk Equal Instruction 0 1 0 1 01 Imm16RdRsRt °Data Memory {R[rs] + SignExt[imm16]} <- R[rt] oprsrtimmediate 016212631 nPC_sel= +4

8 CS152 / Kubiatowicz Lec8.8 2/23/04©UCB Spring 2004 Recap: The Single Cycle Datapath during Branch 32 ALUctr =Sub Clk busW RegWr = 0 32 busA 32 busB 555 RwRaRb 32 32-bit Registers Rs Rt Rd RegDst = x Extender Mux 32 16 imm16 ALUSrc = 0 ExtOp = x Mux MemtoReg = x Clk Data In WrEn 32 Adr Data Memory 32 MemWr = 0 ALU Instruction Fetch Unit Clk Equal Instruction 0 1 0 1 01 Imm16RdRsRt °if (R[rs] - R[rt] == 0) then Zero <- 1 ; else Zero <- 0 oprsrtimmediate 016212631 nPC_sel= “Br”

9 CS152 / Kubiatowicz Lec8.9 2/23/04©UCB Spring 2004 Recap: A Summary of Control Signals inst Register Transfer ADDR[rd] <– R[rs] + R[rt];PC <– PC + 4 ALUsrc = RegB, ALUctr = “add”, RegDst = rd, RegWr, nPC_sel = “+4” SUBR[rd] <– R[rs] – R[rt];PC <– PC + 4 ALUsrc = RegB, ALUctr = “sub”, RegDst = rd, RegWr, nPC_sel = “+4” ORiR[rt] <– R[rs] + zero_ext(Imm16); PC <– PC + 4 ALUsrc = Im, Extop = “Z”, ALUctr = “or”, RegDst = rt, RegWr, nPC_sel = “+4” LOADR[rt] <– MEM[ R[rs] + sign_ext(Imm16)];PC <– PC + 4 ALUsrc = Im, Extop = “Sn”, ALUctr = “add”, MemtoReg, RegDst = rt, RegWr, nPC_sel = “+4” STOREMEM[ R[rs] + sign_ext(Imm16)] <– R[rs];PC <– PC + 4 ALUsrc = Im, Extop = “Sn”, ALUctr = “add”, MemWr, nPC_sel = “+4” BEQif ( R[rs] == R[rt] ) then PC <– PC + sign_ext(Imm16)] || 00 else PC <– PC + 4 nPC_sel = “Br”, ALUctr = “sub”

10 CS152 / Kubiatowicz Lec8.10 2/23/04©UCB Spring 2004 Step 5: Assemble Control logic ALUctr RegDst ALUSrc ExtOp MemtoRegMemWr Equal Instruction Imm16RdRsRt nPC_sel Adr Inst Memory DATA PATH Decoder Op Fun RegWr

11 CS152 / Kubiatowicz Lec8.11 2/23/04©UCB Spring 2004 A Summary of the Control Signals addsuborilwswbeq RegDst ALUSrc MemtoReg RegWrite MemWrite nPCsel ExtOp ALUctr 1 0 0 1 0 0 x Add 1 0 0 1 0 0 x Subtract 0 1 0 1 0 0 0 Or 0 1 1 1 0 0 1 Add x 1 x 0 1 0 1 x 0 x 0 0 1 x Subtract optarget address oprsrtrdshamtfunct 061116212631 oprsrt immediate R-type I-type J-type add, sub ori, lw, sw, beq jump func op00 0000 00 110110 001110 101100 0100 Appendix A 10 0000See10 0010 We Don’t Care :-)

12 CS152 / Kubiatowicz Lec8.12 2/23/04©UCB Spring 2004 The Concept of Local Decoding Main Control op 6 ALU Control (Local) func N 6 ALUop ALUctr 3 ALU R-typeorilwswbeq RegDst ALUSrc MemtoReg RegWrite MemWrite Branch ExtOp ALUop 1 0 0 1 0 0 x “R-type” 0 1 0 1 0 0 0 Or 0 1 1 1 0 0 1 Add x 1 x 0 1 0 1 x 0 x 0 0 1 x Subtract op00 000000 110110 001110 101100 0100

13 CS152 / Kubiatowicz Lec8.13 2/23/04©UCB Spring 2004 The Encoding of ALUop °ALUop has to be 2 bits wide to represent: (1) “R-type” instructions “I-type” instructions that require the ALU to perform: -(2) Or, (3) Add, and (4) Subtract Main Control op 6 ALU Control (Local) func N 6 ALUop ALUctr 3 R-typeorilwswbeq ALUop (Symbolic)“R-type”OrAdd Subtract ALUop 1 000 100 00 0 01

14 CS152 / Kubiatowicz Lec8.14 2/23/04©UCB Spring 2004 The Decoding of the “func” Field Main Control op 6 ALU Control (Local) func N 6 ALUop ALUctr 3 oprsrtrdshamtfunct 061116212631 R-type funct Instruction Operation 10 0000 10 0010 10 0100 10 0101 10 1010 add subtract and or set-on-less-than ALUctr ALU Operation 000 001 010 110 111 And Or Add Subtract Set-on-less-than P. 286 text: ALUctr ALU R-typeorilwswbeq ALUop (Symbolic)“R-type”OrAdd Subtract ALUop 1 000 100 00 0 01

15 CS152 / Kubiatowicz Lec8.15 2/23/04©UCB Spring 2004 The Truth Table for ALUctr R-typeorilwswbeq ALUop (Symbolic) “R-type”OrAdd Subtract ALUop 1 000 100 00 0 01 funct Instruction Op. 0000 0010 0100 0101 1010 add subtract and or set-on-less-than

16 CS152 / Kubiatowicz Lec8.16 2/23/04©UCB Spring 2004 Step 5: Logic for each control signal `define Rtype 6`b000000; `define BEQ 6`b000100; `defineOri6`b001101; `defineLoad6`b100011; `defineStore6`b101011; … etc … nPC_sel <= (OP == `BEQ) ? `Br : `plus4; ALUsrc <= (OP == `Rtype) ? `regB : `immed; ALUctr <= (OP == `Rtype`) ? funct : (OP == `ORi) ? `ORfunction : (OP == `BEQ) ? `SUBfunction : `ADDfunction; ExtOp <= (OP == `ORi) : `ZEROextend : `SIGNextend; MemWr <= (OP == `Store) ? 1 : 0; MemtoReg<= (OP == `Load) ? 1 : 0; RegWr: <= ((OP == `Store) || (OP == `BEQ)) ? 0 : 1; RegDst: <= ((OP == `Load) || (OP == `ORi)) ? 0 : 1;

17 CS152 / Kubiatowicz Lec8.17 2/23/04©UCB Spring 2004 The “Truth Table” for the Main Control R-typeorilwswbeq RegDst ALUSrc MemtoReg RegWrite MemWrite nPC_sel Jump ExtOp ALUop (Symbolic) 1 0 0 1 0 0 0 x “R-type” 0 1 0 1 0 0 0 0 Or 0 1 1 1 0 0 0 1 Add x 1 x 0 1 0 0 1 x 0 x 0 0 1 0 x Subtract op00 000000 110110 001110 101100 0100 ALUop 1000 0 0100 0 0000 1 Main Control op 6 ALU Control (Local) func 3 6 ALUop ALUctr 3RegDst ALUSrc :

18 CS152 / Kubiatowicz Lec8.18 2/23/04©UCB Spring 2004 The “Truth Table” for RegWrite R-typeorilwswbeqjump RegWrite111000 op00 000000 110110 001110 101100 010000 0010 °RegWrite = R-type + ori + lw = !op & !op & !op & !op & !op & !op (R-type) + !op & !op & op & op & !op & op (ori) + op & !op & !op & !op & op & op (lw) RegWrite

19 CS152 / Kubiatowicz Lec8.19 2/23/04©UCB Spring 2004 PLA Implementation of the Main Control RegWrite ALUSrc MemtoReg MemWrite Branch Jump RegDst ExtOp ALUop

20 CS152 / Kubiatowicz Lec8.20 2/23/04©UCB Spring 2004 Administrative Issues °Read Chapter 5 °This lecture and next one slightly different from the book °Design Document for lab 3 due in section this Thursday! Describe your division of labor Your testing methodology (how will you test each step of the way?) Top-level block diagrams °Midterm on Wednesday 3/10 5:30pm to 8:30pm, location TBA No class on that day : Pencil, calculator, one 8.5” x 11” (both sides) of handwritten notes °Meet at LaVal’s pizza after the midterm

21 CS152 / Kubiatowicz Lec8.21 2/23/04©UCB Spring 2004 The Big Picture: Where are We Now? °The Five Classic Components of a Computer °Today’s Topic: Designing the Datapath for the Multiple Clock Cycle Datapath Control Datapath Memory Processor Input Output

22 CS152 / Kubiatowicz Lec8.22 2/23/04©UCB Spring 2004 Abstract View of our single cycle processor °looks like a FSM with PC as state PC Next PC Register Fetch ALU Reg. Wrt Mem Access Data Mem Instruction Fetch Result Store ALUctr RegDst ALUSrc ExtOp MemWr Equal nPC_sel RegWr MemWr MemRd Main Control ALU control op fun Ext

23 CS152 / Kubiatowicz Lec8.23 2/23/04©UCB Spring 2004 What’s wrong with our CPI=1 processor? °Long Cycle Time °All instructions take as much time as the slowest °Real memory is not as nice as our idealized memory cannot always get the job done in one (short) cycle PCInst Memory mux ALUData Mem mux PCReg FileInst Memory mux ALU mux PCInst Memory mux ALUData Mem PCInst Memorycmp mux Reg File Arithmetic & Logical Load Store Branch Critical Path setup

24 CS152 / Kubiatowicz Lec8.24 2/23/04©UCB Spring 2004 Memory Access Time °Physics => fast memories are small (large memories are slow) question: register file vs. memory °=> Use a hierarchy of memories Storage Array selected word line address storage cell bit line sense amps address decoder Cache Processor 1 time-period proc. bus L2 Cache mem. bus 2-3 time-periods 20 - 50 time-periods memory

25 CS152 / Kubiatowicz Lec8.25 2/23/04©UCB Spring 2004 Reducing Cycle Time °Cut combinational dependency graph and insert register / latch °Do same work in two fast cycles, rather than one slow one °May be able to short-circuit path and remove some components for some instructions! storage element Acyclic Combinational Logic storage element Acyclic Combinational Logic (A) storage element Acyclic Combinational Logic (B) 

26 CS152 / Kubiatowicz Lec8.26 2/23/04©UCB Spring 2004 Worst Case Timing (Load) Clk PC Rs, Rt, Rd, Op, Func Clk-to-Q ALUctr Instruction Memoey Access Time Old ValueNew Value RegWrOld ValueNew Value Delay through Control Logic busA Register File Access Time Old ValueNew Value busB ALU Delay Old ValueNew Value Old ValueNew Value Old Value ExtOpOld ValueNew Value ALUSrcOld ValueNew Value MemtoRegOld ValueNew Value AddressOld ValueNew Value busWOld ValueNew Delay through Extender & Mux Register Write Occurs Data Memory Access Time

27 CS152 / Kubiatowicz Lec8.27 2/23/04©UCB Spring 2004 Basic Limits on Cycle Time °Next address logic PC <= branch ? PC + offset : PC + 4 °Instruction Fetch InstructionReg <= Mem[PC] °Register Access A <= R[rs] °ALU operation R <= A + B PC Next PC Operand Fetch Exec Reg. File Mem Access Data Mem Instruction Fetch Result Store ALUctr RegDst ALUSrc ExtOp MemWr nPC_sel RegWr MemWr MemRd Control

28 CS152 / Kubiatowicz Lec8.28 2/23/04©UCB Spring 2004 Partitioning the CPI=1 Datapath °Add registers between smallest steps °Place enables on all registers PC Next PC Operand Fetch Exec Reg. File Mem Access Data Mem Instruction Fetch Result Store ALUctr RegDst ALUSrc ExtOp MemWr nPC_sel RegWr MemWr MemRd Equal

29 CS152 / Kubiatowicz Lec8.29 2/23/04©UCB Spring 2004 Example Multicycle Datapath °Critical Path ? PC Next PC Operand Fetch Instruction Fetch nPC_sel IR Reg File Ext ALU Reg. File Mem Acces s Data Mem Result Store RegDst RegWr MemWr MemRd S M MemToReg Equal ALUctr ALUSrc ExtOp A B E

30 CS152 / Kubiatowicz Lec8.30 2/23/04©UCB Spring 2004 Recall: Step-by-step Processor Design Step 1: ISA => Logical Register Transfers Step 2: Components of the Datapath Step 3: RTL + Components => Datapath Step 4: Datapath + Logical RTs => Physical RTs Step 5: Physical RTs => Control

31 CS152 / Kubiatowicz Lec8.31 2/23/04©UCB Spring 2004 Step 4: R-rtype (add, sub,...) °Logical Register Transfer °Physical Register Transfers inst Logical Register Transfers ADDUR[rd] <– R[rs] + R[rt]; PC <– PC + 4 inst Physical Register Transfers IR <– MEM[pc] ADDUA<– R[rs]; B <– R[rt] S <– A + B R[rd] <– S; PC <– PC + 4 Exec Reg. File Mem Acces s Data Mem SM Reg File PC Next PC IR Inst. Mem Time A B E

32 CS152 / Kubiatowicz Lec8.32 2/23/04©UCB Spring 2004 Step 4: Logical immed °Logical Register Transfer °Physical Register Transfers inst Logical Register Transfers ORIR[rt] <– R[rs] OR ZExt(Im16); PC <– PC + 4 inst Physical Register Transfers IR <– MEM[pc] ORIA<– R[rs]; B <– R[rt] S <– A or ZExt(Im16) R[rt] <– S; PC <– PC + 4 Exec Reg. File Mem Acces s Data Mem SM Reg File PC Next PC IR Inst. Mem Time A B E

33 CS152 / Kubiatowicz Lec8.33 2/23/04©UCB Spring 2004 Step 4 : Load °Logical Register Transfer °Physical Register Transfers inst Logical Register Transfers LWR[rt] <– MEM[R[rs] + SExt(Im16)]; PC <– PC + 4 inst Physical Register Transfers IR <– MEM[pc] LWA<– R[rs]; B <– R[rt] S <– A + SExt(Im16) M <– MEM[S] R[rd] <– M; PC <– PC + 4 Exec Reg. File Mem Acces s Data Mem SM Reg File PC Next PC IR Inst. Mem A B E Time

34 CS152 / Kubiatowicz Lec8.34 2/23/04©UCB Spring 2004 Step 4 : Store °Logical Register Transfer °Physical Register Transfers inst Logical Register Transfers SWMEM[R[rs] + SExt(Im16)] <– R[rt]; PC <– PC + 4 inst Physical Register Transfers IR <– MEM[pc] SWA<– R[rs]; B <– R[rt] S <– A + SExt(Im16); MEM[S] <– BPC <– PC + 4 Exec Reg. File Mem Acces s Data Mem SM Reg File PC Next PC IR Inst. Mem A B E Time

35 CS152 / Kubiatowicz Lec8.35 2/23/04©UCB Spring 2004 Step 4 : Branch °Logical Register Transfer °Physical Register Transfers inst Logical Register Transfers BEQif R[rs] == R[rt] then PC <= PC + 4+SExt(Im16) || 00 else PC <= PC + 4 Exec Reg. File Mem Acces s Data Mem SM Reg File PC Next PC IR Inst. Mem inst Physical Register Transfers IR <– MEM[pc] BEQE<– (R[rs] = R[rt]) if !E then PC <– PC + 4 else PC <– PC+4+SExt(Im16)||00 A B E Time

36 CS152 / Kubiatowicz Lec8.36 2/23/04©UCB Spring 2004 Alternative datapath (book): Multiple Cycle Datapath °Miminizes Hardware: 1 memory, 1 adder Ideal Memory WrAdr Din RAdr 32 Dout MemWr 32 ALU 32 ALUOp ALU Control Instruction Reg 32 IRWr 32 Reg File Ra Rw busW Rb 5 5 32 busA 32busB RegWr Rs Rt Mux 0 1 Rt Rd PCWr ALUSelA Mux 01 RegDst Mux 0 1 32 PC MemtoReg Extend ExtOp Mux 0 1 32 0 1 2 3 4 16 Imm 32 << 2 ALUSelB Mux 1 0 Target 32 Zero PCWrCondPCSrcBrWr 32 IorD ALU Out

37 CS152 / Kubiatowicz Lec8.37 2/23/04©UCB Spring 2004 Our Control Model °State specifies control points for Register Transfer °Transfer occurs upon exiting state (same falling edge) Control State Next State Logic Output Logic inputs (conditions) outputs (control points) State X Register Transfer Control Points Depends on Input

38 CS152 / Kubiatowicz Lec8.38 2/23/04©UCB Spring 2004 Step 4  Control Specification for multicycle proc IR <= MEM[PC] R-type A <= R[rs] B <= R[rt] S <= A fun B R[rd] <= S PC <= PC + 4 S <= A or ZX R[rt] <= S PC <= PC + 4 ORi S <= A + SX R[rt] <= M PC <= PC + 4 M <= MEM[S] LW S <= A + SX MEM[S] <= B PC <= PC + 4 BEQ PC <= Next(PC,Equal) SW “instruction fetch” “decode / operand fetch” Execute Memory Write-back

39 CS152 / Kubiatowicz Lec8.39 2/23/04©UCB Spring 2004 Traditional FSM Controller State 6 4 11 next State op Equal control points stateopcond next state control points Truth Table datapath State

40 CS152 / Kubiatowicz Lec8.40 2/23/04©UCB Spring 2004 Step 5  (datapath + state diagram  control) °Translate RTs into control points °Assign states °Then go build the controller

41 CS152 / Kubiatowicz Lec8.41 2/23/04©UCB Spring 2004 Mapping RTs to Control Points IR <= MEM[PC] R-type A <= R[rs] B <= R[rt] S <= A fun B R[rd] <= S PC <= PC + 4 S <= A or ZX R[rt] <= S PC <= PC + 4 ORi S <= A + SX R[rt] <= M PC <= PC + 4 M <= MEM[S] LW S <= A + SX MEM[S] <= B PC <= PC + 4 BEQ PC <= Next(PC,Equal) SW “instruction fetch” “decode” imem_rd, IRen ALUfun, Sen RegDst, RegWr, PCen Aen, Ben, Een Execute Memory Write-back

42 CS152 / Kubiatowicz Lec8.42 2/23/04©UCB Spring 2004 Assigning States IR <= MEM[PC] R-type A <= R[rs] B <= R[rt] S <= A fun B R[rd] <= S PC <= PC + 4 S <= A or ZX R[rt] <= S PC <= PC + 4 ORi S <= A + SX R[rt] <= M PC <= PC + 4 M <= MEM[S] LW S <= A + SX MEM[S] <= B PC <= PC + 4 BEQ PC <= Next(PC) SW “instruction fetch” “decode” 0000 0001 0100 0101 0110 0111 1000 1001 1010 00111011 1100 Execute Memory Write-back

43 CS152 / Kubiatowicz Lec8.43 2/23/04©UCB Spring 2004 (Mostly) Detailed Control Specification (missing  0) 0000???????00011 0001BEQx00111 1 1 0001R-typex01001 1 1 0001ORIx01101 1 1 0001LWx10001 1 1 0001SWx10111 1 1 0011xxxxxx000001 0 x 0 x 0011xxxxxx100001 1 x 0 x 0100xxxxxxx01010 1 fun 1 0101xxxxxxx00001 0 0 1 1 0110xxxxxxx01110 0 or 1 0111xxxxxxx00001 0 0 1 0 1000xxxxxxx10011 0 add 1 1001xxxxxxx10101 0 1 1010 xxxxxxx00001 0 1 1 0 1011xxxxxxx11001 0 add 1 1100xxxxxxx0000 1 00 1 0 StateOp fieldEqNext IRPCOpsExecMemWrite-Back en selA B EEx Sr ALU S R W MM-R Wr Dst R: ORi: LW: SW: -all same in Moore machine BEQ:

44 CS152 / Kubiatowicz Lec8.44 2/23/04©UCB Spring 2004 Performance Evaluation °What is the average CPI? state diagram gives CPI for each instruction type workload gives frequency of each type TypeCPI i for typeFrequency CPI i x freqI i Arith/Logic440%1.6 Load530%1.5 Store410%0.4 branch320%0.6 Average CPI:4.1

45 CS152 / Kubiatowicz Lec8.45 2/23/04©UCB Spring 2004 Controller Design °The state digrams that arise define the controller for an instruction set processor are highly structured °Use this structure to construct a simple “microsequencer” °Control reduces to programming this very simple device  microprogramming sequencer control datapath control micro-PC sequencer microinstruction

46 CS152 / Kubiatowicz Lec8.46 2/23/04©UCB Spring 2004 Example: Jump-Counter op-code Map ROM Counter zero inc load 0000 i i+1 i None of above: Do nothing (for wait states)

47 CS152 / Kubiatowicz Lec8.47 2/23/04©UCB Spring 2004 Using a Jump Counter IR <= MEM[PC] R-type A <= R[rs] B <= R[rt] S <= A fun B R[rd] <= S PC <= PC + 4 S <= A or ZX R[rt] <= S PC <= PC + 4 ORi S <= A + SX R[rt] <= M PC <= PC + 4 M <= MEM[S] LW S <= A + SX MEM[S] <= B PC <= PC + 4 BEQ PC <= Next(PC) SW “instruction fetch” “decode” 0000 0001 0100 0101 0110 0111 1000 1001 1010 00111011 1100 inc load zero inc Execute Memory Write-back

48 CS152 / Kubiatowicz Lec8.48 2/23/04©UCB Spring 2004 Our Microsequencer op-code Map ROM Micro-PC Z I L datapath control taken

49 CS152 / Kubiatowicz Lec8.49 2/23/04©UCB Spring 2004 Microprogram Control Specification 0000?inc1 00010load1 1 00110zero1 0 00111zero1 1 0100xinc0 1 fun 1 0101xzero1 00 1 1 0110xinc0 0 or 1 0111xzero1 00 1 0 1000xinc1 0 add 1 1001xinc1 0 1 1010 xzero1 01 1 0 1011xinc1 0 add 1 1100xzero 1 00 1 0 µPC TakenNext IRPCOpsExecMemWrite-Back en selA B Ex Sr ALU S R W MM-R Wr Dst R: ORi: LW: SW: BEQ

50 CS152 / Kubiatowicz Lec8.50 2/23/04©UCB Spring 2004 Overview of Control °Control may be designed using one of several initial representations. The choice of sequence control, and how logic is represented, can then be determined independently; the control can then be implemented with one of several methods using a structured logic technique. Initial Representation Finite State Diagram Microprogram Sequencing ControlExplicit Next State Microprogram counter Function + Dispatch ROMs Logic RepresentationLogic EquationsTruth Tables Implementation PLAROM Technique “hardwired control”“microprogrammed control”

51 CS152 / Kubiatowicz Lec8.51 2/23/04©UCB Spring 2004 Summary °Disadvantages of the Single Cycle Processor Long cycle time Cycle time is too long for all instructions except the Load °Multiple Cycle Processor: Divide the instructions into smaller steps Execute each step (instead of the entire instruction) in one cycle °Partition datapath into equal size chunks to minimize cycle time ~10 levels of logic between latches °Follow same 5-step method for designing “real” processor

52 CS152 / Kubiatowicz Lec8.52 2/23/04©UCB Spring 2004 Summary (cont’d) °Control is specified by finite state digram °Specialize state-diagrams easily captured by microsequencer simple increment & “branch” fields datapath control fields °Control design reduces to Microprogramming °Control is more complicated with: complex instruction sets restricted datapaths (see the book) °Simple Instruction set and powerful datapath  simple control could try to reduce hardware (see the book) rather go for speed => many instructions at once!


Download ppt "CS 152 Computer Architecture and Engineering Lecture 8 Single-Cycle (Con’t) Designing a Multicycle Processor February 23, 2004 John Kubiatowicz (www.cs.berkeley.edu/~kubitron)"

Similar presentations


Ads by Google