Wed, 19 Oct 2011, 04:08
A student writes: > Dear Professor Patt, > > For problem set 4, question 1, does the MAR and the MDR change during the > fetch operand phase or does the MAR change during the Evaluate Address > phase? > > <<name withheld to protect the student who is rightfully confused>> Excellent question. Normally, one might look in the book for the answer, but Ooops! In this case, the book contradicts itself. Shame on the author! On page 106, the paragraph "Fetch Operands" says the MAR is loaded there. On page 144, under "Evaluate Address," it says the MAR is loaded there. Clearly, they can't both be right. So what is really going on? ...and why did I contradict myself between page 106 and page 144? The problem is that on page 144 I was trying to force each phase to end at the end of a cycle. That is, I wanted to point to a state on the state machine and be able to say the Evaluate Address phase is done in this state, and the Fetch Operand phase starts in the next state. I wanted a nice clean termination of phases to occur on state (or clock cycle) boundaries. I was forgetting that the phases are all about the functions being performed and not about state (or clock cycle) boundaries. On soberly looking at the instruction cycle, it is clear that Evaluate Address is about adding the offset to the register to obtain the memory address. It is equally clear that Fetch operand is about loading MAR with the address, accessing memory, and loading the operand into MDR. Thus the explanation of page 106 is correct, and the verbiage on page 144 is incorrect. What I had forgotten in my eagerness to end a phase at the end of a cycle was that in the LC-3, the Evaluate Address phase does not end at the end of the cycle. The cycle ends with MAR being loaded, which is the first step in the Fetch Operand phase. That is, one state consists of (a) the Evaluate Address phase of adding the offset to the register and (b) the first part of the Fetch Operand phase by loading that result into MAR. Given all of this, it is a little misleading to ask what is in MAR at the end of the Evaluate Address phase of the LC-3, since that "end" occurs in the middle of the clock cycle. The answer would be "whatever was in MAR at the start of that cycle" which is somewhat of a trick question. So we changed the wording of Problem 1 to get rid of the trickery. The case of the MDR is much clearer. For an LDR, LD, or LDI instruction, it gets loaded at the end of the Fetch Opearand phase. I apologize if I caused you anxiety over this. Yale Patt