|
Computer Science 2500 Computer Organization Rensselaer Polytechnic Institute Spring 2009
|
|
Lecture 17: Pipelines: Dealing with Hazards
Date: Friday, April 3, 2009
- Announcements
- Figures from Chapter 4 are in the shared area
- Lecture assignment recap
- Pipeline datapath recap
- Pipelined control
- Data hazards
- Control hazards
Due at the start of class, Tuesday, April 7.
Please turn in a hard copy answer to the exercises below. We will
discuss these during class, so no late submissions are accepted.
Problems are reproduced here for the benefit of those working without
the text. All Chapter 4 figures are available in the course shared
area.
- P&H Exercise 4.12.1 and 4.12.2
In this exercise, we examine how pipelining affects the clock cycle
time of the processor. Problems in this exercise assume that
individual stages of the datapath have the following latencies:
a. IF: 300, ID: 400, EX: 350, MEM: 500, WB: 100
b. IF: 200, ID: 150, EX: 120, MEM: 190, WB: 140
4.12.1. What is the clock cycle time in a pipelined and nonpipelined
processor?
4.12.2. What is the total latency of a lw instruction in a
pipelined and nonpipelined processor?
- P&H Exercise 4.13, parts 1b, 2b, and 3b only
In this exercise, we examine how data dependences affect execution in
the basic five-stage pipeline described in Section 4.5. Problems in
this exercise refer to the following sequence of instructions:
lw $5, -16($5)
sw $5, -16($5)
add $5, $5, $5
4.13.1. Indicate dependences and their type.
4.13.2. Assume there is no forwarding in this pipelined processor.
Indicate hazards and add nop instructions to eliminate them.
4.13.3. Assume there is full forwarding. Indicate hazards and add
nop instructions to eliminate them.
- P&H Exercise 4.15, parts 1b and 3b only
In this exercise, we examine how the ISA affects pipeline design.
Problems in this exercise refer to the following new instruction:
swi Rd, Rs(Rt)
which has the effect: Mem[Rs+Rt] = Rd
4.15.1. What must be changed in the pipelined datapath to add this
instruction to the MIPS ISA?
4.15.3. Does support for this instruction introduce any new hazards?
Are stalls due to existing hazards made worse?
- P&H Exercise 4.17, parts 4a, 5a, 6a only
Each pipeline stage in Figure 4.33 has some latency. Additionally,
pipelining introduces registers between stages (Figure 4.35), and each
of these adds an additional latency. The remaining problems in this
exercise assume the following latencies for logic within each pipeline
stage and for each register between the two stages:
a. IF: 100, ID: 120, EX: 90, MEM: 130, WB: 60, Pipeline register: 10
4.17.4. Assuming there are no stalls, what is the speed-up achieved
by pipelining a single-cycle datapath?
4.17.5. We can convert all load/store instructions into
register-based (no offset) and put the memory access in parallel with
the ALU. What is the clock cycle time if this is done in the
single-cycle and in the pipelined datapath? Assume that the latency
of the new EX/MEM stage is equal to the longer of their latencies.
4.17.6. The change in 4.17.5 requires many existing lw/sw
instructions to be converted into two-instruction sequences. If this
is needed for 50% of these instructions, what is the overall speed-up
achieved by changing from the five-stage pipeline to the four-stage
pipeline where EX and MEM are done in parallel?