4. A computer has a 5-stage instruction pipeline of one cycle each. The 5 stages are: Instruction Fetch (IF), Instruction Decode (ID), Operand Fetch (OF), Instruction Execution (IE), and Operand Store...


e


4. A computer has a 5-stage instruction pipeline of one cycle each. The 5 stages are:<br>Instruction Fetch (IF), Instruction Decode (ID), Operand Fetch (OF), Instruction<br>Execution (IE), and Operand Store (OS). Consider the following code sequence, which<br>is to be run on this computer.<br>Label<br>Action<br>Code sequence<br>STORE R16, Mem(12) Mem Address #12 € R16;<br>LOAD R16, Mem(8)<br>R16 E Mem(8);<br>R7 E R16 – R4;<br>SUB R7, R16, R4;<br>BGT R7, NewAddr;<br>SUB R5, R1, R4<br>AND R15, R5, R4<br>Branch to NewAddr if result is Greater than zero<br>R5 E R4 - R1;<br>R15 E R5 & R4;<br>Do nothing<br>NewAddr NOP<br>(a) Suppose we modify the pipeline so that it has only one memory (that handles both<br>instructions and data). In this case, there will be a structural (resource) hazard<br>every time a program needs to fetch an instruction during the same cycle in which<br>another instruction accesses data i.e. only ONE of instruction fetch, operand fetch<br>and operand store can be operating in one cycle. Draw a pipeline diagram to show<br>where the code above will stall.<br>(b) In general, is it possible to reduce the number of stalls/NOPS resulting from this<br>structural hazard by reordering the code?<br>(c) Must this structural hazard be handled in hardware? We have seen that data<br>hazards can be eliminated by adding NOPS to the code. Can you do the same with<br>this structural hazard? If so, explain how. If not, explain why not.<br>(d) Draw a pipeline diagram to show what happens if the BGT instruction is true.<br>Assume that the next instruction to be executed when BGT instruction is true starts<br>with instruction fetch after the instruction execution cycle of BGT instruction.<br>(e) Show where is the occurrence of a data hazard in the above code. Draw a pipeline<br>diagram to show how the hazard can be eliminated.<br>

Extracted text: 4. A computer has a 5-stage instruction pipeline of one cycle each. The 5 stages are: Instruction Fetch (IF), Instruction Decode (ID), Operand Fetch (OF), Instruction Execution (IE), and Operand Store (OS). Consider the following code sequence, which is to be run on this computer. Label Action Code sequence STORE R16, Mem(12) Mem Address #12 € R16; LOAD R16, Mem(8) R16 E Mem(8); R7 E R16 – R4; SUB R7, R16, R4; BGT R7, NewAddr; SUB R5, R1, R4 AND R15, R5, R4 Branch to NewAddr if result is Greater than zero R5 E R4 - R1; R15 E R5 & R4; Do nothing NewAddr NOP (a) Suppose we modify the pipeline so that it has only one memory (that handles both instructions and data). In this case, there will be a structural (resource) hazard every time a program needs to fetch an instruction during the same cycle in which another instruction accesses data i.e. only ONE of instruction fetch, operand fetch and operand store can be operating in one cycle. Draw a pipeline diagram to show where the code above will stall. (b) In general, is it possible to reduce the number of stalls/NOPS resulting from this structural hazard by reordering the code? (c) Must this structural hazard be handled in hardware? We have seen that data hazards can be eliminated by adding NOPS to the code. Can you do the same with this structural hazard? If so, explain how. If not, explain why not. (d) Draw a pipeline diagram to show what happens if the BGT instruction is true. Assume that the next instruction to be executed when BGT instruction is true starts with instruction fetch after the instruction execution cycle of BGT instruction. (e) Show where is the occurrence of a data hazard in the above code. Draw a pipeline diagram to show how the hazard can be eliminated.
Jun 05, 2022
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here