Computer Organization & Design The Hardware/Software Interface Chapter 5 The processor : Datapath and control

Size: px
Start display at page:

Download "Computer Organization & Design The Hardware/Software Interface Chapter 5 The processor : Datapath and control"

Transcription

1 Computer Organization & Design The Hardware/Software Interface Chapter 5 The processor : Datapath and control Qing-song Shi zjsqs@zju.edu.cn

2 Chapter 5 The processor : Datapath and control

3 Chapter Five The processor : Datapath and control 5. Introduction 5.2 Logic Design Conventions (skip) 5.3 Building a datapath 5.4 A Simple Implementation Scheme 5.5 A ulticycle Implementation 5.5 icroprogramming 5.6 Exception

4 What is the IPS? icroprocessor without Interlocked Pipeline Stages

5 5. Introduction We ll look at an implementation of the IPS Simplified to contain only: memory-reference instructions: lw, sw arithmetic-logical instructions: add, sub, and, or, slt What are steps? control flow instructions: beq, j How many FUN.? An Overview of the implementation For every insruction, the first two step are identical. Fetch the instruction from the memory 2. Decode and read the registers Next steps depend on the instruction class emory-refrernce Arithmetic-logical branches

6 Computer Organization Control unit CPU Path: multiplexors 计算机 emory Datapath ALU Registers I/O interface

7 An abstract view of the implementation of IPS 4 Add PC address memory register register 2 Write register Write data RegWrite Registers data data 2 ALUSrc u x 3 ALU operation Zero ALU ALU result Address Write data emwrite data Data memory emtoreg u x 6 Sign 32 extend em

8 Chapter Five The processor : Datapath and control 5. Introduction 5.2 Logic Design Conventions (skip) 5.3 Building a datapath 5.4 A Simple Implementation Scheme 5.5 A ulticycle Implementation 5.5 icroprogramming 5.6 Exception

9 State Elements Unclocked vs. Clocked Clocks used in synchronous logic when should an element that contains state be updated? falling edge cycle time rising edge

10 Our Implementation An edge triggered methodology Typical execution: read contents of some state elements, send values through some combinational logic write results to one or more state elements State element Com binational logic State element 2 Clock cycle

11 D-Latch for state D C D S R Q(t + ) X X X hold C Q=:reset Q=:reset S R Q Q C D Q(t + ) X hold Q=:reset Q=:set D-Latch FUN. table D Q C Q D-Latch symbol

12 Chapter Five The processor : Datapath and control 5. Introduction 5.2 Logic Design Conventions (skip) 5.3 Building a datapath 5.4 A Simple Implementation Scheme 5.5 A ulticycle Implementation 5.5 icroprogramming 5.6 Exception

13 The datapath there are Name Example Comments 32 register 3 Word Addresses signals line $s-$s7,$t-$t9, $zero,$a-$a3, $v-$v emory[], emory[4],, enory[ ] Fast locations for data. In IPS, data must be in registers to perform arithmetic. IPS register $zero always equals. $gp(28) is the global pointer, $sp(29) is the stack pointer, $fp(3) is the frame pointer, and $ra(3) is the return address. Accessed only by data transfer instructions. IPS uses byte addresses, so sequential word addresses differ by 4. emory holds data structures, arrays, and spilled registers, such as those saved on procedure calls. Name Register no. Usage Preserved on call $zero The constant value n,.a. $v-$v 2-3 Values for results and expression evaluation no $a-$a3 4-7 Arguments no $t-$t7 8-5 Temporaries no $s-$s Saved yes $t8-$t ore temporaries no $gp 28 Global pointer yes $sp 29 Stack pointer yes $fp 3 Framer pointer yes $ra 3 Return address yes

14 ALU OP for IPS machine language Name Format Example Comment add R add $s, $s2, $s3 sub R sub $s, $s2, $s3 lw I lw $s, ($s2) sw I sw $s, ($s2) and R and $s, $s2, $s3 or R or $s, $s2, $s3 nor R nor $s, $s2, $s3 addi I addi $s, $s2, ori I ori $s, $s2, beq I beq $s, $s2, bne I bne $s, $s2, slt R slt $s, $s2,$s3 j J 2 25 j (see section 2.9) jr R 3 8 j Sra jal J 3 25 jar (see section 2.9) Field size 6bits 5bits 5bits 5bits 5bits 6bits All IPS instruction 32 bits R-format R op rs rt rd shamt funct Arithmetic instruction format i-format I op rs rt address Data transfer,branch format

15 execution in IPS Fetch : Take instructions from the instruction memory odify PC to point the next instruction decoding & Operand: Will be translated into machine control command ing Register Operands, whether or not to use Executive Control: Control the implementation of the corresponding ALU operation emory access: Write or data from memory Only LW/SW Write results to register: If it is R-type instructions, ALU results are written to Rd If it is I-type instructions, Results are written to Rt

16 fetching three elements How to connect? Who? address memory PC Add Sum memory Program counter Adder

17 fetching unit Add 4 PC address memory CPU

18 ore Implementation Details Abstract / Simplified View: Data Register # PC Address Registers ALU memory Register # Register # Address Data memory Data

19 Register File--Built using D flip-flops Reg. address Data output Output from the register 5 bits 5 bits 5 bits 32 bits register number register number 2 Register file Write register Write data Write data data 2 32 bits 32 bits Reg. address register number register number 2 Register Register Register n Register n u x u x data data 2

20 Register File Write Written to the register Write Write signals rd or rt 5 bits Register number n-to- decoder n n C Register D C Register D Reg. address 32 bits Register data C Register n D C Register n D

21 Register files Foundation element of Computer(Part of Datapath ) Aggregation of many Registers Register address Control signals: /Write

22 Description: 32 32bits Register files odule regs(clk, rst,reg_rd_addr_a, reg_rt_addr_b, reg_wt_addr, wdata, we, rdata_a, rdata_b); input clk, rst, we; input [4:] reg_rd_addr_a, reg_rt_addr_b, reg_wt_addr; input [3:] wdata; output [3:] rdata_a, rdata_b; reg [3:] register [:3]; // r - r3 integer i; assign rdata_a = (reg_rd_addr_a == )? : register[reg_rd_addr_a]; // read assign rdata_b = (reg_rt_addr_b == )? : register[reg_rt_addr_b]; // read clk or posedge rst) begin if (rst==) begin // reset for (i=; i<32; i=i+) register[i] <= ; end else begin end endmodule if ((reg_wt_addr!= ) && (we == )) register[reg_wt_addr] <= wdata; end // write

23 Path Built using ultiplexer R-type instruction Datapath I-type instruction Datapath For ALU For memory For branch J-type instruction Datapath For Jump First, Look at the data flow within instruction execution

24 R type & Data stream op(6) rs(5) rt(5) rd(5) shamt func(6) bit 2-25 bit 6-2 bit -5 rs rt rd control reg. address data reg. address2 Registers RegWrite Write reg. address data2 Write data ALU operation 32bits data 3 ALU Zero ALU result Bnegate op function and Or Add Sub Slt

25 I type & Data stream op(6) rs(5) rt(5) Immediate data bit 2-25 bit 6-2 rs rt rt control reg. address data reg. address2 Registers RegWrite Write reg. address data2 Write data bit -5 6 lw $t, 2($s2) Sign extend 32 3 ALU Zero ALU result 32bits data Sw $t, 2($s2) ALU operation address data Data emory Write data enwrite en if $s2=,it will load word in element number 2 to $t

26 I type & Data stream of beq op(6) rs(5) rt(5) offset bit 2-25 bit 6-2 PC+4 from instructiondatapath rs rt reg. address data reg. address2 Registers RegWrite Write reg. address data2 Write data bit -5 6 Sign extend 32 Shift left 2 3 ALU ADD ALU operation Zero ALU result To PC

27 Combine the datapath R & I type op(6) rs(5) rt(5) Immediate data PC bit 2-25 bit -5 bit 6-2 bit -5 address emory UX rs rt rd 6 4 reg. address data reg. address2 Registers RegWrite Write reg. address data2 Write data Sign extend ADD 32 UX Shift left 2 3 ALU ADD Zero ALU result 32bits data ALU operation address data Data emory Write data en UX To PC enwrite UX

28 Combine the datapath R & I type address PC emory bit -5 bit 2-25 bit 6-2 UX bit RegWrite address data address2 Registers Write address data2 Write data Sign extend ADD 32 UX Shift left 2 ALU 3 ALU operation Zero ALU result ADD 32bits data address enwrite data Data emory Write data en UX UX

29 Combine the datapath R & I type address PC emory I-beq4 I-SW RI-LW bit -5 bit 2-25 bit 6-2 UX bit -5 6 RegWrite address data address2 Registers Write address data2 Write data Sign extend ADD 32 UX Shift left 2 ALU 3 ALU operation Zero ALU result ADD 32bits data address enwrite data Data emory Write data en UX UX

30 Chapter Five The processor : Datapath and control 5. Introduction 5.2 Logic Design Conventions (skip) 5.3 Building a datapath 5.4 A Simple Implementation Scheme 5.5 A ulticycle Implementation 5.5 icroprogramming 5.6 Exception

31 Building the Datapath Use multiplexors to stitch them together Note : control signals Page 36 F5.6

