CSSE232 Computer Architecture I Mul5cycle Datapath Class - - PowerPoint PPT Presentation

csse232 computer architecture i
SMART_READER_LITE
LIVE PREVIEW

CSSE232 Computer Architecture I Mul5cycle Datapath Class - - PowerPoint PPT Presentation

CSSE232 Computer Architecture I Mul5cycle Datapath Class Status Next 3 days : Mul5cycle datapath Reading Mul5cycle datapath is not in the book!


slide-1
SLIDE 1

CSSE232 ¡ Computer ¡Architecture ¡I ¡

Mul5cycle ¡Datapath ¡

slide-2
SLIDE 2

Class ¡Status ¡

  • Next ¡3 ¡days ¡: ¡Mul5cycle ¡datapath ¡

– Reading ¡

  • Mul5cycle ¡datapath ¡is ¡not ¡in ¡the ¡book! ¡
slide-3
SLIDE 3

How ¡long ¡do ¡instruc5ons ¡take? ¡

  • ALU ¡2ns ¡
  • Mem ¡2ns ¡
  • Reg ¡File ¡1ns ¡
  • Everything ¡ ¡

else ¡is ¡free! ¡

slide-4
SLIDE 4

How ¡long ¡do ¡instruc5ons ¡take? ¡

  • ALU ¡2ns ¡
  • Mem ¡2ns ¡
  • Reg ¡File ¡1ns ¡
  • Everything ¡ ¡

else ¡is ¡free! ¡

  • R-­‑type? ¡Branch? ¡ ¡

Store? ¡Load? ¡

slide-5
SLIDE 5

Outline ¡ ¡

  • Problems ¡with ¡single-­‑cycle ¡
  • Steps ¡

– IF, ¡ID, ¡EXEC, ¡MEM, ¡WB ¡

  • RTL ¡(Register ¡Transfer ¡Language) ¡

– Describe ¡processor ¡ac5ons ¡

slide-6
SLIDE 6

Single ¡Cycle ¡Design ¡Problems ¡

  • What ¡are ¡they? ¡
slide-7
SLIDE 7

Single ¡Cycle ¡Design ¡Problems ¡

  • Fixed ¡period ¡clock ¡

– Every ¡instruc5on ¡takes ¡one ¡clock ¡cycle ¡ – All ¡cycles ¡same ¡length ¡ – Cycle ¡5me ¡set ¡by ¡longest ¡instruc5on ¡path ¡(lw) ¡

  • Some ¡instruc5ons ¡could ¡run ¡faster ¡
  • What ¡if ¡we ¡have ¡very ¡long ¡instruc5ons? ¡(floa5ng ¡point) ¡
  • Many ¡adders ¡

– Duplicate ¡hardware ¡is ¡a ¡waste? ¡

slide-8
SLIDE 8

Improving ¡Single ¡Cycle ¡

  • Reduce ¡hardware ¡use? ¡
  • Reduce ¡5me ¡use? ¡
slide-9
SLIDE 9

Improving ¡Single ¡Cycle ¡

  • Reduce ¡hardware ¡use? ¡

– Very ¡hard, ¡all ¡parts ¡are ¡needed ¡

  • Reduce ¡5me ¡use? ¡

– Variable ¡length ¡clock ¡

  • Longer ¡for ¡lw, ¡shorter ¡for ¡branch ¡
  • Has ¡been ¡done, ¡hard ¡to ¡do ¡in ¡prac5ce ¡

– Shorter ¡clock ¡cycles ¡

  • Break ¡work ¡into ¡small ¡steps ¡
  • Con5nue ¡instruc5on ¡if ¡not ¡finished ¡aZer ¡step ¡
slide-10
SLIDE 10

Mul5cycle ¡

  • Break ¡instruc5ons ¡into ¡steps ¡

– Each ¡step ¡takes ¡one ¡cycle ¡ – Each ¡step ¡needs ¡approximately ¡the ¡same ¡5me ¡ – Each ¡step ¡uses ¡one ¡piece ¡of ¡hardware ¡

  • Save ¡instruc5on ¡data ¡between ¡steps ¡

– Save ¡par5al ¡work ¡at ¡end ¡of ¡cycle ¡ – Next ¡cycle, ¡con5nue ¡instruc5on ¡

slide-11
SLIDE 11

PC Instruction memory Read address Instruction 16 32 Add ALU result M u x Registers Write register Write data Read data 1 Read data 2 Read register 1 Read register 2 Shift left 2 4 M u x ALU operation 3 RegWrite MemRead MemWrite PCSrc ALUSrc MemtoReg ALU result Zero ALU Data memory Address Write data Read data M u x Sign extend Add

ALU ¡2ns ¡ ¡ ¡ ¡ ¡Mem ¡2ns ¡ ¡ ¡ ¡ ¡Reg ¡1ns ¡

