

Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!


Score:______ Section:____________ Date:__________ Name:______________________________
Due Date Part I: Tuesday (sections A,B) and Thursday (section C), October 8 or 10 Due Date Part II: Tuesday (sections A,B) and Thursday (section C), October 22 or 24 Part I: Forwarding Once the MIPS is pipelined as in Lab 2, data hazards can occur between the five instructions present in the pipeline. As an example, consider the following program: Sub $2,$1,$ Add $4,$2,$ The subtract instruction stores a result in register 2 and the following add instruction uses register 2 as a source operand. The new value of register 2 is written into the register file by SUB $2,$1,$3 in the write-back stage after the old value of register 2 was read out by ADD $4,$2,$5 in the decode stage. In the text, this problem is fixed by adding two forwarding muxes to each ALU input in the execute stage. In addition to the existing values feeding in the two ALU inputs, the forwarding multiplexers can also select the last ALU result or the last value in the data memory stage. These muxes are controlled by comparing the rd, rt, and rs register address fields of instructions in the decode, execute, or data memory stages. Instruction rd fields will need to be added to the pipelines in the execute, data memory, and write-back stages for the forwarding compare operations. Since register 0 is always zero, do not forward register 0 values. The forwarding muxes in the EX stage handle dependences on instructions in the EX and MEM stages. For Part II of the lab you will need to have the ALU’s data forwarding muxes moved back into the decode stage, so you are required to move the forwarding muxes to the decode stage for Part I of the lab. Note that the mux signals to forward are now needed one clock cycle earlier, so you will need to rework the forwarding equations to reflect this change before coding them in VHDL (read and carefully work problem 6.18!). It would be a good idea to work through several examples by hand to double check your new forwarding equations. If necessary, draw a picture like Fig 6.37 to obtain the new forwarding equations. You can assume that there is enough time in a single clock cycle to take the current ALU output (before a pipeline register) and forward it to the decode stage for a branch decision. Dependence from an instruction in the WB stage to one in the ID stage must also be considered. You can handle this dependence in one of 2 ways. The first method is to ensure that the assumption used in Patterson and Hennessy holds, i.e. that the register file write in one cycle occurs before the register file read in the same cycle. The current VHDL model does not function this way. This can be accomplished by writing to the register file on the falling edge (instead of the rising edge as done currently) of each clock cycle. A register file read from the same register will then have its value clocked into the ID/EX pipeline register at the next rising edge, ensuring that the just-written value is passed to the EX stage. The second method to handle this type of dependence is to add two forwarding multiplexers to the Idecode module so that the register file is bypassed in this situation. If the register file write address equals one of the two read addresses, the register file write data value should be forwarded to the ID/EX pipeline register instead of the normal register file data value. Since you already have the data forwarding muxes in the decode stage, you may find this option easier. Sections 6.4 and 6.5 of Computer Organization and Design The Hardware/Software Interface contain additional background information on forwarding.
Beq $0,$4,label Add $3,$1,$ Add $5,$5,$ label1: Beq $3,$5,label Sub $5,$5,$ label2: Beq $5,$6,label label3: Beq $0,$0,label Grading Criteria: Correct simulation for Part I – 4 pts. Correct simulation for Part II – 4 pts. Demonstration and explanation of simulations to TA – 2 pts.