32 Building Control Analyse for cause and effect Information comes from the 32 bits of the instruction Selecting the operations to perform (ALU, read/write, etc.) Controlling the flow of data (multiplexor inputs) ALU's operation based on instruction type and function code R-format instruction (add, sub, and, or, slt) Op 6 bits 5bits 5bits 5bits 5bits 6bits I-format instruction (lw, sw, beq) Op Rs Rt Immediate 6 bits 5bits 5bits 6bits J-format instruction (add, sub, and, or, slt) Op Rs Rt Rd Shamt Funct address 6 bits 26bits

33 Code P3 Code add R rs rt rd sub R rs rt rd and R rs rt rd or R rs rt rd slt R rs rt rd lw I rs rt Immediate(displacement) sw I rs rt Immediate(displacement) beq I rs rt Immediate(offset) j J address

34 What should ALU do? e.g. what should the ALU do with these instructions Example: lw $, ($2) lw sw R OP rs rt 6 bit displacement ()35 2 ()43 2 () rs(5) rt(5) rd(5) shamt func(6) ALU op ALU control input 3 -types B negate op function and Or Add Sub Slt Why is the code for subtract and not?

35 Scheme of Controller 2-level decoder op(6) rs(5) rt(5) rd(5) shamt func(6) instruction op code (6) First ain decoder ALU op(2) Defined ALU Decoder Second Signals for Other Components (7) Defined at Chapter-3 ALU operation(3) Defined

36 The ALU control is where and other signals(7)

37 signals for datapath Defined 7+2 control (p. 35) Signal name Effect when deasserted(=) RegDst RegWrite Select register destination number from the rt(2:6) when WR None Effect when asserted(=) Select register destination number from the rd(5:) when WB Register destination input is written with the value on the Write data input ALUScr PCSrc em emwrite emtoreg The second ALU operand come from the second register file output ( data 2) The PC is replaced by the output of the adder that computers the value PC+4 None None The value fed to register Write data input comes from the Alu The second ALU operand is the signextended lower 6 bits of the instruction.. The PC is replaced by the output of the adder that computers the branch target. Data memory contents designated by the address input are put on the data output. Data memory contents designated by the address input are replaced by value on the Write data input. The value fed to the register Write data input comes from the data memory.

38 Designing the ain Control Unit (First level) ain Control Unit function ALU op (2) Divided 7 control signals into 2 groups 4 ux 3 R/W op code (6) ALU control ALU op (2) ux (4) R/W (3) em emwrite LW SW Beq R-type RegDst ALUScr PCSrc emtoreg RegWrite

39 Truth Table for ain decoder 4 Add [3 26] RegDst Branch em emtoreg Control ALUOp emwrite ALUSrc RegWrite Shift left 2 Add ALU result u x PC address memory [3 ] [25 2] [2 6] [5 ] u x register data register 2 Registers Write data 2 register Write data u x Zero ALU ALU result Address Write data Data memory data u x [5 ] 6 Sign 32 extend ALU control [5 ] RegDst ALUSrc emtoreg RegWrite em emwrite Branch ALU op ALU op emto- Reg em em R-format beq X RegDst ALUSrc X Reg Write Write Branch ALUOp ALUp LW R-format R-format lw SW LW sw X X beq SW beq X X X X

40 Circuitry of main Controller Simple combinational logic (truth tables) Inputs Op5 Op4 Op3 Op2 Op Op R-format Iw sw beq Outputs RegDst ALUSrc emtoreg RegWrite em emwrite Branch ALUOp ALUOpO opcode output R-format lw sw beq L/S beq R-type

41 Designing the ALU decoder (Second level) ust describe hardware to compute 3-bit ALU conrol input opcode ALUop operation Funct field Desired ALU action ALU control Input LW Load word xxxxxx Load word SW Store word xxxxxx Store word Beq branch equal xxxxxx branch equal R-type add add R-type subtract subtract R-type AND AND R-type OR OR R-type Set on less than Set on less than

42 Truth Table for ALU decoder Describe it using a truth table (can turn into gates): don t care ALUOp Funct field Operation ALUOp ALUOp F5 F4 F3 F2 F F 2 X X X X X X X X X X X X X X X X X X X X X X X X X X X X Operation 2 = ALU op + ALU op (F 3 F 2 F F + F 3 F 2 F F ) Operation = ALU op F 3 F 2 F F + ALU op F 3 F 2 F F Operation = ALU op F 3 F 2 F F + ALU op F 3 F 2 F F

43 The ALU control signals----logic circuit ALUOp ALU control block ALUOp ALUOp Operation2 F3 F2 Operation F (5 ) F Operation F Operation Operation Operation 2 = = = ALU ALU ALU op op op + + F 2 + (F ALU + F Operation op 3 F ) F F F F 3 F 2 x x x x x x x x x x x F F F 3 F 2 x x F 2 x X x x x X x x F F F F 3 F 2 x x F 3 x X x x x X x x x

44 Our Simple Control Structure All of the logic is combinational We wait for everything to settle down, and the right thing to be done ALU might not produce right answer? right away we use write signals along with clock to determine when to write Cycle time determined by length of the longest path State element Combinational logic State element 2 n n+ Clock cycle We are ignoring some details like setup and hold times

45 The simple Datapath with the control unit pc 4 [25-] Shift jump address[3-] left 2 Add ALU U U PC+4[3-28] result X X Shift Add left 2 address [3-26] Control RegDst Branch em emto ALUOp emwrite ALUSrc RegWrite jump R-type [3-] memory Op rs rt rd shamt Funct I-type Op rs rt Jump-type Op Immediate address [25-2] [2-6] U X [5-] [5-] register register 2 Write register Write data data data 2 Registers 6 Sign 32 extend [5-] U X ALU control Zero ALU ALU result Address data Data memory Write data U X

46 The Datapath in operation for R-type pc 4 [25-] address Add 26 Shift left 2 [3-26] jump address[3-] 28 PC+4[3-28] Control RegDst Branch em emto ALUOp emwrite ALUSrc RegWrite Shift left 2 Add ALU result U X U X jump I-type Op rs rt Jump-type Op [3-] memory add sub and or slt R-type Op rs rt rd shamt Funct Immediate address [25-2] [2-6] U X [5-] [5-] register register 2 Write register Write data data data 2 Registers 6 Sign 32 extend [5-] U X ALU control Zero ALU ALU result Address data Data memory Write data U X

47 The Datapath in operation for load pc 4 [25-] Shift 26 left 2 28 address Add [3-26] Control jump address[3-] PC+4[3-28] RegDst Branch em emto ALUOp emwrite ALUSrc RegWrite Shift left 2 Add ALU result U X U X jump R- Otype rsrt r I-type p d Op [3-] memory load instruction sha mt address Fu nct Op rs rt Immediate Jump-type [25-2] [2-6] U X [5-] [5-] register register 2 Write register Write data data data 2 Registers 6 Sign 32 extend [5-] U X ALU control Zero ALU ALU result Address data Data memory Write data U X

48 The Datapath in operation for store pc 4 [25-] Shift 26 left 2 28 address Add [3-26] Control jump address[3-] PC+4[3-28] RegDst Branch em emto ALUOp emwrite ALUSrc RegWrite Shift left 2 Add ALU result U X U X jump R- Otype rsrt r I-type p d Op rs rt sha mt Jump-type Op [3-] memory store instruction address Fu nct Immediate [25-2] [2-6] U X [5-] [5-] register register 2 Write register Write data data data 2 Registers 6 Sign 32 extend [5-] U X ALU control Zero ALU ALU result Address data Data memory Write data U X

49 The Datapath in operation for beq pc 4 [25-] Shift 26 left 2 28 address Add [3-26] Control jump address[3-] PC+4[3-28] RegDst Branch em emto ALUOp emwrite ALUSrc RegWrite Shift left 2 Add ALU result U X U X jump R- Otype rsrt r I-type p d Op rs rt Jump-type Op [3-] memory beq instruction sha mt address Fu nct Immediate [25-2] [2-6] U X [5-] [5-] register register 2 Write register Write data data data 2 Registers 6 Sign 32 extend [5-] U X ALU control Zero ALU ALU result Address data Data memory Write data U X

50 j instruction instruction format j Label ()2 26 bits address Implementation pc = pc 28~3 ## 26bits-address 4

51 The Datapath in operation for Jump pc 4 [25-] address Add 26 Shift left 2 [3-26] 28 Control jump address[3-] PC+4[3-28] RegDst Branch em emto ALUOp emwrite ALUSrc RegWrite Shift left 2 Add ALU result U X U X jump jump instruction R- Otype rsrt r sha Fu I-type p d mt nct O rs rt Immediat Jump-type p e Op [3-] memory address [25-2] [2-6] U X [5-] [5-] register register 2 Write register Write data data data 2 Registers 6 Sign 32 extend [5-] U X ALU control Zero ALU ALU result Address data Data memory Write data U X

52 Single Cycle Implementation performance for lw Calculate cycle time assuming negligible delays except: memory (2ns), ALU and adders (2ns), register file access (ns) 4 Add [3 26] Control RegDst Branch em emtoreg ALUOp emwrite ALUSrc RegWrite Shift left 2 Add ALU result u x PC address memory [3 ] [25 2] [2 6] [5 ] u x register data register 2 Registers Write data 2 register Write data u x Zero ALU ALU result Address Write data Data memory data u x [5 ] 6 Sign 32 extend ALU control [5 ] 2ns +=ns 2ns 2ns

