There is HW loop #0 configured to run 10 times following 2 instructions: "jal ra, _some_function" and "add x20, x20, x21".
Instruction jal performs jump operation to address with mark "_some_function" and stores NPC value to register ra. In our case NPC should have pointer to the instruction "add x20, x20, x21". Pointer "_some_function" stores address of some block of code with dummy calculations that ends with instruction "jalr ra". This instruction performs jump operation with the address that stored in ra register.
So we can predict that HW loop should execute 10 times next sequence of instructions: jump to "_some_function", perform dummy instructions, jump back to the loop, do add instruction.
After jumping back to the HW loop, the last instruction "add x20, x20, x21" was skipped.
Source code of the test:
_start_jmp:
j _start #8000 0080
_start:
li x20, 1
li x21, 1
lp.starti x0, __hw_loop_start
lp.endi x0, __hw_loop_end
lp.counti x0, 10
__hw_loop_start: jal ra, _some_function
add x21, x21, x20
__hw_loop_end: add x20, x20, x21
_some_function:
nop
nop
nop
nop
nop
nop
jalr ra
To simplify debugging I will add few lines from dissemble file..
"_some function" block of code:
8000009a <_some_function>:
_some_function():
8000009a: 0001 nop
8000009c: 0001 nop
8000009e: 0001 nop
800000a0: 0001 nop
800000a2: 0001 nop
800000a4: 0001 nop
800000a6: 9082 jalr ra
HW loop initialization with body:
80000086: 0060007b lp.starti x0,80000092 <__hw_loop_start>
8000008a: 0060107b lp.endi x0,80000096 <__hw_loop_end>
8000008e: 00a0307b lp.counti x0,10
80000092 <__hw_loop_start>:
__hw_loop_start():
80000092: 008000ef jal ra,8000009a <_some_function>
80000096 <__hw_loop_end>:
__hw_loop_end():
80000096: 9a56 add s4,s4,s5
In the waveform we can see that after jumping back to the HW loop body, counter was decremented and next executed instruction has PC 0x80000092, but expected PC should be 0x80000096. HW loop counter should be decremented after execution of the add instruction.
Error message from the scoreboard:
UVM_ERROR /proj/dbm10l/denisg/ws_dbm10l_test/blk/ri5cy/verif/classes/pulpino_scoreboard_c.sv(323) @ 2963000: uvm_test_top.pp_env.pp_scoreboard [SPIKE_DBG] PC compare mismatch. in the spike 0xffffffff80000096, in the design: 0x80000092
To confirm that instruction was executed with mistakes, I added register x20 and x21 to the waveform.W we saw they are still constant 1 till the end of the simulation, so add instruction which can modify it was not executed.