




Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!





CS472 1
Chapter 5
CS472 2
CS472 3
CS472 4
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
CS472 8
CS472 9
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
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
Load is the longest instruction.
Reg [ IR[20-16] ] = MDR
CS472 14
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
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? ______________