Manual Pipelining
Manual Pipelining
Objectives
At the end of this lab students should be able to:
1. Demonstrate the difference between pipelined and sequential processing of the
CPU instructions
2. Understand pipeline data dependency and data hazard
3. Explain a pipeline technique to eliminate data hazards
4. Demonstrate compiler “loop unrolling” optimization’s benefits for instruction
pipelining
5. Describe the re‐arranging of instructions by compiler to minimize data dependencies
6. Learn to make use of jump‐predict table for pipeline optimization.
Make sure No instruction pipeline check box is selected. In the CPU simulator window bring the
speed slider down to around a reading of 30. Run the program and observe the pipeline. Wait for
the program to complete. Now make a note of the following values
BITS
Next, the No instruction pipeline checkbox is unchecked. Reset and run the above program again
and wait for it to complete.
Note down the observation and watch the pipeline to visualize the different behavior of the
pipeline
Exercise 2 – CPU pipeline data hazards, bubbles and the NOP instruction
A data hazard is caused by unavailability of an operand value when it is needed. In order to
demonstrate this create a program (call it Ex2) and enter the following set of instructions.
MOV #3, R02
MOV #4, R03
MOV #5, R02
ADD R02, R03
HLT
Before running the program make a note of the result expexted,
R03=?
Make sure the No instruction pipeline is NOT checked and Do not insert bubbles is checked.
Reset the program and run the above instructions. Make a note of the value in register R03
below:
R03 = ?
Now insert a NOP instruction (use the Miscellaneous tab) after the third instruction, i.e.
Reset the program and run the above set of instructions & note down the value
R03= ?
Explanation?
Now there are three records of R03. Briefly explain the result in each case.
Now delete the NOP instruction from above program and uncheck the option Do not insert
bubbles. Reset the program and run the instructions. Observe the value in register R03 when the
program completes. Make a note of this value below
R03= ? 9
Briefly explain : Why one gets the same result without including the “NOP” instruction?
Is the “bubble” still there? What colour is it?
BITS
So, now there should be two versions of the code: Ex4_1 without “loop unrolling” optimization
and Ex4_2 with “loop unrolling” optimization. It can be seen in the program window of CPU
simulator as shown below.
BITS
Make a note of the size of the code generated for Ex4_2 here:
Click on show pipeline and check the keep on top box. Ascertain that Enable operand
forwarding and Enable jump prediction boxes are all unchecked.
First, select program Ex4_1 from the PROGRAM LIST frame in the CPU simulator window as
shown in figure below and then click the RESET button
BITS
Now run the program EX4_1 at full speed and observe the pipeline. Prepare the following table.
Do the same with program Ex4_2 and make note of the following values:
Briefly comment on the observations making references to the code sizes and the number of
instructions executed:
BITS
Copy the CPU instruction sequence generated below (do not include the instruction addresses):
Next, select the optimization option Code Dependencies. Change the program name to Ex5_2,
compile it and load in memory.
Copy the CPU instruction sequence generated below:
How do the two sequences differ? Does the change affect the logic of the program? Briefly
explain the rationale for the change. Explain the difference in pipeline achieved in two
methodologies.
Do you see any improvement in program Ex5_4 over program Ex5_3 (express this in
percentage)?
BITS
Now, in the pipeline window select the Enable jump prediction check box. Reset the
program and run it again. Make a note of the following pipeline statistics
Click on the SHOW JUMP TABLE… button. Observe the Jump Predict Table
window showing. This table keeps an entry relevant to each conditional jump instruction. The
information contained has the following fields. What each field stands for? Enter the suggestions
in the table below:
V
JInstAddr
JTarget
PStat
Count