For this lab you will be looking at the RISC-V instruction set. Please Set up gem5 simulator
; Fibonacci sequence
(defcode fib (n)
fib
($addi ‘sp ‘sp -24)
($sd ‘ra 0 ‘(sp))
($li ‘t0 2)
($ble ‘a0 ‘t0 ret1)
($sd ‘a0 8 ‘(sp))
($addi ‘a0 ‘a0 -1)
($jal fib)
($sd ‘a0 16 ‘(sp))
($ld ‘a0 8 ‘(sp))
($addi ‘a0 ‘a0 -2)
($jal fib)
($ld ‘t0 16 ‘(sp))
($addw ‘a0 ‘a0 ‘t0)
($j ret)
ret1
($li ‘a0 1)
ret
($ld ‘ra 0 ‘(sp))
($addi ‘sp ‘sp 24)
($ret))
Regarding Problem 3
- Write down a paragraph describing your steps to solve this problem.
- Then answer the following questions using gem5 simulator:
- Make your program calculates the first 15 integers of the Fibonacci Sequence. If you disable forwarding how many cycles does it take to finish the program? If you enable forwarding how many cycles does it take to finish the program? Provide screenshots of both Execution Tables generated by the simulator when you run your program with forwarding enabled and disabled. Make sure to label every table properly.
- Make your program calculate the first 15 integers of the Fibonacci Sequence. How many elements are in your array? What is the range of addresses used for the array (i.e. 1024 to …)? Provide a screenshot of the data memory generated by the simulator after you run your program.


0 comments