Lab 5 preview
Hung-Wei Tseng
Lab 5 preview Hung-Wei Tseng Announcement Lab 4 due Thursday - - PowerPoint PPT Presentation
Lab 5 preview Hung-Wei Tseng Announcement Lab 4 due Thursday before 5:30pm! Interview with any of us Lab 5 & 6 due next Thursday No extension Come and have some pizza together next Friday @ 6p! 2 In Lab 5...
Hung-Wei Tseng
6p!
2
3
4
Read Address
Instruc(on Memory
PC ALU Write Data 4 Add Read Data 1 Read Data 2 Read Reg 1 Read Reg 2 Write Reg
Register File
inst[25:21] inst[20:16] inst[15:11] inst[31:0]
m u x
0 1
m u x
0 1
sign- extend
32 16
Data Memory
Address Read Data
m u x
1
Write Data
JumpOut BranchOut Func_in RegDst Jump re_in MemToReg we_in ALUSrc RegWrite
Add Shi> le> 2
m u x
1
inst[25:0] Shi> le> 2 26 28
PC+4[31:28] size_in
control unit
inst[31:26], inst[5:0]
m u x
1
5
Read Address
Instruc(on Memory
PC ALU Write Data 4 Add Read Data 1 Read Data 2 Read Reg 1 Read Reg 2 Write Reg
Register File
inst[25:21] inst[20:16] inst[15:11] inst[31:0]
m u x
0 1
m u x
0 1
sign- extend
32 16
Data Memory
Address Read Data
m u x
1
Write Data
JumpOut BranchOut Func_in RegDst Jump re_in MemToReg we_in ALUSrc RegWrite
Add Shi> le> 2
m u x
1
inst[25:0] Shi> le> 2 26 28
PC+4[31:28] size_in
control unit
inst[31:26], inst[5:0]
m u x
1
6
Read Address
Instruc(on Memory
PC ALU Write Data 4 Add Read Data 1 Read Data 2 Read Reg 1 Read Reg 2 Write Reg
Register File
inst[25:21] inst[20:16]
inst[15:11]
inst[31:0]
m u x
0 1
m u x
0 1
sign- extend
32 16
Data Memory
Address Read Data
m u x
1
Write Data
JumpOut BranchOut Func_in RegDst Jump re_in MemToReg we_in ALUSrc RegWrite
Add Shi> le> 2
m u x
1
inst[25:0] Shi> le> 2 26 28
PC+4[31:28] size_in
control unit
inst[31:26], inst[5:0]
m u x
1
but publicized in WB!
away!
7
add $1, $2, $3 lw $4, 0($1) sub $5, $2, $4 sub $1, $3, $1 sw $1, 0($5)
IF EXE ID IF ID IF
We can obtain the result here!
8
add $1, $2, $3 lw $4, 0($1) sub $5, $2, $4 sub $1, $3, $1 sw $1, 0($5)
IF EXE ID IF ID IF WB MEM EXE ID IF MEM WB ID MEM EXE WB IF ID MEM EXE WB IF ID MEM EXE WB
forwarding the result from the previous instruction (Ins#1) to the EXE stage of the current instruction (Ins#2)?
9
We need to know the following:
If ins #1 is R-type: rs, rt of ins #2 == rd of ins #1 If ins #1 is I-type: rs, rt of ins #2 == rt of ins #1
rs rt rd shift amount funct
rs rt immediate / offset
result from a previous instruction that is entering MEM stage or WB stage
register file
10
11
Read Address
Instruc(on Memory
PC ALU Write Data 4 Add Read Data 1 Read Data 2 Read Reg 1 Read Reg 2 Write Reg
Register File
inst[25:21] inst[20:16] inst[31:0]
m u x
0 1
m u x
0 1
sign- extend
32 16
Data Memory
Address Read Data
m u x
1
Write Data
m u x
1
Add Shi> le> 2 ALUSrc
MemtoReg
MemRead
RegDst
RegWrite MemWrite PCSrc
Zero
IF/ID ID/EX EX/MEM MEM/WB
inst[15:11] ALUop
Contr
W M E W M W
RegWrite
forwardin g
m u x
ForwardA ForwardB ForwardA ForwardB
destination of Ins#1 Rs of Ins#2 Rt of Ins#2 ALU result of Ins#1 Control of Ins#1 Control of Ins#2
inst[31:25],inst[5:0]
previous instruction (Ins#1) curernt instruction (Ins#2)
12
Read Address
Instruc(on Memory
PC ALU Write Data 4 Add Read Data 1 Read Data 2 Read Reg 1 Read Reg 2 Write Reg
Register File
inst[25:21] inst[20:16] inst[31:0]
m u x
0 1
m u x
0 1
sign- extend
32 16
Data Memory
Address Read Data
m u x
1
Write Data
m u x
1
Add Shi> le> 2 ALUSrc
MemtoReg
MemRead
RegDst
RegWrite MemWrite PCSrc
Zero
IF/ID ID/EX EX/MEM MEM/WB
inst[15:11] ALUop
Contr
W M E W M W
RegWrite
forwardin g
m u x
ForwardA ForwardB ForwardA ForwardB
Rd of Ins#1 ALU/MEM result of Ins#1 Control of Ins#1
inst[31:25],inst[5:0]
13
add $1, $2, $3 lw $4, 0($1) sub $5, $2, $4 sub $1, $3, $1 sw $1, 0($5)
IF EXE ID IF ID IF WB MEM EXE ID IF MEM WB ID MEM EXE WB IF ID MEM EXE WB IF ID MEM EXE WB
lw generates result at MEM stage, we have to stall
load instruction that does not finish its MEM stage yet, we have to stall!
We need to know the following:
(rs, rt of ID/EX == rt of EX/MEM #1)
14
Read Address
Instruc(on Memory
PC ALU Write Data 4 Add Read Data 1 Read Data 2 Read Reg 1 Read Reg 2 Write Reg
Register File
inst[25:21] inst[20:16] inst[31:0]
m u x
0 1
m u x
0 1
sign- extend
32 16
Data Memory
Address Read Data
m u x
1
Write Data
m u x
1
Add Shi> le> 2 ALUSrc
MemtoReg
MemRead
RegDst
RegWrite MemWrite PCSrc
Zero
IF/ID ID/EX EX/MEM MEM/WB
inst[15:11] ALUop
Contr
W M E W M W
RegWrite
forwardin g
m u x
ForwardA ForwardB ForwardA ForwardB
hazard detection unit
ID/EX.MemRead PCWrite IF/IDWrite
m u x
inst[31:25],inst[5:0]
15
Read Address
Instruc(on Memory
PC ALU Write Data 4 Add Read Data 1 Read Data 2 Read Reg 1 Read Reg 2 Write Reg
Register File
inst[25:21] inst[20:16] inst[31:0]
m u x
0 1
m u x
0 1
sign- extend
32 16
Data Memory
Address Read Data
m u x
1
Write Data
m u x
1
Add Shi> le> 2
MemtoReg
MemRead
RegDst
RegWrite MemWrite PCSrc
Zero
IF/ID ID/EX EX/MEM MEM/WB
inst[15:11] ALUop
Contr
W M E W M W
RegWrite
ALUSrc hazard detection unit
ID/EX.MemRead PCWrite IF/IDWrite
m u x
Check if the destination register of EX == source register of the instruction in ID Check if the destination register of MEM == source register of the instruction in ID Insert a “noop” if we need to stall
inst[31:25],inst[5:0]
16
17
18
19
20
21