slide-12
SLIDE 12

Breaking ¡instruc5ons ¡into ¡steps ¡

  • Our ¡goal ¡is ¡to ¡break ¡up ¡the ¡instruc5ons ¡into ¡steps ¡so ¡that ¡

– each ¡step ¡takes ¡one ¡clock ¡cycle ¡ – the ¡amount ¡of ¡work ¡to ¡be ¡done ¡in ¡each ¡step/cycle ¡is ¡about ¡equal ¡ – each ¡cycle ¡uses ¡at ¡most ¡once ¡each ¡major ¡func5onal ¡unit ¡so ¡that ¡ such ¡units ¡do ¡not ¡have ¡to ¡be ¡replicated ¡ – func5onal ¡units ¡can ¡be ¡shared ¡between ¡different ¡cycles ¡within ¡

  • ne ¡instruc5on ¡
  • Data ¡at ¡end ¡of ¡one ¡cycle ¡to ¡be ¡used ¡in ¡next ¡must ¡be ¡

stored ¡!! ¡

slide-13
SLIDE 13

Breaking ¡instruc5ons ¡into ¡steps ¡

  • We ¡break ¡instruc5ons ¡into ¡the ¡following ¡poten/al ¡execu5on ¡

steps ¡– ¡not ¡all ¡instruc5ons ¡require ¡all ¡the ¡steps ¡– ¡each ¡step ¡ takes ¡one ¡clock ¡cycle ¡

  • 1. Instruc5on ¡fetch ¡and ¡PC ¡increment ¡(IF) ¡
  • 2. Instruc5on ¡decode ¡and ¡register ¡fetch ¡(ID) ¡
  • 3. Execu5on, ¡memory ¡address ¡computa5on, ¡or ¡branch ¡comple5on ¡(EX) ¡
  • 4. Memory ¡access ¡or ¡R-­‑type ¡instruc5on ¡comple5on ¡(MEM) ¡
  • 5. Memory ¡read ¡comple5on ¡(WB) ¡
  • Each ¡MIPS ¡instruc5on ¡takes ¡from ¡3 ¡– ¡5 ¡cycles ¡(steps) ¡
slide-14
SLIDE 14

Step ¡1: ¡ ¡Instruc5on ¡Fetch ¡& ¡PC ¡ Increment ¡(IF) ¡

  • Use ¡PC ¡to ¡get ¡instruc5on ¡and ¡put ¡it ¡in ¡the ¡instruc5on ¡register. ¡

¡ ¡ ¡ ¡Increment ¡the ¡PC ¡by ¡4 ¡and ¡put ¡the ¡result ¡back ¡in ¡the ¡PC. ¡

  • Can ¡be ¡described ¡succinctly ¡using ¡RTL ¡(Register-­‑Transfer ¡Language): ¡

IR = Memory[PC];

PC = PC + 4;

slide-15
SLIDE 15

Step ¡2: ¡ ¡Instruc5on ¡Decode ¡and ¡Register ¡ Fetch ¡(ID) ¡

  • Read ¡registers ¡rs ¡and ¡rt ¡in ¡case ¡we ¡need ¡them. ¡

¡ ¡ ¡ ¡Compute ¡the ¡branch ¡address ¡in ¡case ¡the ¡instruc5on ¡is ¡a ¡branch. ¡

  • RTL: ¡

A = Reg[IR[25-21]]; B = Reg[IR[20-16]]; ALUOut = PC + (sign-extend(IR[15-0]) << 2); ¡ ¡

slide-16
SLIDE 16

Step ¡3: ¡Execu5on, ¡Address ¡Computa5on ¡

  • r ¡Branch ¡Comple5on ¡(EX) ¡
  • ALU ¡performs ¡one ¡of ¡four ¡func5ons ¡depending ¡on ¡instruc5on ¡type ¡

– memory ¡reference: ¡ ALUOut = A + sign-extend(IR[15-0]); ¡ – R-­‑type: ¡ ALUOut = A op B; ¡ – branch ¡(instruc5on ¡completes): ¡ if (A==B) PC = ALUOut; – jump ¡(instruc5on ¡completes): ¡ ¡ ¡ ¡PC = PC[31-28] || (IR(25-0) << 2)

¡ ¡Note ¡that ¡the ¡PC ¡is ¡wriden ¡twice!! ¡

slide-17
SLIDE 17

Step ¡4: ¡Memory ¡access ¡or ¡R-­‑type ¡ Instruc5on ¡Comple5on ¡ (MEM) ¡

  • Again ¡depending ¡on ¡instruc5on ¡type: ¡
  • Loads ¡and ¡stores ¡access ¡memory ¡

