Skip to content
Snippets Groups Projects
Commit c5043359 authored by Yuan, Weize's avatar Yuan, Weize
Browse files

Update fibo-hazards-template.S

parent 4280638a
Branches master
No related tags found
No related merge requests found
Pipeline #64323 failed
// fibo-hazards.S file template, rename and implement the algorithm
// Test algorithm in qtrvsim_gui program
// Select the CPU core configuration to
// Pipelined without hazard unit and cache
// This option select version where RAW dependencies which leads
// to hazards are not resolved in hardware, you need to schedule
// instruction execution according to the pipeline structure
// (classical 5-stage RISC-V) such way, that no dependency results
// in a hazard
// copy directory with the project to your repository to
// the directory work/fibo-hazards
// critical is location of the file work/fibo-hazards/fibo-hazards.S
// which is checked by the scripts
// The script loads number of the last Fibonacci series element to compute
// into fibo_limit variable and expects computed series in memory starting
// at address fibo_series, the series has to be followed by at least
// one zero element
// Directives to make interesting windows visible
#pragma qtrvsim show registers
#pragma qtrvsim show memory
......@@ -31,27 +11,58 @@
.globl _start
_start:
la a1, fibo_limit
la a1, fibo_limit
la a0, fibo_series
la a0, fibo_series
addi a1, a1, 8
nop
addi a0, a0, 8
lw a1, 0(a1)
li t0, 0
nop
nop
sw t0, 0(a0)//21c
li t0, 1
nop
nop
sw t0, 4(a0) //228
li t1, 2
addi a2, a0, 8
la a0, fibo_series
la a1, fibo_limit
lw a1, 0(a1) // number of elements in the array
fibo:
beq t1, a1, end_loop
nop
lw t2, -4(a2)
lw t3, -8(a2)
nop
nop
add t4, t2, t3
nop
nop
sw t4, 0(a2)
addi a2, a2, 4
addi t1, t1, 1
j fibo
nop
//Insert your code there
//Final infinite loop
end_loop:
fence // flush cache memory
ebreak // stop the simulator
j end_loop
nop
.data
// .align 2 // not supported by QtRVSim yet
fibo_limit:
.word 15
.word 12
fibo_series:
.skip 1000*4
// Specify location to show in memory window
#pragma qtrvsim focus memory fibo_limit
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment