Rung-Bin Lin
Appendix-1
Rung-Bin Lin
Appendix-2
Rung-Bin Lin
Appendix-3
Rung-Bin Lin
Appendix-4
Rung-Bin Lin
Appendix-5
Rung-Bin Lin
Appendix-6
Instruction Issue
The process of letting an instruction move from the
instruction decode stage (ID) into execution stage
(EX) of this pipeline.
Rung-Bin Lin
Appendix-7
Example in A-10.
Rung-Bin Lin
Appendix-8
Rung-Bin Lin
Appendix-9
CPI pipelined
Clock cycle pipelined
CPI unpipelined
1 Pipeline stall cycles per instruction
Pipeline depth
1 Pipeline stall cycles per instruction
Rung-Bin Lin
Appendix-10
1
Clock cycle unpipelined
Pipeline depth
1 Pipeline stall cycles per instruction
Rung-Bin Lin
Structural Hazards
Due to resource conflicts (Example in A-14)
Due to some functional unit being not fully pipelined.
When some resources have not been duplicated enough.
Appendix-11
Rung-Bin Lin
Data Hazards
A memory access depends on the results of unfinishing
instructions.
Appendix-12
Rung-Bin Lin
Appendix-13
Rung-Bin Lin
Appendix-14
Rung-Bin Lin
Appendix-15
Rung-Bin Lin
Appendix-16
Rung-Bin Lin
Appendix-17
Load interlock
Example (Fig. A.10 at A-21)
Rung-Bin Lin
Appendix-18
Control Hazards
Caused by the instructions that change PC.
Some basics
If a branch changes the PC to its target address, it is a taken
branch. If it does not change the PC, it falls through or it is not
taken.
Recall that if an instruction i is a taken branch, the PC is normally
not changed until the end of ID. A stall cycle is required.
Branch Instruction
Branch successor
Branch successor+1
Branch successor+2
IF ID EX MEM WB
IF IF ID
EX MEM WB
IF
ID EX
MEM WB
IF ID
EX
MEM WB
Rung-Bin Lin
Appendix-19
Branch Penalty
Branch delay: The length of a control hazard.
Branch penalty: The branch delay, unless it is dealt with,
turns into branch penalty.
The deeper the pipeline, the worse the branch penalty.
The number of branch stalls can be reduced by two steps
Find out whether the branch is taken or not taken earlier in the
pipeline.
Compute the taken PC (i.e., the address of the branch target)
earlier.
Rung-Bin Lin
Delayed branch:
The execution cycle with a branch delay n is
Branch instruction
Sequential successor 1
Sequential successor 2
Appendix-20
Rung-Bin Lin
Appendix-21
Rung-Bin Lin
Appendix-22
Rung-Bin Lin
Appendix-23
Rung-Bin Lin
Appendix-24
Rung-Bin Lin
Appendix-25
Rung-Bin Lin
Appendix-26
Rung-Bin Lin
Appendix-27
Rung-Bin Lin
Appendix-28
Rung-Bin Lin
Appendix-29
Rung-Bin Lin
Appendix-30
Types of Exceptions
Types
Rung-Bin Lin
Appendix-31
Classification of Exceptions
Synchronous versus asynchronous
If the event occurs at the same place every time that the program
is executed with the same data and memory allocation, the event is
called synchronous.
Rung-Bin Lin
Appendix-32
Rung-Bin Lin
Appendix-33
Exception Handling
Stopping and restarting execution
Force a trap instruction on the next IF
Until the trap is taken, turn off all writes for the faulting instruction and
for all instructions that follow in the pipeline.
After the exception-handling routine in the operating system receives
control, it immediately saves the PC of the faulting instruction.
IF
ID
EX
MEM
IF
ID
EX
MEM
WB
IF
ID
EX
MEM
WB
IF
ID
EX
MEM
IF
ID
EX
WB
MEM
Rung-Bin Lin
Appendix-34
Precise Interrupt
If a pipeline can be stopped so that the instructions
just before the faulting instruction are completed
and those after it can be restarted from scratch.
Supporting precise interrupts is a requirement in many
systems.
Exceptions in DLX
With pipelining, multiple exceptions may occur in the
same clock cycle. (fig. A.28 on page A-44).
Rung-Bin Lin
Appendix-35
Implementation
Hardware posts all exceptions caused by a given instruction in a
status vector associated that instruction.
Once an exception indication is set in the exception status vector,
any control signal that may cause a data value to be written is
turned off.
When an instruction enters WB, the exception status vector is
checked, if any exceptions are posted, they are handled in the
order in which they would occur in time on an unpipelined
machine.
This will guarantee that all exceptions will be seen on instruction i
before any are seen on i+1.
Rung-Bin Lin
Appendix-36
Instruction Committed
When an instruction is guaranteed to complete, it is called
committed.
In the MIPS pipeline, all instructions are committed when
they reach the end of the MEM stage and no instruction
updates the state before that stage. Thus precise exceptions
are straight forward.
Rung-Bin Lin
Appendix-37
Rung-Bin Lin
Appendix-38
Rung-Bin Lin
Appendix-39
Rung-Bin Lin
Appendix-40
Rung-Bin Lin
Appendix-41
Latency
0
1
3
6
24
Initiation interval
1
1
1
1
25
Rung-Bin Lin
Appendix-42
Rung-Bin Lin
Appendix-43
Rung-Bin Lin
Appendix-44
Rung-Bin Lin
Appendix-45
F0, F2, F4
F10, F10, F8
F12, F12, F14
Rung-Bin Lin
Appendix-46
Rung-Bin Lin
Appendix-47
Rung-Bin Lin
Appendix-48
Rung-Bin Lin
Appendix-49
Rung-Bin Lin
Appendix-50
Rung-Bin Lin
Appendix-51
Rung-Bin Lin
Appendix-52
Rung-Bin Lin
Appendix-53
Concluding Remarks
We can spend a little money to buy a very powerful
computer today.