Question: (RISC-V ISA Manual) https://content.riscv. org/wp-content/uploads/2017/05/riscv-spec-v2.2.pdf This problem deals with the following code fragment, as it executes. Note that the register naming convention is taken from

 (RISC-V ISA Manual) https://content.riscv. org/wp-content/uploads/2017/05/riscv-spec-v2.2.pdf This problem deals with the following

(RISC-V ISA Manual) https://content.riscv. org/wp-content/uploads/2017/05/riscv-spec-v2.2.pdf

This problem deals with the following code fragment, as it executes. Note that the register naming convention is taken from the RISC-V ISA manual, page 109 addi s2, zero, 3 addi s3, zero, 0 LOOP: slli t1, s2, 3 add t2, a2, t1 ld t3, 0(t2) andi t4, t3, 1 beq zero, t4, LABEL xori t3, t3, 0x55 // a2 contains the base address of array X LABEL: add s3, s3, t3 ld t4, 400 (t2) add s3, s3, t4 add s2, s2, 1 blt zero, s2, LOOP sd 800 (a2), s3 (a) What is the C code that this fragment implements? (b) Draw the pipeline diagram for the code as it executes, assuming no forwarding of any kind. You may want to turn your paper horizontally to do this so you have sufficient room. You may also find it casier to pre-print a table that you fill in, or do it on a computer, rather than draw the lines by hand. (c) How many pipeline stalls are there? What is the total execution time in cycles, and what is the CPI? (d) Can you reorder the instructions to reduce the number of stalls? Again, there's no forwarding. You may use different registers if it helps This problem deals with the following code fragment, as it executes. Note that the register naming convention is taken from the RISC-V ISA manual, page 109 addi s2, zero, 3 addi s3, zero, 0 LOOP: slli t1, s2, 3 add t2, a2, t1 ld t3, 0(t2) andi t4, t3, 1 beq zero, t4, LABEL xori t3, t3, 0x55 // a2 contains the base address of array X LABEL: add s3, s3, t3 ld t4, 400 (t2) add s3, s3, t4 add s2, s2, 1 blt zero, s2, LOOP sd 800 (a2), s3 (a) What is the C code that this fragment implements? (b) Draw the pipeline diagram for the code as it executes, assuming no forwarding of any kind. You may want to turn your paper horizontally to do this so you have sufficient room. You may also find it casier to pre-print a table that you fill in, or do it on a computer, rather than draw the lines by hand. (c) How many pipeline stalls are there? What is the total execution time in cycles, and what is the CPI? (d) Can you reorder the instructions to reduce the number of stalls? Again, there's no forwarding. You may use different registers if it helps

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!