Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Question about RVTEST_PASS and RVTEST_FAIL #471

Open
ZhaoHaowenn opened this issue May 11, 2023 · 1 comment
Open

Question about RVTEST_PASS and RVTEST_FAIL #471

ZhaoHaowenn opened this issue May 11, 2023 · 1 comment

Comments

@ZhaoHaowenn
Copy link

I'm trying to understand how Rocket-chip uses riscv-tests to test instruction sets and then uses it to my own processor.
how rocket-chip know the test result through these two macro. I'm confused about the execution details of these two macros. how to adapt this repo to my own processor? how can my own testbench know the test result?

Does anyone can help? Is there any tutorial? thanks.

related code below:

#define RVTEST_PASS
fence;
li TESTNUM, 1;
li a7, 93;
li a0, 0;
ecall

#define TESTNUM gp
#define RVTEST_FAIL
fence;
1: beqz TESTNUM, 1b;
sll TESTNUM, TESTNUM, 1;
or TESTNUM, TESTNUM, 1;
li a7, 93;
addi a0, TESTNUM, 0;
ecall

@ZhaoHaowenn ZhaoHaowenn changed the title Question about RVTEST_PASS and RVTEST——FAIL Question about RVTEST_PASS and RVTEST_FAIL May 11, 2023
@kathlenehurt-sifive
Copy link
Contributor

The macros use the ecall instruction to execute an "exit" system call. The RISC-V calling convention defines registers a0-a7 (0x10-x17) as function arguments, so these registers may be read when executing a system call. Register a7 holds the system call code. For the exit system call, the return code is read from a0. A return code of 0 means that the test passed; any value other than zero means that the test failed. In this macro, the test number is returned if the test fails so you can tell which subtest caused the test to fail.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants