组织
用户5691
添加快捷方式
分享
Complex Computer Construction
输入“/”快速插入内容
Complex Computer Construction
用户5691
用户5691
2024年6月20日修改
Pipelining Basis
•
Stages of single cycle CPU
◦
IF
: instruction fetch from memory (inst mem)
◦
ID
: instruction decoding and register read (reg)
◦
EX
: execute operation or calculate address (ALU)
◦
MEM
: access data memory operand (
data
mem)
◦
WB
: write result back to register (reg)
◦
Notice that EX and WB are only related to registers
•
Performance issues
•
Longest delay determines clock period
◦
e.g. The
lw
instruction in right
•
Most blocks are idle most of the time
•
Pipelining improves performance by increasing instruction throughput
◦
Executes multiple instructions in parallel
◦
Each instruction has the same latency
50%
•
Mind that:
◦
ALU/Logic: IF, ID, ALU, WB; no MEM needed
◦
Jump/Branch: IF, ID, ALU; both MEM, WB don't needed
◦
Load: all five stages needed, including ALU
◦
Store: IF, ID, ALU, MEM; no WB needed
50%
•
In pipelined CPU, each stage takes one clock cycle
◦
Whereas in single-cycle, each instruction takes one clock cycle,
◦
That in pipelined,
▪
All cycles of the same length
▪
Speedup
is based on
so we should expect a high acceleration
•
In this case: originally
, now
, 4x speedup
•
Speedup due to increased throughput,
latency
(time for each instruction) does not decrease
50%
•
When not specially mentioned, we consider a 5-stages case
50%
•
RISC-V ISA is designed for pipelining
◦
All instructions are 32-bits long, easier to fetch and decode
◦
Fewer and regular instruction format
◦
Instruction set design affects complexity of pipeline implementation
•
Hazards
◦
Can usually resolve hazards by
stall
(waiting, using NOP)
▪
e.g. For 0.05*n NOPs, that is, we need to use
instead
•
Structure hazards
◦
That a required resource is busy, e.g. A unified memory being used simultaneously
▪
The mem conflict case cannot be solved using NOP
, because NOP is also an instruction that needs to be taken from inst-mem
▪
In RISC-V, we use two separate memories to solve: inst-mem and d-mem
50%
•
However, we do not always need a stall, because sometimes an instruction may actually not access some memory part
50%
◦
Data hazards
▪
When data is needed to execute, the instruction is not yet available
▪
Two types:
register usage (related to reg), load-use (related to mem loading, esp. data-mem)