53 Performance in Single Cycle Implementation Let s see the following table: class memory Register read ALU Data memory Register write Total R-format ns Load word ns Store word ns Branch ns Jump 2 2 ns The conclusion: Different instructions needs different time. The clock cycle must meet the need of the slowest instruction. So,some time will be wasted.

54 The CPU Performance Equation CPU time =I CPI τ

55

56 CPU performance is dependent upon three characteristics: clock cycle (or rate) clock cycles per instruction and instruction count. It is difficult to change one parameter in complete isolation from others because the basic technologies involved in changing each characteristic are interdependent: Clock cycle time Hardware technology and organization Clock cycle time Hardware technology and organization count set architecture and compiler technology

57 IPS (million instruction per second) The bigger the IPS, the faster the machine. Three problems with IPS: IPS is dependent on the instruction set, making it difficult to compare IPS of computers with different instruction sets. IPS varies between programs on the same computer. ost importantly, IPS can vary inversely to performance!

58 Single Cycle Problems : what if we had a more complicated instruction like floating point? If so,the waste of time will be more serious. wasteful of area. The reason is the following: Let s see the instruction mult.this instruction needs to use the ALU repeatedly. But,in the single cycle implementation,one ALU can be used only once in one clock cycle. So,the instruction mult will need many ALUs.The CPU will be very large.

59 One Solution for Single Cycle Problems One Solution: Use a smaller cycle time Let different instructions take different numbers of cycles a ulticycle datapath: PC Address emory Data or data register emory data register Data Register # Registers Register # Register # A B ALU ALUOut

60 Chapter Five The processor : Datapath and control 5. Introduction 5.2 Logic Design Conventions (skip) 5.3 Building a datapath 5.4 A Simple Implementation Scheme 5.5 A ulticycle Implementation 5.5 icroprogramming 5.6 Exception

61 ulticycle Approach Break up the instructions into steps, each step takes a cycle balance the amount of work to be done restrict each cycle to use only one major functional unit At the end of a cycle store values for use in later cycles introduce additional internal registers

62 Analyse events: Five Execution Steps IF: Fetch ID: Decode and Register Fetch EX(BC):Execution, emory Address Computation, or Branch Completion E(WB):emory Access or R-type instruction completion WB:Write-back step INSTRUCTIONS TAKE FRO 3-5 CYCLES!

63 Step : Fetch Use PC to get instruction and put it in the Register. IR = emory[pc]; Increment the PC by 4 and put the result back in the PC. PC = PC + 4; Can be described simply using RTL "Register-Transfer Language" IR = emory[pc]; PC = PC + 4; Can we figure out the values of the control signals? What is the advantage of updating the PC now?

64 Step 2: Decode and Register Fetch registers rs and rt in case we need them Compute the branch address in case the instruction is a branch RTL: A = Reg[IR[25-2]]; B = Reg[IR[2-6]]; ALUOut = PC + (sign-extend(ir[5-]) << 2); We aren't setting any control lines based on the instruction type (we are busy "decoding" it in our control logic)

65 Step 3 (instruction dependent) ALU is performing one of three functions, based on instruction type emory Reference ( lw / sw ): ALUOut = A + sign-extend(ir[5-]); R-type: ALUOut = A op B; Branch: if (A==B) PC = ALUOut; jump: pc = pc IR25- << 2

66 Step 4 (R-type or memory-access) Loads and stores access memory DR = emory[aluout]; # for lw or emory[aluout] = B; # for sw R-type instructions finish Reg[rd]=Reg[ IR[5-] ] = ALUOut; The write actually takes place at the end of the cycle on the edge

67 Write-back step (step 5) lw Reg[rt]=Reg[IR[2-6]]= DR; What about all the other instructions?

68 Summary: Step name fetch decode/register fetch Action for R-type instructions Action for memory-reference Action for instructions branches IR = emory[pc] PC = PC + 4 A = Reg [IR[25-2]] B = Reg [IR[2-6]] ALUOut = PC + (sign-extend (IR[5-]) << 2) Action for jumps Execution, address ALUOut = A op B ALUOut = A + sign-extend if (A ==B) then PC = PC [3-28] II computation, branch/ (IR[5-]) PC = ALUOut (IR[25-]<<2) jump completion emory access or R-type Reg [IR[5-]] = Load: DR = emory[aluout] completion ALUOut or Store: emory [ALUOut] = B emory read completion Load: Reg[IR[2-6]] = DR

69 Simple Questions How many cycles will it take to execute this code? lw $t2, ($t3) lw $t3, 4($t3) beq $t2, $t3, Label #assume not add $t5, $t2, $t3 sw $t5, 8($t3) Label:... What is going on during the 8th cycle of execution? Answer: In what cycle does the actual addition of $t2 and $t3 takes place? No. 6 Calculating memory address (2)

70 Reusing Resource We will be reusing functional units ALU used to compute address and to increment PC emory used for instruction and data We will use a finite state machine for control PC Address emory or data Data register emory data register Data Register # Registers Register # Register # A B ALU ALUOut shared unit

71 Scheme of Controller of ulticycle PC u x Address Write data emory emdata [25 2] [2 6] [5 ] register [5 ] emory data register [5 ] u x u x 6 register register 2 Registers Write register Write data Sign extend data data 2 32 Shift left 2 A B 4 u x u 2 x 3 Zero ALU ALU result ALUOut

72 How does it control in ulticycle Approach IorD em emwrite IRWrite RegDst RegWrite ALUSrcA PC u x Address Write data emory emdata [25 2] [2 6] [5 ] register [5 ] emory data register [5 ] u x u x 6 register register 2 Registers Write register Write data Sign extend data data 2 32 Shift left 2 A B 4 u x u 2 x 3 ALU control Zero ALU ALU result ALUOut [5 ] emtoreg ALUSrcB ALUOp

73 signals for datapath of ulticycle Defined +6 control (p. 324) Signal name Effect when deasserted(=) Effect when asserted(=) RegDst Select register destination number from the rt(2:6) when WR. Select register destination number from the rd(5:) when WB. RegWrite None Register destination input is written with the value on the Write data input ALUScrA The first ALU operand is the PC The first ALU operand come from the A register. em None emory contents at the location specified by the address input is put on the emory data out. emwrite None emory contents at the location specified by the address input are replaced by value on the Write data input. emtoreg IorD The value fed to register Write data input comes from the ALUOut The PC is used to supply the address to the memory unit. The value fed to the register Write data input comes from the DA. ALUOut is used to supply the address to the memory unit. IRWrite None The output of memory is written into the IR. PCWrite None The is written;the source is controlled by PCSource. PCWriteCond None The PC is written if the zero output from the ALU is also active.

74 Control signals Signal name Value Effect ALUOp ALUScrB The ALU performs an add operation. The ALU performs an subtract operation. The funct field of the instruction determines the ALUoperation The second input to the ALU comes from the B register. PCSource The second input to the ALU is the constant 4. The second input to the ALU is the sign-extended, lower 6 bits of the IR. The second input to the ALU is the sign-extended, lower 6 bits of the IR shift 2 bits. Output of the ALU(PC+4) is sent to the PC for writing. The contents of ALUOut (the branch target address) are sent to the PC writing. The jump target address (IR[25:]shifted left 2 bits and concatenated with PC+4[3:28]) is sent to the PC for writing.

75 seq: pc = pc + 4 beq:pc = pc + offset * 4 j :pc = pc IR 25- << 2 PC u x Address Write data emory emdata [3-26] [25 2] [2 6] [5 ] register [5 ] emory data register PCWriteCond PCWrite IorD Outputs em emwrite emtoreg IRWrite [25 ] [5 ] Control Op [5 ] u x u x PCSource ALUOp ALUSrcB ALUSrcA RegDst 6 RegWrite register register 2 Registers Write register Write data Sign extend data data 2 32 Shift left 2 A B 4 u x u 2 x 3 26 Shift 28 left 2 ALU control PC [3-28] Zero ALU ALU result Jump address [3-] ALUOut 2 u x [5 ]

76 Implementing the Control Value of control signals is dependent upon: what instruction is being executed which step is being performed Let s go over the main control unit in the single-cycle implementation.

77 Review for singlecycle ain control unit in the single-cycle implementation R-type lw 35 sw 43 beq 4 Inputs Op5 Op4 Op3 Op2 Op Op Outputs R-format Iw sw beq RegDst ALUSrc emtoreg RegWrite em emwrite Branch ALUOp ALUOpO

78 Review Now,let s look at the AlU control unit.it does not need to changed. ALUOp ALUOp ALUOp ALU control block F3 Operation2 F (5 ) F2 F F Operation Operation Operation

79 As same as the single-cycle So,the following truth table remains the same. ALUOp Funct field Operation ALUOp ALUOp F5 F4 F3 F2 F F X X X X X X X X X X X X X X X X X X X X X X X X X X X X

80 Review: Finite state machines Finite state machines: a set of states next state function (determined by current state and the input) output function (determined by current state and possibly input) Current state Next-state function Next state Inputs Clock Output function Outputs

81 Difference in controller Do something different in each cycle Tow main ways to implement the control. Finite state machine 2. use microprogramming Next,we will discuss the first way.

