Question: 1 . 2 Complete the timeline of the program assuming that you have an always - taken branch predictor. Assume that the branch prediction happens

1.2 Complete the timeline of the program assuming that you have an always-taken branch predictor. Assume that the branch prediction happens
within the ID stage, and the full branch outcome is available in the EX stage. For conciseness, use F/D/E/M/W for IF/ID/EX/MEM/WB stages in the
table. Also use "N" for NOP. In empty rows, add proper instructions from the assembly program and complete the table. Show mispredicted
instructions as well in the table; you need to invalidate those instructions at the right time. (60 pts)Consider the code snippet given below:
addi x14, x0,3
addi x15, x0,0
addi x12, x0,0
LOOP:
lw x10,0(x13)
lw x11,4(x13)
add x16, x10, x11
add x12, x16, x12
addi x13, x13,16
addi x15, x15,1
blt x15, x14, LOOP
* Abbreviations
- IF: Instruction fetch stage
- ID: Instruction decode / register file read stage
- EX: execution
- MEM: Data memory access
- WB: Write back to the register file
- NOP: No operation; a bubble
* Key assumptions
- The write-back data in the WB stage is available in the decode stage at the same cycle.
- The processor has forwarding links for data hazard resolution (EX -> ID and MEM -> ID)
- Forwarded data from the execution/memory stage is visible to the decode stage at the same cycle (i.e., if an instruction receives a forwarded data from EX/MEM stage, align the ID stage of the next instruction with the EX/MEM stage of the previous instruction)
- The processor has a branch predictor (each problem will specify which predictor we have) and a branch target buffer (BTB).
- We need to compute the full branch outcome at least once to have the target address in the branch target buffer.
- When "NOP" exists in a pipeline stage, the next instruction cannot complete the previous stage. For example, in the timeline given below, instruction B cannot start IF until the NOP in ID stage of instruction A is removed. Likewise, Instruction C needs to wait until the NOP in the ID stage caused by instruction B is removed (that's why IF for instruction C started at cycle 6, not 5).
1.1 Write a C code that performs the same job as the given assembly program.
The assembly program implements the highlighted part in the following C code
snippet. (20 pts)
(hint: the program includes a loop)
 1.2 Complete the timeline of the program assuming that you have

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!