– load ¡ MDR = Memory[ALUOut]; ¡ – store ¡(instruc5on ¡completes) Memory[ALUOut] = B; ¡ ¡

  • R-­‑type ¡(instruc5ons ¡completes) ¡

Reg[IR[15-11]] = ALUOut; ¡ ¡ ¡

¡ ¡

slide-18
SLIDE 18

Step ¡5: ¡Memory ¡Read ¡Comple5on ¡ (WB) ¡

  • Again ¡depending ¡on ¡instruc5on ¡type: ¡
  • Load ¡writes ¡back ¡(instruc5on ¡completes) ¡

Reg[IR[20-16]]= MDR; Important: ¡There ¡is ¡no ¡reason ¡from ¡a ¡datapath ¡(or ¡control) ¡point ¡of ¡ view ¡that ¡Step ¡5 ¡cannot ¡be ¡eliminated ¡by ¡performing ¡ Reg[IR[20-16]]= Memory[ALUOut]; ¡ ¡ ¡ ¡for ¡loads ¡in ¡Step ¡4. ¡This ¡would ¡eliminate ¡the ¡MDR ¡as ¡well. ¡ ¡ The ¡reason ¡this ¡is ¡not ¡done ¡is ¡that, ¡to ¡keep ¡steps ¡balanced ¡in ¡length, ¡ the ¡design ¡restric5on ¡is ¡to ¡allow ¡each ¡step ¡to ¡contain ¡at ¡most ¡one ¡ ALU ¡opera5on, ¡or ¡one ¡register ¡access, ¡or ¡one ¡memory ¡access. ¡

slide-19
SLIDE 19

Summary ¡of ¡Instruc5on ¡Execu5on ¡

Step name Action for R-type instructions Action for memory-reference instructions Action for branches Action for jumps Instruction fetch IR = Memory[PC] PC = PC + 4 Instruction A = Reg [IR[25-21]] decode/register fetch B = Reg [IR[20-16]] ALUOut = PC + (sign-extend (IR[15-0]) << 2) Execution, address ALUOut = A op B ALUOut = A + sign-extend if (A ==B) then PC = PC [31-28] II computation, branch/ (IR[15-0]) PC = ALUOut (IR[25-0]<<2) jump completion Memory access or R-type Reg [IR[15-11]] = Load: MDR = Memory[ALUOut] completion ALUOut

  • r

Store: Memory [ALUOut] = B Memory read completion Load: Reg[IR[20-16]] = MDR

1: IF 2: ID 3: EX 4: MEM 5: WB Step

slide-20
SLIDE 20

Mul5cycle ¡Approach ¡ ¡ ¡

PC Instruction memory Read address Instruction 16 32 Add ALU result M u x Registers Write register Write data Read data 1 Read data 2 Read register 1 Read register 2 Shift left 2 4 M u x ALU operation 3 RegWrite MemRead MemWrite PCSrc ALUSrc MemtoReg ALU result Zero ALU Data memory Address Write data Read data M u x Sign extend Add

Single-cycle datapath

slide-21
SLIDE 21

Mul5cycle ¡Approach ¡ ¡ ¡

¡

  • Note ¡par5culari5es ¡of ¡

¡ ¡ ¡ ¡mul5cyle ¡vs. ¡single-­‑ ¡ ¡ ¡ ¡ ¡diagrams ¡

– single ¡memory ¡for ¡data ¡ ¡ ¡ ¡ ¡and ¡instruc5ons ¡ – single ¡ALU, ¡no ¡extra ¡adders ¡ – extra ¡registers ¡to ¡ ¡ ¡ ¡ ¡ ¡hold ¡data ¡between ¡ ¡ ¡ ¡ ¡ ¡clock ¡cycles ¡

¡ ¡ ¡

¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡ ¡

PC Instruction memory Read address Instruction 16 32 Add ALU result M u x Registers Write register Write data Read data 1 Read data 2 Read register 1 Read register 2 Shift left 2 4 M u x ALU operation 3 RegWrite MemRead MemWrite PCSrc ALUSrc MemtoReg ALU result Zero ALU Data memory Address Write data Read data M u x Sign extend Add PC Memory Address Instruction

  • r data

Data Instruction register Registers Register # Data Register # Register # ALU Memory data register A B ALUOut

Single-cycle datapath Multicycle datapath (high-level view)

slide-22
SLIDE 22

Mul5cycle ¡Datapath ¡

Shift left 2 PC Memory MemData Write data M u x 1 Registers Write register Write data Read data 1 Read data 2 Read register 1 Read register 2 M u x 1 M u x 1 4 Instruction [15– 0] Sign extend 32 16 Instruction [25– 21] Instruction [20– 16] Instruction [15– 0] Instruction register 1 M u x 3 2 M u x ALU result ALU Zero Memory data register Instruction [15– 11] A B ALUOut 1 Address