82 PC u x Address Write data emory emdata [3-26] [25 2] [2 6] [5 ] register [5 ] emory data register PCWriteCond PCWrite IorD Outputs em emwrite emtoreg IRWrite [25 ] [5 ] Control Op [5 ] u x u x PCSource ALUOp ALUSrcB ALUSrcA RegDst 6 RegWrite register register 2 Registers Write register Write data Sign extend data data 2 32 Shift left 2 A B 4 u x u 2 x 3 26 Shift 28 left 2 ALU control PC [3-28] Zero ALU ALU result Jump address [3-] ALUOut 2 u x [5 ]

83 State diagram for execute flow Ref Fig5.3 (p.332) Start fetch/decode and registerfetch Figure(5.32) enory access instructions Figure(5.33) R-type instructions Figure(5.34) Branch instructions Figure(5.35) Jump instructions Figure(5.36)

84 fetch / decode and Reg fetch Start (Op = 'LW') or (Op = 'SW') fetch em ALUSrcA = IorD = IRWrite ALUSrcB = ALUOp = PCWrite PCSource = (Op = R-type) (Op = 'BEQ') decode/ Register fetch ALUSrcA = ALUSrcB = ALUOp = (Op = 'JP') emory reference FS (Figure 5.33) R-type FS (Figure 5.34) Branch FS (Figure 5.35) Jump FS (Figure 5.36)

85 lw and sw 2 From state ALUSrcA = ALUSrcB = ALUOp = (Op = 'LW') or (Op = 'SW') emory address computation 3 (Op = 'LW') emory access (Op = 'SW') 5 emory access em IorD = emwrite IorD = 4 Write-back step RegWrite emtoreg = RegDst = To state (Figure 5.32)

86 R-type From stste 6 Op=R-type ALUSrcA= ALUSrcB= ALUOp= Execution 7 RegDst= RegWrite emtoreg= R-type completion To stste (Figure 5.32)

87 Branch From stste 8 Op= BEQ ALUSrcA= ALUSrcB= ALUOp= PCWriteCond PCSource= Branch completion To stste (Figure 5.32)

88 J-type From stste 9 Op= J PCSource= Jump completion To stste (Figure 5.32)

89 Graphical Specification of FS lw 2 3 emory address computation ALUSrcA = ALUSrcB = ALUOp = (Op = 'LW') em IorD = emory access (Op = 'SW') 5 Start (Op = 'LW') or (Op = 'SW') sw emwrite IorD = emory access fetch em ALUSrcA = IorD = IRWrite ALUSrcB = ALUOp = PCWrite PCSource = 6 7 Execution ALUSrcA = ALUSrcB = ALUOp= RegDst = RegWrite emtoreg = 8 R-type completion (Op = R-type) Branch completion ALUSrcA = ALUSrcB = ALUOp = PCWriteCond PCSource = beq (Op = 'BEQ') decode/ register fetch 9 ALUSrcA = ALUSrcB = ALUOp = (Op = 'J') Jump completion PCWrite PCSource = jump 4 Write-back step R-type RegDst= RegWrite emtoreg =

90 The truth table for the 6 datapath control outputs, which depend only on the state inputs.

91 The logic equations for the control unit shown in a shorthand form

92 Implemented using a block of combinational logic and a register to hold the the current state Combinational Control logic Datapath control output Outputs Inputs State register Next state Input from instruction Register opcode field

93 Chapter Five The processor : Datapath and control 5. Introduction 5.2 Logic Design Conventions (skip) 5.3 Building a datapath 5.4 A Simple Implementation Scheme 5.5 A ulticycle Implementation 5.5 icroprogramming 5.6 Exception

94 icroinstruction format icroinstruction control signal position of next icroinstruction Representation split into some fields next position sequential dispatch table (jump)

95 icroinstruction format (Reg fetch) A=Reg[IR 25-2 ], B=Reg[IR 2-6 ]

96 icroinstruction format em address is from

97 Steps of s Step name fetch decode/register fetch Action for R-type instructions Action for memory-reference Action for instructions branches IR = emory[pc] PC = PC + 4 A = Reg [IR[25-2]] B = Reg [IR[2-6]] ALUOut = PC + (sign-extend (IR[5-]) << 2) Action for jumps Execution, address ALUOut = A op B ALUOut = A + sign-extend if (A ==B) then PC = PC [3-28] II computation, branch/ (IR[5-]) PC = ALUOut (IR[25-]<<2) jump completion emory access or R-type Reg [IR[5-]] = Load: DR = emory[aluout] completion ALUOut or Store: emory [ALUOut] = B emory read completion Load: Reg[IR[2-6]] = DR

98 icrooperation 2 emory address computation ALUSrcA = ALUSrcB = ALUOp = Start fetch em ALUSrcA = IorD = IRWrite ALUSrcB = ALUOp = PCWrite PCSource = 6 (Op = 'LW') or (Op = 'SW') Execution ALUSrcA = ALUSrcB = ALUOp= 8 (Op = R-type) Branch completion ALUSrcA = ALUSrcB = ALUOp = PCWriteCond PCSource = decode/ register fetch (Op = 'BEQ') 9 ALUSrcA = ALUSrcB = ALUOp = (Op = 'J') Jump completion PCWrite PCSource = 3 (Op = 'LW') emory access (Op = 'SW') 5 emory access 7 R-type completion em IorD = emwrite IorD = RegDst = RegWrite emtoreg = 4 Write-back step RegDst= RegWrite emtoreg=

99 icroprogramming A specification methodology address appropriate if hundreds of opcodes, modes, cycles, etc. signals specified symbolically using microinstructions Label ALU control SRC SRC2 Register control emory PCWrite control Sequencing Fetch Add PC 4 PC ALU Seq Add PC Extshft Dispatch em Add A Extend Dispatch 2 LW2 ALU Seq Write DR Fetch SW2 Write ALU Fetch Rformat Func code A B Seq Write ALU Fetch BEQ Subt A B ALUOut-cond Fetch JUP Jump address Fetch

100 微指令编码 ALUOp ALUOp ALU ALUSrcA ALUSrcB ALUSrcB IRWrite RegWrite RegDst SRC SRC2 emtoreg em em IorD PCSource PCSource PCWrite PCWriteCond Addrctl Addrctl Register emory control control PCWite Seq ALU Register PCWrite Label control SRC SRC2 control emory control Sequencing Fetch Add PC 4 PC ALU Seq Add PC Extshft Dispatch em Add A Extend Dispatch 2 LW2 ALU Seq Write DR Fetch SW2 Write ALU Fetch RformatFunc codea B Seq Write ALU Fetch BEQ Subt A B ALUOut-cond Fetch JUP Jump addressfetch

101 icroprogramming What are the icroinstructions? Control unit icrocode memory Outputs Input PCWrite PCWriteCond IorD em emwrite IRWrite BWrite emtoreg PCSource ALUOp ALUSrcB ALUSrcA RegWrite RegDst AddrCtl Datapath Adder icroprogram counter Address select logic Op[5 ] register opcode field

102 Details PLA or RO Dispatch RO Dispatch State RO 2 Op Opcode name Value Adder Op Opcode name Value R-format lw ux jmp 3 2 sw beq lw sw Dispatch RO 2 Dispatch RO AddrCtl Address select logic Op register opcode field State number Address-control action Value of AddrCtl Use incremented state 3 Use dispatch RO 2 Use dispatch RO Use incremented state 3 4 Replace state number by 5 Replace state number by 6 Use incremented state 3 7 Replace state number by 8 Replace state number by 9 Replace state number by Seeing to CD

103 ALU ALUOp ALUOp Lw sw SRC SRC2 ALUSrcA ALUSrcB ALUSrcB IRWrite Opcode 3 2 State (C) Register control emory control PCWite RegWrite RegDst emtoreg em em IorD PCSource PCSource PCWrite R J Beq Lw Sw Seq PCWriteCond Addrctl Addrctl

104 Chapter Five The processor : Datapath and control 5. Introduction 5.2 Logic Design Conventions (skip) 5.3 Building a datapath 5.4 A Simple Implementation Scheme 5.5 A ulticycle Implementation 5.5 icroprogramming 5.6 Exception

105 5.6 Exception The cause of changing CPU s work flow : Control instructions in program (bne/beq, j, jal, etc) It is foreseeable in programming flow Something happen suddenly (Exception and Interruption) It is unpredictable Unexpected events Exception: from within processor ( overflow, undefined instruction, etc) Interruption : from outside processor ( input /output )

106 5.6 Exception Exception An Exception is a unexpected event from within processor. We follow the IPS convention, using the term exception to refer to any unexpected change in control flow. Here we will discuss two types exceptions : arithmetic overflow undefined instruction

107 How Exceptions Are Handled When exception happens, the processor must do something. The predefined process routines are saved in memory when computer starts. Problem: how can CPU goto relative routine when an exception occurs. CPU should know the cause of exception which instruction generate the exception

108 How Exceptions Are Handled Design add a register: exception program counter(epc) save the address of the offending instruction add a status register: cause register( CauseReg) hold a field that indicates the reason for the exception. undefined instruction bit = overflow Another method is to use vector interrupts Exception type vector address undefine instr c H overflow c 2 H

109 How Control Checks for Exceptions add control signal CauseWrite for CauseReg EPCWrite for EPC EPC = PC - 4 (completed by ALU) process of control CauseReg = or EPC = PC - 4 PC <--- address of process routine ( ex. c )

