Problems 2
Fall 1999
These problems are in addition to those given out for the midterm. The exam will cover material from the entire course.
Here are some additional pipelining questions.
Since instruction fetch is supposed to happen in one cycle, what does that imply about the memory system?
We said that memory accesses were of the form that did the load of a register from memory or a store of a register to memory. They would look like:
ld x(r1),r2 ; x is an offset added to contents of r1 ; r2 is loaded from memory st r1,x(r2) ; r1 is stored in memory
To compute the address, the ALU in the execution unit is to be used to add the offset to the register.
When is the address available?
Assume that it takes one cycle to access memory, what needs to be done for memory instructions if you want to maintain the 4-stage pipeline?
If you want to keep the pipeline busy as much as possible what modification needs to be done to the pipeline? You should make sure the write stage for all instructions happens at the same step. Why? Show your new pipeline and explain in detail how the memory instructions get executed.
What must be true about the memory system to allow memory accesses to happen in one cycle?
Does this new pipeline affect the number of branch delay slots?
This is a modification of the previous pipeline to allow memory accesses to fit into the pipeline. This is what you should have gotten in the previous question.
Assume that you have ld/st instructions as described above. Branches are of the compare-and-branch flavour:
bgt r1,r2,label
which means that if r1-r2 > 0, the program branches to label. In the machine code, the branches are relative, so the actual instruction encodes an offset represented in 2's complement notation.
Show how a branch progresses through the pipeline. In particular, show what is needed to update the PC with the correct value depending on whether the branch is taken or not. Show what values are used to compute the new PC values for a taken branch.
What datapath resources will you need to make this work? For example, you will need an ALU unit to do the execute unit functions. You'll need some pipeline registers. Don't forget that you'll need to update or modify the PC at times. Draw a diagram of your datapath.
When does a branch instruction complete in the pipeline of question 2?