Professional Documents
Culture Documents
Lecture 2
Instruction Sets, Pipelining
RISC Vs CISC
CISC (complex instruction set computer)
VAX, Intel X86, IBM 360/370, etc.
1/7/09
1/7/09
Early RISC projects: IBM 801 (America), Berkeley SPUR, RISC I and RISC II and Stanford MIPS.
1/7/09
op: operation of the instruction rs, rt, rd: the source and destination register specifiers shamt: shift amount funct: selects the variant of the operation in the op field address / immediate: address offset or immediate value target address: target address of the jump instruction
7
1/7/09
register PC-relative op rs PC rt
1/7/09
4.Memory (MEM):
access memory if load/store, everyone else idle
5.Writeback/retire (WB):
write results to register file
11
Solution
Overlap execution of instructions
Start instruction on every cycle, e.g. the new instruction can be fetched while the previous one is decoded pipeline. Each cycle performing a specific task; number of stages is called pipeline depth (5 here) Non-pipelined time 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
1/7/09
Pipeline Progress Instn moves with all control signals, addresses, data items => different register lengths at different stages
M U X
PC+1
R0
PC+1
target
0 valA valB
offset
regA regB
R1 R2 R3 R4 R5 R6 R7
eq?
A L U
ALU result
PC
Register file
Inst mem
M U X
IF/ ID
Pipelined Control
- Group control lines by pipeline stage needed Extend pipeline registers with control bits
instruction
M U X
Data memory
data dest
valB
Bits 11-15 Bits 16-20
M U X
dest
dest
dest
ID/ EX
EX/ Mem
Mem/ WB 13
WB Inst ruction
Mem
C ontrol
WB
Mem
EX
WB
MemToReg RegWrite
IF/ID
ID/E X
EX/MEM
ME M/WB
14
1/7/09
Decode
Execute
Memory
Write Back
IF/ID
Add 4
ID/EX
A dd S hif t left 2 Add res ult
EX/MEM
MEM/WB
PC
Add re ss
In s tru c tio n
Imem
Write data
Regs
16 Si gn exte nd 32
0 M u x 1
A ddr ess
Read data
Wri te dat a
1 M u x 0
Dmem
64 bits
133 bits
102 bits
69 bits 15
16
1/7/09
Pipeline Hazards
Hazards are caused by conflicts between instructions. Will lead to incorrect behavior if not fixed.
Three types:
o Structural: two instructions use same h/w in the same cycle resource conflicts (e.g. one memory port, unpipelined divider etc). o Data: two instructions use same data storage (register/memory) dependent instructions. o Control: one instruction affects which instruction is next PC modifying instruction, changes control flow of program.
17
Handling Hazards
Force stalls or bubbles in the pipeline.
Stop some younger instructions in the stage when hazard happens Make younger instr. Wait for older ones to complete Implementation: de-assert write-enable signals to pipeline registers Blow instructions out of the pipeline Refetch new instructions later solving control hazards Implementation: assert clear signals on pipeline registers
18
Flush pipeline