110 How Control Checks for Exceptions PC u x Address Write data emory emdata [25 2] [2 6] [5 ] register [5 ] emory data register PCWriteCond PCWrite IorD em emwrite emtoreg IRWrite [5 ] Outputs Control Op [5 ] [25 ] 26 Shift 28 left 2 [3-26] PC [3-28] u x u x 6 CauseWrite IntCause EPCWrite PCSource ALUOp ALUSrcB ALUSrcA RegWrite RegDst register register 2 Registers Write register Write data 32 Sign extend data data 2 Shift left 2 A B 4 u x u 2 x 3 ALU control Zero ALU ALU result Jump address [3-] CO 3 ALUOut u x u x 2 EPC Cause [5 ]

111 How Control Checks for Exceptions detect exceptions Undefined instruction when no next state is defined from state for op value. New state is introduced. Overflow Overflow is occured only in R-type instruction. Overflow is provided as an output from the ALU. This signal is used in the modified FS to specify an additional state for state 7.

112 IntCause = CauseWrite ALUSrcA = ALUSrcB = ALUOp = EPCWrite PCWrite PC++Source = IntCause = CauseWrite ALUSrcA = ALUSrcB = ALUOp = EPCWrite PCWrite PCSource = PCSource = To state to begin next instruction

113 emory address computation 2 ALUSrcA = ALUSrcB = ALUOp = Start fetch em ALUSrcA = IorD = IRWrite ALUSrcB = ALUOp = PCWrite PCSource = 6 (Op = 'LW') or (Op = 'SW') Execution ALUSrcA = ALUSrcB = ALUOp = (Op = R-type) Branch completion 8 ALUSrcA = ALUSrcB = ALUOp = PCWriteCond PCSource = decode/ Register fetch (Op = 'BEQ') 9 ALUSrcA = ALUSrcB = ALUOp = (Op = 'J') Jump completion PCWrite PCSource = (Op = other) 3 (Op = 'LW') em IorD = emory access 5 (Op = 'SW') emwrite IorD = emory access 7 R-type completion IntCause = CauseWrite RegDst = RegWrite emtoreg = Overflow ALUSrcA = ALUSrcB = ALUOp = EPCWrite PCWrite PCSource = IntCause = CauseWrite ALUSrcA = ALUSrcB = ALUOp = EPCWrite PCWrite PCSource = 4 Write-back step Overflow RegWrite emtoreg = RegDst =

Lecture 5: The Processor

Lecture 5: The Processor Lecture 5: The Processor CSCE 26 Computer Organization Instructor: Saraju P. ohanty, Ph. D. NOTE: The figures, text etc included in slides are borrowed from various books, websites, authors pages, and

More information

The Processor: Datapath & Control

The Processor: Datapath & Control Chapter Five 1 The Processor: Datapath & Control We're ready to look at an implementation of the MIPS Simplified to contain only: memory-reference instructions: lw, sw arithmetic-logical instructions:

More information

Systems Architecture I

Systems Architecture I Systems Architecture I Topics A Simple Implementation of MIPS * A Multicycle Implementation of MIPS ** *This lecture was derived from material in the text (sec. 5.1-5.3). **This lecture was derived from

More information

ﻪﺘﻓﺮﺸﻴﭘ ﺮﺗﻮﻴﭙﻣﺎﻛ يرﺎﻤﻌﻣ MIPS يرﺎﻤﻌﻣ data path and ontrol control

ﻪﺘﻓﺮﺸﻴﭘ ﺮﺗﻮﻴﭙﻣﺎﻛ يرﺎﻤﻌﻣ MIPS يرﺎﻤﻌﻣ data path and ontrol control معماري كامپيوتر پيشرفته معماري MIPS data path and control abbasi@basu.ac.ir Topics Building a datapath support a subset of the MIPS-I instruction-set A single cycle processor datapath all instruction actions

More information

ENE 334 Microprocessors

ENE 334 Microprocessors ENE 334 Microprocessors Lecture 6: Datapath and Control : Dejwoot KHAWPARISUTH Adapted from Computer Organization and Design, 3 th & 4 th Edition, Patterson & Hennessy, 2005/2008, Elsevier (MK) http://webstaff.kmutt.ac.th/~dejwoot.kha/

More information

Lecture 5 and 6. ICS 152 Computer Systems Architecture. Prof. Juan Luis Aragón

Lecture 5 and 6. ICS 152 Computer Systems Architecture. Prof. Juan Luis Aragón ICS 152 Computer Systems Architecture Prof. Juan Luis Aragón Lecture 5 and 6 Multicycle Implementation Introduction to Microprogramming Readings: Sections 5.4 and 5.5 1 Review of Last Lecture We have seen

More information

Lets Build a Processor

Lets Build a Processor Lets Build a Processor Almost ready to move into chapter 5 and start building a processor First, let s review Boolean Logic and build the ALU we ll need (Material from Appendix B) operation a 32 ALU result

More information

CC 311- Computer Architecture. The Processor - Control