Basic multicycle MIPS datapath handles R-type instructions and load/stores: new internal registers and new multiplexors in ovals.

slide-23
SLIDE 23

Mul5cycle ¡Datapath ¡

Shift left 2 PC Memory MemData Write data M u x 1 Registers Write register Write data Read data 1 Read data 2 Read register 1 Read register 2 M u x 1 M u x 1 4 Instruction [15– 0] Sign extend 32 16 Instruction [25– 21] Instruction [20– 16] Instruction [15– 0] Instruction register 1 M u x 3 2 M u x ALU result ALU Zero Memory data register Instruction [15– 11] A B ALUOut 1 Address

Basic multicycle MIPS datapath handles R-type instructions and load/stores: new internal registers and new multiplexors in ovals.

slide-24
SLIDE 24

Mul5cycle ¡Execu5on ¡Step ¡(1): ¡ Instruc5on ¡Fetch ¡

IR = Memory[PC]; PC = PC + 4; ¡

4

PC ¡+ ¡4 ¡

slide-25
SLIDE 25

Mul5cycle ¡Execu5on ¡Step ¡(2): ¡ Instruc5on ¡Decode ¡& ¡Register ¡Fetch ¡

A = Reg[IR[25-21]]; (A = Reg[rs]) B = Reg[IR[20-15]]; (B = Reg[rt]) ALUOut = (PC + sign-extend(IR[15-0]) << 2) ¡

Branch ¡ Target ¡ Address ¡ Reg[rs] ¡ Reg[rt] ¡ PC ¡+ ¡4 ¡

slide-26
SLIDE 26

Mul5cycle ¡Execu5on ¡Step ¡(3): ¡ Memory ¡Reference ¡Instruc5ons ¡

ALUOut = A + sign-extend(IR[15-0]); ¡

  • Mem. ¡

Address ¡ Reg[rs] ¡ Reg[rt] ¡ PC ¡+ ¡4 ¡

slide-27
SLIDE 27

Mul5cycle ¡Execu5on ¡Step ¡(3): ¡ ALU ¡Instruc5on ¡(R-­‑Type) ¡

ALUOut = A op B ¡

R-­‑Type ¡ Result ¡ Reg[rs] ¡ Reg[rt] ¡ PC ¡+ ¡4 ¡

slide-28
SLIDE 28

Mul5cycle ¡Execu5on ¡Step ¡(3): ¡ Branch ¡Instruc5ons ¡

if (A == B) PC = ALUOut; ¡

Branch ¡ Target ¡ Address ¡ Reg[rs] ¡ Reg[rt] ¡ Branch ¡ Target ¡ Address ¡

slide-29
SLIDE 29

Mul5cycle ¡Execu5on ¡Step ¡(3): ¡ Jump ¡Instruc5on ¡

PC = PC[31-28] concat (IR[25-0] << 2) ¡

Jump ¡ Address ¡ Reg[rs] ¡ Reg[rt] ¡ Branch ¡ Target ¡ Address ¡

slide-30
SLIDE 30

Mul5cycle ¡Execu5on ¡Step ¡(4): ¡ Memory ¡Access ¡-­‑ ¡Read ¡(lw) ¡

MDR = Memory[ALUOut]; ¡

  • Mem. ¡

Data ¡ PC ¡+ ¡4 ¡ Reg[rs] ¡ Reg[rt] ¡

  • Mem. ¡

Address ¡

slide-31
SLIDE 31

Mul5cycle ¡Execu5on ¡Step ¡(4): ¡ Memory ¡Access ¡-­‑ ¡Write ¡(sw) ¡

Memory[ALUOut] = B; ¡

PC ¡+ ¡4 ¡ Reg[rs] ¡ Reg[rt] ¡

slide-32
SLIDE 32

Mul5cycle ¡Execu5on ¡Step ¡(4): ¡ ALU ¡Instruc5on ¡(R-­‑Type) ¡

Reg[IR[15:11]] = ALUOUT ¡

R-­‑Type ¡ Result ¡ Reg[rs] ¡ Reg[rt] ¡ PC ¡+ ¡4 ¡

slide-33
SLIDE 33

Mul5cycle ¡Execu5on ¡Step ¡(5): ¡ Memory ¡Read ¡Comple5on ¡(lw) ¡

Reg[IR[20-16]] = MDR; ¡

PC ¡+ ¡4 ¡ Reg[rs] ¡ Reg[rt] ¡

  • Mem. ¡

Data ¡

  • Mem. ¡

Address ¡

slide-34
SLIDE 34

Review ¡and ¡Ques5ons ¡

  • Problems ¡with ¡single-­‑cycle ¡
  • Steps ¡
  • RTL ¡