lowRISC / ibex

Ibex is a small 32 bit RISC-V CPU core, previously known as zero-riscy.
https://www.lowrisc.org
Apache License 2.0
1.34k stars 524 forks source link

Regression testing failed #485

Closed taddevrp closed 4 years ago

taddevrp commented 4 years ago

I've tried to run regression test but it has failed a few times. I debugged one of the fails and found differnce between iss_sim and rtl_sim program flows. So, at asm program there is a jump to subroutine. Trace log of this jump looks the same for both iss and rtl simulations but return code differs.

Subrotine call code at main program looks like this (line 54):

                  ...
                  j init_user_mode

And subroutine code is (line 17 287):

init_user_mode:   
                  ...
                  mret

According to trace of ISS simulator it uses "mret (0x30200073)" (line 145) command as the return instruction, but RTL uses "jal (0800006f)" (line 69) in the same case. So, they used different return codes which causes jumping to different addresses. As I've seen ISS uses .o file as the source and rtl simulator .bin which can be a root of the problem, but both of them are generated by gen rule of makefile from the same source.

riscv_illegal_instr_test_0_ASM.TXT riscv_illegal_instr_test.0.log trace_core_00000000.log

udinator commented 4 years ago

Hi @TAD-dev - Thanks for reporting this! It would appear that in the init_user_mode section, there is an access to sstatus, which Ibex does not support. Looks like this is an issue with the instruction generator, rather than the core. I'll prepare a fix in the generator and update the vendor directory accordingly.

udinator commented 4 years ago

@TAD-dev - #486 and #487, once merged, should fix this issue; it was mostly fixes on the flow side. Thanks again for raising this issue!

udinator commented 4 years ago

Can you sync to the master branch and try running this test again? Everything should be fixed now.

taddevrp commented 4 years ago

After update I've got an error related to randomization on gen step. Please find error message attached below:

if (MSCRATCH inside {implemented_csr}) {
                                             |
ncsim: *E,RNDCNSTE (ibex/vendor/google_riscv-dv/src/riscv_rand_instr.sv,108|45): Randomization constraint has this error, which will cause the randomize function to return 0 and no new rand values will be set:                                            
Unsupported parameter type in constraint.
        `DV_CHECK_RANDOMIZE_WITH_FATAL(branch_instr, category == BRANCH;)
                                                                        |
ncsim: *W,SVRNDF (ibex/vendor/google_riscv-dv/src/riscv_directed_instr_lib.sv,323|72): The randomize method call failed. The unique id of the failed randomize call is 808.                                                                                  
Observed simulation time : 0 FS + 44
UVM_FATAL ibex/vendor/google_riscv-dv/src/riscv_directed_instr_lib.sv(323) @ 0: reporter [instr_stack_enter] Check failed (branch_instr.randomize()) Randomization failed! 
udinator commented 4 years ago

Could you please re-sync to master and re-run the test?

taddevrp commented 4 years ago

I still have the same error.

udinator commented 4 years ago

Are you using IUS or Xcelium to run the simulations?

taddevrp commented 4 years ago

This error happens on gen step where IUS is used for compilation and simulation.