CC 311- Computer Architecture. The Processor - Control CC 311- Computer Architecture The Processor - Control Control Unit Functions: Instruction code Control Unit Control Signals Select operations to be performed (ALU, read/write, etc.) Control data flow (multiplexor

More information

Topic #6. Processor Design

Topic #6. Processor Design Topic #6 Processor Design Major Goals! To present the single-cycle implementation and to develop the student's understanding of combinational and clocked sequential circuits and the relationship between

More information

ECE369. Chapter 5 ECE369

ECE369. Chapter 5 ECE369 Chapter 5 1 State Elements Unclocked vs. Clocked Clocks used in synchronous logic Clocks are needed in sequential logic to decide when an element that contains state should be updated. State element 1

More information

COMP303 - Computer Architecture Lecture 10. Multi-Cycle Design & Exceptions

COMP303 - Computer Architecture Lecture 10. Multi-Cycle Design & Exceptions COP33 - Computer Architecture Lecture ulti-cycle Design & Exceptions Single Cycle Datapath We designed a processor that requires one cycle per instruction RegDst busw 32 Clk RegWr Rd ux imm6 Rt 5 5 Rs

More information

Chapter 5: The Processor: Datapath and Control

Chapter 5: The Processor: Datapath and Control Chapter 5: The Processor: Datapath and Control Overview Logic Design Conventions Building a Datapath and Control Unit Different Implementations of MIPS instruction set A simple implementation of a processor

More information

Multicycle Approach. Designing MIPS Processor

Multicycle Approach. Designing MIPS Processor CSE 675.2: Introduction to Computer Architecture Multicycle Approach 8/8/25 Designing MIPS Processor (Multi-Cycle) Presentation H Slides by Gojko Babić and Elsevier Publishing We will be reusing functional

More information

CPE 335. Basic MIPS Architecture Part II

CPE 335. Basic MIPS Architecture Part II CPE 335 Computer Organization Basic MIPS Architecture Part II Dr. Iyad Jafar Adapted from Dr. Gheith Abandah slides http://www.abandah.com/gheith/courses/cpe335_s08/index.html CPE232 Basic MIPS Architecture

More information

RISC Processor Design

RISC Processor Design RISC Processor Design Single Cycle Implementation - MIPS Virendra Singh Indian Institute of Science Bangalore virendra@computer.org Lecture 13 SE-273: Processor Design Feb 07, 2011 SE-273@SERC 1 Courtesy:

More information

ECE 313 Computer Organization EXAM 2 November 9, 2001

ECE 313 Computer Organization EXAM 2 November 9, 2001 ECE 33 Computer Organization EA 2 November 9, 2 This exam is open book and open notes. You have 5 minutes. Credit for problems requiring calculation will be given only if you show your work. Choose and

More information

Processor: Multi- Cycle Datapath & Control

Processor: Multi- Cycle Datapath & Control Processor: Multi- Cycle Datapath & Control (Based on text: David A. Patterson & John L. Hennessy, Computer Organization and Design: The Hardware/Software Interface, 3 rd Ed., Morgan Kaufmann, 27) COURSE

More information

Implementing the Control. Simple Questions

Implementing the Control. Simple Questions Simple Questions How many cycles will it take to execute this code? lw $t2, 0($t3) lw $t3, 4($t3) beq $t2, $t3, Label add $t5, $t2, $t3 sw $t5, 8($t3) Label:... #assume not What is going on during the

More information

Major CPU Design Steps

Major CPU Design Steps Datapath Major CPU Design Steps. Analyze instruction set operations using independent RTN ISA => RTN => datapath requirements. This provides the the required datapath components and how they are connected

More information

CSE 2021 Computer Organization. Hugh Chesser, CSEB 1012U W10-M

CSE 2021 Computer Organization. Hugh Chesser, CSEB 1012U W10-M CSE 22 Computer Organization Hugh Chesser, CSEB 2U Agenda Topics:. ultiple cycle implementation - complete Patterson: Appendix C, D 2 Breaking the Execution into Clock Cycles Execution of each instruction

More information

LECTURE 6. Multi-Cycle Datapath and Control

LECTURE 6. Multi-Cycle Datapath and Control LECTURE 6 Multi-Cycle Datapath and Control SINGLE-CYCLE IMPLEMENTATION As we ve seen, single-cycle implementation, although easy to implement, could potentially be very inefficient. In single-cycle, we

More information

Mapping Control to Hardware

Mapping Control to Hardware C A P P E N D I X A custom format such as this is slave to the architecture of the hardware and the instruction set it serves. The format must strike a proper compromise between ROM size, ROM-output decoding,

More information

ELEC 5200/6200 Computer Architecture and Design Spring 2017 Lecture 4: Datapath and Control

ELEC 5200/6200 Computer Architecture and Design Spring 2017 Lecture 4: Datapath and Control ELEC 52/62 Computer Architecture and Design Spring 217 Lecture 4: Datapath and Control Ujjwal Guin, Assistant Professor Department of Electrical and Computer Engineering Auburn University, Auburn, AL 36849

More information

CENG 3420 Computer Organization and Design. Lecture 06: MIPS Processor - I. Bei Yu

CENG 3420 Computer Organization and Design. Lecture 06: MIPS Processor - I. Bei Yu CENG 342 Computer Organization and Design Lecture 6: MIPS Processor - I Bei Yu CEG342 L6. Spring 26 The Processor: Datapath & Control q We're ready to look at an implementation of the MIPS q Simplified

More information

ALUOut. Registers A. I + D Memory IR. combinatorial block. combinatorial block. combinatorial block MDR

ALUOut. Registers A. I + D Memory IR. combinatorial block. combinatorial block. combinatorial block MDR Microprogramming Exceptions and interrupts 9 CMPE Fall 26 A. Di Blas Fall 26 CMPE CPU Multicycle From single-cycle to Multicycle CPU with sequential control: Finite State Machine Textbook Edition: 5.4,

More information

CSE 2021 COMPUTER ORGANIZATION

CSE 2021 COMPUTER ORGANIZATION CSE 22 COMPUTER ORGANIZATION HUGH CHESSER CHESSER HUGH CSEB 2U 2U CSEB Agenda Topics:. Sample Exam/Quiz Q - Review 2. Multiple cycle implementation Patterson: Section 4.5 Reminder: Quiz #2 Next Wednesday

More information

CSE 2021 COMPUTER ORGANIZATION

CSE 2021 COMPUTER ORGANIZATION CSE 2021 COMPUTER ORGANIZATION HUGH LAS CHESSER 1012U HUGH CHESSER CSEB 1012U W10-M Agenda Topics: 1. Multiple cycle implementation review 2. State Machine 3. Control Unit implementation for Multi-cycle

More information

Chapter 4 The Processor (Part 2)

Chapter 4 The Processor (Part 2) Department of Electr rical Eng ineering, Chapter 4 The Processor (Part 2) 王振傑 (Chen-Chieh Wang) ccwang@mail.ee.ncku.edu.tw ncku edu Feng-Chia Unive ersity Outline A Multicycle Implementation Mapping Control

More information

Chapter 4. The Processor. Computer Architecture and IC Design Lab

Chapter 4. The Processor. Computer Architecture and IC Design Lab Chapter 4 The Processor Introduction CPU performance factors CPI Clock Cycle Time Instruction count Determined by ISA and compiler CPI and Cycle time Determined by CPU hardware We will examine two MIPS

More information

Processor (I) - datapath & control. Hwansoo Han

Processor (I) - datapath & control. Hwansoo Han Processor (I) - datapath & control Hwansoo Han Introduction CPU performance factors Instruction count - Determined by ISA and compiler CPI and Cycle time - Determined by CPU hardware We will examine two

More information

Initial Representation Finite State Diagram. Logic Representation Logic Equations

Initial Representation Finite State Diagram. Logic Representation Logic Equations Control Implementation Alternatives 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;

More information

Review: Abstract Implementation View

Review: Abstract Implementation View Review: Abstract Implementation View Split memory (Harvard) model - single cycle operation Simplified to contain only the instructions: memory-reference instructions: lw, sw arithmetic-logical instructions:

More information

Outline. Combinational Element. State (Sequential) Element. Clocking Methodology. Input/Output of Elements

Outline. Combinational Element. State (Sequential) Element. Clocking Methodology. Input/Output of Elements Outline ombinational Element ombinational & sequential logic Single-cycle PU ulti-cycle PU Examples of ombinational Elements State (Sequential) Element! "#$$$ #$$ #$$ #$ # & & ) *.// * - + #3, * + - locking

More information

RISC Architecture: Multi-Cycle Implementation

RISC Architecture: Multi-Cycle Implementation RISC Architecture: Multi-Cycle Implementation Virendra Singh Associate Professor Computer Architecture and Dependable Systems Lab Department of Electrical Engineering Indian Institute of Technology Bombay

More information

RISC Design: Multi-Cycle Implementation

RISC Design: Multi-Cycle Implementation RISC Design: Multi-Cycle Implementation Virendra Singh Associate Professor Computer Architecture and Dependable Systems Lab Department of Electrical Engineering Indian Institute of Technology Bombay http://www.ee.iitb.ac.in/~viren/

More information

Lecture 10 Multi-Cycle Implementation

Lecture 10 Multi-Cycle Implementation Lecture 10 ulti-cycle Implementation 1 Today s enu ulti-cycle machines Why multi-cycle? Comparative performance Physical and Logical Design of Datapath and Control icroprogramming 2 ulti-cycle Solution

More information

CENG 3420 Lecture 06: Datapath

CENG 3420 Lecture 06: Datapath CENG 342 Lecture 6: Datapath Bei Yu byu@cse.cuhk.edu.hk CENG342 L6. Spring 27 The Processor: Datapath & Control q We're ready to look at an implementation of the MIPS q Simplified to contain only: memory-reference

More information

Lab 8: Multicycle Processor (Part 1) 0.0

Lab 8: Multicycle Processor (Part 1) 0.0 Lab 8: ulticycle Processor (Part ). Introduction In this lab and the next, you will design and build your own multicycle IPS processor! Your processor should match the design from the text reprinted below

More information

Processor Design CSCE Instructor: Saraju P. Mohanty, Ph. D. NOTE: The figures, text etc included in slides are borrowed

Processor Design CSCE Instructor: Saraju P. Mohanty, Ph. D. NOTE: The figures, text etc included in slides are borrowed Lecture 3: General Purpose Processor Design CSCE 665 Advanced VLSI Systems Instructor: Saraju P. ohanty, Ph. D. NOTE: The figures, tet etc included in slides are borrowed from various books, websites,

More information

Systems Architecture

Systems Architecture Systems Architecture Lecture 15: A Simple Implementation of MIPS Jeremy R. Johnson Anatole D. Ruslanov William M. Mongan Some or all figures from Computer Organization and Design: The Hardware/Software

More information

CO Computer Architecture and Programming Languages CAPL. Lecture 18 & 19

CO Computer Architecture and Programming Languages CAPL. Lecture 18 & 19 CO2-3224 Computer Architecture and Programming Languages CAPL Lecture 8 & 9 Dr. Kinga Lipskoch Fall 27 Single Cycle Disadvantages & Advantages Uses the clock cycle inefficiently the clock cycle must be

More information

RISC Architecture: Multi-Cycle Implementation

RISC Architecture: Multi-Cycle Implementation RISC Architecture: Multi-Cycle Implementation Virendra Singh Associate Professor Computer Architecture and Dependable Systems Lab Department of Electrical Engineering Indian Institute of Technology Bombay

More information

Chapter 5 Solutions: For More Practice

Chapter 5 Solutions: For More Practice Chapter 5 Solutions: For More Practice 1 Chapter 5 Solutions: For More Practice 5.4 Fetching, reading registers, and writing the destination register takes a total of 300ps for both floating point add/subtract

More information

Computer Science 324 Computer Architecture Mount Holyoke College Fall Topic Notes: Data Paths and Microprogramming

Computer Science 324 Computer Architecture Mount Holyoke College Fall Topic Notes: Data Paths and Microprogramming Computer Science 324 Computer Architecture Mount Holyoke College Fall 2007 Topic Notes: Data Paths and Microprogramming We have spent time looking at the MIPS instruction set architecture and building

More information

CPE 335 Computer Organization. Basic MIPS Architecture Part I

CPE 335 Computer Organization. Basic MIPS Architecture Part I CPE 335 Computer Organization Basic MIPS Architecture Part I Dr. Iyad Jafar Adapted from Dr. Gheith Abandah slides http://www.abandah.com/gheith/courses/cpe335_s8/index.html CPE232 Basic MIPS Architecture

More information

Multiple Cycle Data Path

Multiple Cycle Data Path Multiple Cycle Data Path CS 365 Lecture 7 Prof. Yih Huang CS365 1 Multicycle Approach Break up the instructions into steps, each step takes a cycle balance the amount of work to be done restrict each cycle

More information

CPU Organization (Design)

CPU Organization (Design) ISA Requirements CPU Organization (Design) Datapath Design: Capabilities & performance characteristics of principal Functional Units (FUs) needed by ISA instructions (e.g., Registers, ALU, Shifters, Logic

More information

CSE 2021: Computer Organization Fall 2010 Solution to Assignment # 3: Multicycle Implementation

CSE 2021: Computer Organization Fall 2010 Solution to Assignment # 3: Multicycle Implementation CSE 2021: Computer Organization Fall 2010 Solution to Assignment # 3: Multicycle Implementation Note that these questions are taken from the previous final exmas of CSE2021 and should serve as practice

More information

Single Cycle Datapath

Single Cycle Datapath Single Cycle atapath Lecture notes from MKP, H. H. Lee and S. Yalamanchili Section 4.1-4.4 Appendices B.3, B.7, B.8, B.11,.2 ing Note: Appendices A-E in the hardcopy text correspond to chapters 7-11 in

More information

Single Cycle Datapath

Single Cycle Datapath Single Cycle atapath Lecture notes from MKP, H. H. Lee and S. Yalamanchili Section 4.-4.4 Appendices B.7, B.8, B.,.2 Practice Problems:, 4, 6, 9 ing (2) Introduction We will examine two MIPS implementations

More information

Computer and Information Sciences College / Computer Science Department The Processor: Datapath and Control

Computer and Information Sciences College / Computer Science Department The Processor: Datapath and Control Computer and Information Sciences College / Computer Science Department The Processor: Datapath and Control Chapter 5 The Processor: Datapath and Control Big Picture: Where are We Now? Performance of a

More information

COMPUTER ORGANIZATION AND DESIGN. 5 th Edition. The Hardware/Software Interface. Chapter 4. The Processor

COMPUTER ORGANIZATION AND DESIGN. 5 th Edition. The Hardware/Software Interface. Chapter 4. The Processor COMPUTER ORGANIZATION AND DESIGN The Hardware/Software Interface 5 th Edition Chapter 4 The Processor Introduction CPU performance factors Instruction count Determined by ISA and compiler CPI and Cycle

More information

Note- E~ S. \3 \S U\e. ~ ~s ~. 4. \\ o~ (fw' \i<.t. (~e., 3\0)

Note- E~ S. \3 \S U\e. ~ ~s ~. 4. \\ o~ (fw' \i<.t. (~e., 3\0) 5.4 A Multicycle Implementation 377 Similarly, if we had a machine with more powerful operations and addressing modes, instructions could vary from three or four functional unit delays to tens or even

More information

Chapter 4. Instruction Execution. Introduction. CPU Overview. Multiplexers. Chapter 4 The Processor 1. The Processor.

Chapter 4. Instruction Execution. Introduction. CPU Overview. Multiplexers. Chapter 4 The Processor 1. The Processor. COMPUTER ORGANIZATION AND DESIGN The Hardware/Software Interface 5 th Edition COMPUTER ORGANIZATION AND DESIGN The Hardware/Software Interface 5 th Edition Chapter 4 The Processor The Processor - Introduction

More information

COMPUTER ORGANIZATION AND DESIGN. 5 th Edition. The Hardware/Software Interface. Chapter 4. The Processor

COMPUTER ORGANIZATION AND DESIGN. 5 th Edition. The Hardware/Software Interface. Chapter 4. The Processor COMPUTER ORGANIZATION AND DESIGN The Hardware/Software Interface 5 th Edition Chapter 4 The Processor COMPUTER ORGANIZATION AND DESIGN The Hardware/Software Interface 5 th Edition The Processor - Introduction

More information

LECTURE 5. Single-Cycle Datapath and Control

LECTURE 5. Single-Cycle Datapath and Control LECTURE 5 Single-Cycle Datapath and Control PROCESSORS In lecture 1, we reminded ourselves that the datapath and control are the two components that come together to be collectively known as the processor.

More information

EECE 417 Computer Systems Architecture

EECE 417 Computer Systems Architecture EECE 417 Computer Systems Architecture Department of Electrical and Computer Engineering Howard University Charles Kim Spring 2007 1 Computer Organization and Design (3 rd Ed) -The Hardware/Software Interface

More information

The Processor. Z. Jerry Shi Department of Computer Science and Engineering University of Connecticut. CSE3666: Introduction to Computer Architecture

The Processor. Z. Jerry Shi Department of Computer Science and Engineering University of Connecticut. CSE3666: Introduction to Computer Architecture The Processor Z. Jerry Shi Department of Computer Science and Engineering University of Connecticut CSE3666: Introduction to Computer Architecture Introduction CPU performance factors Instruction count

More information

CSE 2021 Computer Organization. Hugh Chesser, CSEB 1012U W9-W

CSE 2021 Computer Organization. Hugh Chesser, CSEB 1012U W9-W CSE 22 Computer Organization Hugh Chesser, CSEB 2U Agenda Topics:. Single Cycle Review (Sample Exam/Quiz Q) 2. ultiple cycle implementation Patterson: Section 4.5 Reminder: Quiz #2 Next Wednesday (November

More information

Lecture 8: Control COS / ELE 375. Computer Architecture and Organization. Princeton University Fall Prof. David August

Lecture 8: Control COS / ELE 375. Computer Architecture and Organization. Princeton University Fall Prof. David August Lecture 8: Control COS / ELE 375 Computer Architecture and Organization Princeton University Fall 2015 Prof. David August 1 Datapath and Control Datapath The collection of state elements, computation elements,

More information

Chapter 4. The Processor

Chapter 4. The Processor Chapter 4 The Processor Introduction CPU performance factors Instruction count Determined by ISA and compiler CPI and Cycle time Determined by CPU hardware 4.1 Introduction We will examine two MIPS implementations

More information

Chapter 4. The Processor

Chapter 4. The Processor Chapter 4 The Processor Introduction CPU performance factors Instruction count Determined by ISA and compiler CPI and Cycle time Determined by CPU hardware We will examine two MIPS implementations A simplified

More information

Inf2C - Computer Systems Lecture 12 Processor Design Multi-Cycle

Inf2C - Computer Systems Lecture 12 Processor Design Multi-Cycle Inf2C - Computer Systems Lecture 12 Processor Design Multi-Cycle Boris Grot School of Informatics University of Edinburgh Previous lecture: single-cycle processor Inf2C Computer Systems - 2017-2018. Boris

More information

Initial Representation Finite State Diagram Microprogram. Sequencing Control Explicit Next State Microprogram counter

Initial Representation Finite State Diagram Microprogram. Sequencing Control Explicit Next State Microprogram counter Control Implementation Alternatives 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;

More information

CS/COE0447: Computer Organization

CS/COE0447: Computer Organization CS/COE0447: Computer Organization and Assembly Language Datapath and Control Sangyeun Cho Dept. of Computer Science A simple MIPS We will design a simple MIPS processor that supports a small instruction

More information

CS/COE0447: Computer Organization

CS/COE0447: Computer Organization A simple MIPS CS/COE447: Computer Organization and Assembly Language Datapath and Control Sangyeun Cho Dept. of Computer Science We will design a simple MIPS processor that supports a small instruction

More information

Microprogramming. Microprogramming

Microprogramming. Microprogramming Microprogramming Alternative way of specifying control FSM State -- bubble control signals in bubble next state given by signals on arc not a great language to specify when things are complex Treat as

More information

Single-Cycle Examples, Multi-Cycle Introduction

Single-Cycle Examples, Multi-Cycle Introduction Single-Cycle Examples, ulti-cycle Introduction 1 Today s enu Single cycle examples Single cycle machines vs. multi-cycle machines Why multi-cycle? Comparative performance Physical and Logical Design of

More information

Computer Science 141 Computing Hardware

Computer Science 141 Computing Hardware Computer Science 4 Computing Hardware Fall 6 Harvard University Instructor: Prof. David Brooks dbrooks@eecs.harvard.edu Upcoming topics Mon, Nov th MIPS Basic Architecture (Part ) Wed, Nov th Basic Computer

More information

COMPUTER ORGANIZATION AND DESIGN. The Hardware/Software Interface. Chapter 4. The Processor: A Based on P&H

COMPUTER ORGANIZATION AND DESIGN. The Hardware/Software Interface. Chapter 4. The Processor: A Based on P&H COMPUTER ORGANIZATION AND DESIGN The Hardware/Software Interface Chapter 4 The Processor: A Based on P&H Introduction We will examine two MIPS implementations A simplified version A more realistic pipelined

More information

Ch 5: Designing a Single Cycle Datapath

Ch 5: Designing a Single Cycle Datapath Ch 5: esigning a Single Cycle path Computer Systems Architecture CS 365 The Big Picture: Where are We Now? The Five Classic Components of a Computer Processor Control Memory path Input Output Today s Topic:

More information

ECE 3056: Architecture, Concurrency and Energy of Computation. Single and Multi-Cycle Datapaths: Practice Problems

ECE 3056: Architecture, Concurrency and Energy of Computation. Single and Multi-Cycle Datapaths: Practice Problems ECE 3056: Architecture, Concurrency and Energy of Computation Single and Multi-Cycle Datapaths: Practice Problems 1. Consider the single cycle SPIM datapath. a. Specify the values of the control signals

More information

Points available Your marks Total 100

Points available Your marks Total 100 CSSE 3 Computer Architecture I Rose-Hulman Institute of Technology Computer Science and Software Engineering Department Exam Name: Section: 3 This exam is closed book. You are allowed to use the reference

More information

CS152 Computer Architecture and Engineering Lecture 13: Microprogramming and Exceptions. Review of a Multiple Cycle Implementation

CS152 Computer Architecture and Engineering Lecture 13: Microprogramming and Exceptions. Review of a Multiple Cycle Implementation CS152 Computer Architecture and Engineering Lecture 13: Microprogramming and Exceptions March 3, 1995 Dave Patterson (patterson@cs) and Shing Kong (shing.kong@eng.sun.com) Slides available on http://http.cs.berkeley.edu/~patterson

More information

Chapter 4. The Processor. Instruction count Determined by ISA and compiler. We will examine two MIPS implementations

Chapter 4. The Processor. Instruction count Determined by ISA and compiler. We will examine two MIPS implementations Chapter 4 The Processor Part I Introduction CPU performance factors Instruction count Determined by ISA and compiler CPI and Cycle time Determined by CPU hardware We will examine two MIPS implementations

More information

The Processor: Datapath and Control. Jin-Soo Kim Computer Systems Laboratory Sungkyunkwan University

The Processor: Datapath and Control. Jin-Soo Kim Computer Systems Laboratory Sungkyunkwan University The Processor: Datapath and Control Jin-Soo Kim (jinsookim@skku.edu) Computer Systems Laboratory Sungkyunkwan University http://csl.skku.edu Introduction CPU performance factors Instruction count Determined

More information

Multicycle conclusion

Multicycle conclusion Multicycle conclusion The last few lectures covered a lot of material! We introduced a multicycle datapath, where different instructions take different numbers of cycles to execute. A multicycle unit is

More information

Design of the MIPS Processor

Design of the MIPS Processor Design of the MIPS Processor We will study the design of a simple version of MIPS that can support the following instructions: I-type instructions LW, SW R-type instructions, like ADD, SUB Conditional

More information

ECE 313 Computer Organization Name SOLUTION EXAM 2 November 3, Floating Point 20 Points

ECE 313 Computer Organization Name SOLUTION EXAM 2 November 3, Floating Point 20 Points ECE Computer Organization Name SOLTION EA November, This exam is open book and open notes. Credit for problems requiring calculation will be given only if you show your work.. Floating Point Points Translate

More information

The Processor (1) Jinkyu Jeong Computer Systems Laboratory Sungkyunkwan University

The Processor (1) Jinkyu Jeong Computer Systems Laboratory Sungkyunkwan University The Processor (1) Jinkyu Jeong (jinkyu@skku.edu) Computer Systems Laboratory Sungkyunkwan University http://csl.skku.edu EEE3050: Theory on Computer Architectures, Spring 2017, Jinkyu Jeong (jinkyu@skku.edu)

More information

ECE260: Fundamentals of Computer Engineering

ECE260: Fundamentals of Computer Engineering Datapath for a Simplified Processor James Moscola Dept. of Engineering & Computer Science York College of Pennsylvania Based on Computer Organization and Design, 5th Edition by Patterson & Hennessy Introduction

More information

ICS 233 COMPUTER ARCHITECTURE. MIPS Processor Design Multicycle Implementation

ICS 233 COMPUTER ARCHITECTURE. MIPS Processor Design Multicycle Implementation ICS 233 COMPUTER ARCHITECTURE MIPS Processor Design Multicycle Implementation Lecture 23 1 Add immediate unsigned Subtract unsigned And And immediate Or Or immediate Nor Shift left logical Shift right

More information

TDT4255 Computer Design. Lecture 4. Magnus Jahre. TDT4255 Computer Design

TDT4255 Computer Design. Lecture 4. Magnus Jahre. TDT4255 Computer Design 1 TDT4255 Computer Design Lecture 4 Magnus Jahre 2 Outline Chapter 4.1 to 4.4 A Multi-cycle Processor Appendix D 3 Chapter 4 The Processor Acknowledgement: Slides are adapted from Morgan Kaufmann companion

More information

Computer Organization and Structure. Bing-Yu Chen National Taiwan University

Computer Organization and Structure. Bing-Yu Chen National Taiwan University Computer Organization and Structure Bing-Yu Chen National Taiwan University The Processor Logic Design Conventions Building a Datapath A Simple Implementation Scheme An Overview of Pipelining Pipelined

More information

ECE 313 Computer Organization FINAL EXAM December 14, This exam is open book and open notes. You have 2 hours.

ECE 313 Computer Organization FINAL EXAM December 14, This exam is open book and open notes. You have 2 hours. This exam is open book and open notes. You have 2 hours. Problems 1-4 refer to a proposed MIPS instruction lwu (load word - update) which implements update addressing an addressing mode that is used in

More information

THE HONG KONG UNIVERSITY OF SCIENCE & TECHNOLOGY Computer Organization (COMP 2611) Spring Semester, 2014 Final Examination

THE HONG KONG UNIVERSITY OF SCIENCE & TECHNOLOGY Computer Organization (COMP 2611) Spring Semester, 2014 Final Examination THE HONG KONG UNIVERSITY OF SCIENCE & TECHNOLOGY Computer Organization (COMP 2611) Spring Semester, 2014 Final Examination May 23, 2014 Name: Email: Student ID: Lab Section Number: Instructions: 1. This

More information

Lecture 3: The Processor (Chapter 4 of textbook) Chapter 4.1

Lecture 3: The Processor (Chapter 4 of textbook) Chapter 4.1 Lecture 3: The Processor (Chapter 4 of textbook) Chapter 4.1 Introduction Chapter 4.1 Chapter 4.2 Review: MIPS (RISC) Design Principles Simplicity favors regularity fixed size instructions small number

More information

Lecture 4: Review of MIPS. Instruction formats, impl. of control and datapath, pipelined impl.

Lecture 4: Review of MIPS. Instruction formats, impl. of control and datapath, pipelined impl. Lecture 4: Review of MIPS Instruction formats, impl. of control and datapath, pipelined impl. 1 MIPS Instruction Types Data transfer: Load and store Integer arithmetic/logic Floating point arithmetic Control

More information

EECS 322 Computer Architecture Improving Memory Access: the Cache

EECS 322 Computer Architecture Improving Memory Access: the Cache EECS 322 Computer Architecture Improving emory Access: the Cache Instructor: Francis G. Wolff wolff@eecs.cwru.edu Case Western Reserve University This presentation uses powerpoint animation: please viewshow

More information

Chapter 4. The Processor Designing the datapath

Chapter 4. The Processor Designing the datapath Chapter 4 The Processor Designing the datapath Introduction CPU performance determined by Instruction Count Clock Cycles per Instruction (CPI) and Cycle time Determined by Instruction Set Architecure (ISA)

More information

The MIPS Processor Datapath

The MIPS Processor Datapath The MIPS Processor Datapath Module Outline MIPS datapath implementation Register File, Instruction memory, Data memory Instruction interpretation and execution. Combinational control Assignment: Datapath

More information

comp 180 Lecture 25 Outline of Lecture The ALU Control Operation & Design The Datapath Control Operation & Design HKUST 1 Computer Science

comp 180 Lecture 25 Outline of Lecture The ALU Control Operation & Design The Datapath Control Operation & Design HKUST 1 Computer Science Outline of Lecture The Control Operation & Design The Datapath Control Operation & Design HKST 1 Computer Science Control After the design of partial single IPS datapath, we need to add the control unit

More information

Microprogrammed Control Approach

Microprogrammed Control Approach Microprogrammed Control Approach Considering the FSM for our MIPS subset has 10 states, the complete MIPS instruction set, which contains more than 100 instructions, and considering that these instructions

More information

Single vs. Multi-cycle Implementation

Single vs. Multi-cycle Implementation Single vs. Multi-cycle Implementation Multicycle: Instructions take several faster cycles For this simple version, the multi-cycle implementation could be as much as 1.27 times faster (for a typical instruction

More information

MIPS-Lite Single-Cycle Control

MIPS-Lite Single-Cycle Control MIPS-Lite Single-Cycle Control COE68: Computer Organization and Architecture Dr. Gul N. Khan http://www.ee.ryerson.ca/~gnkhan Electrical and Computer Engineering Ryerson University Overview Single cycle

More information

CISC 662 Graduate Computer Architecture. Lecture 4 - ISA MIPS ISA. In a CPU. (vonneumann) Processor Organization

CISC 662 Graduate Computer Architecture. Lecture 4 - ISA MIPS ISA. In a CPU. (vonneumann) Processor Organization CISC 662 Graduate Computer Architecture Lecture 4 - ISA MIPS ISA Michela Taufer http://www.cis.udel.edu/~taufer/courses Powerpoint Lecture Notes from John Hennessy and David Patterson s: Computer Architecture,

More information

ECE468 Computer Organization and Architecture. Designing a Multiple Cycle Controller

ECE468 Computer Organization and Architecture. Designing a Multiple Cycle Controller ECE468 Computer Organization and Architecture Designing a Multiple Cycle Controller ECE468 multicontroller Review of a Multiple Cycle Implementation The root of the single cycle processor s problems: The

More information

COMPUTER ORGANIZATION AND DESIGN

COMPUTER ORGANIZATION AND DESIGN COMPUTER ORGANIZATION AND DESIGN 5 Edition th The Hardware/Software Interface Chapter 4 The Processor 4.1 Introduction Introduction CPU performance factors Instruction count CPI and Cycle time Determined

More information

Digital Design & Computer Architecture (E85) D. Money Harris Fall 2007

Digital Design & Computer Architecture (E85) D. Money Harris Fall 2007 Digital Design & Computer Architecture (E85) D. Money Harris Fall 2007 Final Exam This is a closed-book take-home exam. You are permitted a calculator and two 8.5x sheets of paper with notes. The exam

More information

Inf2C - Computer Systems Lecture Processor Design Single Cycle

Inf2C - Computer Systems Lecture Processor Design Single Cycle Inf2C - Computer Systems Lecture 10-11 Processor Design Single Cycle Boris Grot School of Informatics University of Edinburgh Previous lectures Combinational circuits Combinations of gates (INV, AND, OR,

More information