Docsity

The Processor - Multicycle Implementation - Lecture Slides | CS 472, Study notes of Computer Architecture and Organization

Toggle sidebar
bg1
1
CS472 1
Chapter 5
The Processor:
Multicycle
Implementation
CS472 2
Single Cycle Implementation Review
• This implementation is combinational. It is not a
series of steps, it all happens in 1 clock cycle.
• The signals within the datapath can vary
unpredictably during the clock cycle.
• All instructions take as long as the longest one.
– If we added fp instructions, every instruction would
be very long.
• Each functional unit can be used only once per
clock cycle. Some functional units must be
duplicated.
pf3
pf4
pf5
pf8

Partial preview of the text

Download The Processor - Multicycle Implementation - Lecture Slides | CS 472 and more Study notes Computer Architecture and Organization in PDF only on Docsity!

CS472 1

Chapter 5

The Processor:

Multicycle

Implementation

CS472 2

Single Cycle Implementation Review

  • This implementation is combinational. It is not a series of steps, it all happens in 1 clock cycle.
  • The signals within the datapath can vary unpredictably during the clock cycle.
  • All instructions take as long as the longest one.
    • If we added fp instructions, every instruction would be very long.
  • Each functional unit can be used only once per clock cycle. Some functional units must be duplicated.

CS472 3

Multicycle Implementation

  • An instruction is a series of steps. Each step will take 1 clock cycle. Different instructions require a different number of steps (clock cycles).
  • A functional unit may be used more than once per instruction, as long as it is used on different clock cycles - A single memory unit for instructions and data - A single ALU, rather than an ALU and two adders
  • Register(s) are added after every major functional unit to hold the output of that unit until it is needed in a subsequent clock cycle.

CS472 4

Multicycle Datapath

PC

Memory

Address

Data

Instructionor data

Instructionregister

Memorydata register

Registers

Data Register #

Register # Register #

A

B

ALU (^) ALU Out

(IR)

(MDR)

We have additional registers to hold the output of the major functional units: IR, MDR, A, B, ALUOut.

CS472 7

Sharing Functional Units

  • One memory unit for both instructions and data
    • we need a mux to select which memory address to use as an input
  • One ALU instead of 2 adders and an ALU
    • we need need more and bigger muxes for that
  • More muxes mean more control lines.
  • Multiplexors (muxes) and registers are relatively small compared to memory units and adders so we have saved some chip real estate.

CS472 8

MIPS Multicycle Divisions

  • Instruction fetch
  • Decode and register fetch
  • Execution, memory address computation, or branch completion
  • Memory access or R-type instruction completion
  • Write back step

CS472 9

Step 1: Instruction Fetch

IR = Memory[PC]

Since the ALU isn’t being used to fetch an instruction, multiplex the PC onto 1 side of the ALU and multiplex 4 onto the other side. Put the sum back into PC.

PC = PC + 4

CS472 10

Step 2: Decode Instr. / Reg. Fetch

A = Reg[ IR[25-21] ] B = Reg[ IR[20-16] ]

We don’t know what the instruction is yet, so we do things that we might need later. Calculate a new value for PC (in case this is a branch instruction)

ALUOut = PC + (sign-ext( IR[15-0]) << 2)

CS472 13

Step 5: Write Back (Memory Read Completion)

Load is the longest instruction.

Reg [ IR[20-16] ] = MDR

CS472 14

Summary

Instruction fetch^ Step name Action for R-typeinstructions Action for memory-referenceinstructions IR = Memory[PC] Action forbranches Action forjumps Instruction A = Reg [IR[25-21]]PC = PC + 4 decode/register fetch (^) ALUOut = PC + (sign-extend (IR[15-0]) << 2)B = Reg [IR[20-16]] Execution, addresscomputation, branch/ ALUOut = A op B ALUOut = A + sign-extend(IR[15-0]) if (A ==B) thenPC = ALUOut PC = PC [31-28] II(IR[25-0]<<2) jump completionMemory access or R-type Reg [IR[15-11]] = Load: MDR = Memory[ALUOut] completion ALUOut (^) Store: Memory [ALUOut] = Bor Memory read completion Load: Reg[IR[20-16]] = MDR

CS472 15

Varying Steps

Not all steps are involved in all instructions. Some may take 3 cycles, some may take 5 cycles. Steps R-type Mem-ref Branches Jumps Ld St 1 X X X X X 2 X X X X X 3 X X X X X 4 X X X 5 X

CS472 16

lw $t2, 0($t3) lw $t3, 4($t3) beq $t2, $t3, Label # assume no branch add $t5, $t2, $t sw $t5, 8($t3)

What are we doing in the 11th cycle? ______ How about the 17th cycle? ______________