Interrupting the PC-setting step of a cm.popret (only) can sample the return target as the exception return PC, which will cause the stack pointer adjust to be skipped when returning from the IRQ. Fix this by making the PC-setting step uninterruptible (note the PC-setting step is the instruction we execute first out of the group of instructions specified in the Zc spec as being atomic wrt interrupts. This does not itself imply that the PC-setting step is uninterruptible, it just requires that when the PC-setting step retires, all following steps also retire. However this is not sufficient given the special case logic that allows the jr ra PC-setting step to execute before the final stack adjust as an optimisation.) |
||
---|---|---|
.. | ||
include | ||
.gitignore | ||
Makefile | ||
Readme.md | ||
amo_fault.c | ||
amo_misalign.c | ||
amo_ops.c | ||
amo_smoke.c | ||
amo_smoke.gtkw | ||
amo_timer_irq.c | ||
amo_timer_irq.gtkw | ||
cleantests | ||
csr_id.c | ||
csr_mcycle.c | ||
csr_minstret.c | ||
csr_readable.c | ||
csr_readable_umode.c | ||
csr_writable.c | ||
ebreak.c | ||
ecall_simple.c | ||
ecall_simple.gtkw | ||
extension_xh3b.c | ||
hellow.c | ||
illegal_instr.c | ||
instr_access_fault.c | ||
irq_force.c | ||
irq_individual_enable.c | ||
irq_individual_pend.c | ||
irq_preempt_set_in_irq.c | ||
irq_set_all.c | ||
irq_set_all_with_pri.c | ||
irq_top_bottom.c | ||
load_misalign_halfword.c | ||
load_misalign_word.c | ||
load_store_fault.c | ||
lr_sc_bypass.c | ||
lr_sc_fault.c | ||
lr_sc_smoke.c | ||
lr_sc_smoke.gtkw | ||
mret_mpp_mprv.c | ||
pmp_mprv.c | ||
pmp_u_rw.c | ||
pmp_u_x.c | ||
pmp_write_and_lock.c | ||
runtests | ||
soft_irq.c | ||
store_misalign_halfword.c | ||
store_misalign_word.c | ||
umode_mret.c | ||
umode_wfi.c | ||
unblock_self_latching.c | ||
wfi_loop.c | ||
wfi_loop_deepsleep_powerdown.c | ||
zcmp_irq_kill.c | ||
zcmp_irq_kill_popret.c | ||
zcmp_irq_kill_popretz.c | ||
zcmp_mva01s.c | ||
zcmp_mvsa01.c | ||
zcmp_pop.c | ||
zcmp_push.c |
Readme.md
Software Testcases
A smorgasbord of software testcases for various features and cases that aren't well-covered by upstream tests such as riscv-arch-test
, the riscv-test
end-to-end debug tests or riscv-formal
. Each test consists of one C file.
Some tests have an expected text output associated with them -- the test passes if this text output matches, and main()
exits with a zero return code. Other tests are completely self-checking, reporting pass/fail only with the return code from main()
. This means there is no point running these tests if the processor is in a fundamentally broken state (e.g. doesn't pass ISA compliance) and can't be trusted to check itself.
For example, hellow.c
:
#include "tb_cxxrtl_io.h"
/*EXPECTED-OUTPUT***************************************************************
Hello world from Hazard3 + CXXRTL!
*******************************************************************************/
int main() {
tb_puts("Hello world from Hazard3 + CXXRTL!\n");
return 0;
}
The contents of the EXPECTED-OUTPUT
comment is simply compared with the logged text from tb_puts
, tb_printf
etc. Tests might log a range of output here, such as mcause
values in exceptions. The contents of this comment may have inline //
comments embedded within, and these are stripped by the test script before comparing with the output. This is useful if some of the test output requires some brief inline explanation in the test source.
To run the tests:
./runtests
This will first rebuild the simulator (../tb_cxxrtl/
) if needed, then build and run all the software testcases, then print out a summary of test pass/fail status. The ./run_tests
executable itself returns a successful exit code if and only if all tests passed. A printf log will be created for each test, with the same name as the test, at tmp/test_name.log
.
VCD waveform dumping is not enabled by default, because tests run faster without waves, and dumping waves for all tests uses gigabytes of disk space. To re-run a failing test testname
and get wave output, run:
./runtests testname --vcd
This creates a VCD file at tmp/testname_run.vcd
. If you really want, you can pass --vcd
without naming specific tests, to generate waves for all tests.
To clean up the junk:
./cleantests