rv32emu
rv32emu copied to clipboard
Implement performance counter
On-going tasks:
- [x] 1. Add new register in structure
riscv_t - [x] 2. Create an API for getting performance counter
- [ ] 3. Implementing the incrementation of CSR_CYCLEH, CSR_TIME and CSR_INSTRT in
rv_step()
Don't frequently close/reopen a pull request. Instead, you can force push the commits if you found something wrong.
- [ ] 3. Implementing the incrementation of CSR_CYCLEH, CSR_TIME and CSR_INSTRT in
rv_step()
You shall provide some test programs which utilize performance counter. Either C with inline assembly or assembly programs are pretty well.
You shall provide a minimal RISC-V assembly program which examines CSR functionalities.
You shall provide a minimal RISC-V assembly program which examines CSR functionalities.
Will do. Thanks.
Hi @jserv,
Do you think it is okay for me to write a test program "test_csr.c" with Makefile to test performance? Or do you think I shall try to use unit testing instead?
Do you think it is okay for me to write a test program "test_csr.c" with Makefile to test performance? Or do you think I shall try to use unit testing instead?
You can create a test program named tests/csr-tests.c or tests/csr-tests.S. Furthermore, add it into the list of CHECK_ELF_FILES, so that make check can verify CSR implementations.
What should I do to use syscall_gettimeofday() in emulate.c without using #include "syscall.c"?
What should I do to use
syscall_gettimeofday()in emulate.c without using#include "syscall.c"?
You can decouple the common part into a dedicated utility source file. Let's say, utils.[ch], and then you can invoke the utility function(s) in syscall and CSR specific handling.
I cannot #include "utils.h" in both emulate.c and syscall.c
it will show the following error message
Undefined symbols for architecture arm64:
"_rv_gettimeofday", referenced from:
_csr_get_ptr in emulate.o
_syscall_handler in syscall.o
ld: symbol(s) not found for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [build/rv32emu] Error 1
I cannot
#include "utils.h"in both emulate.c and syscall.c it will show the following error message
You have to tweak Makefile accordingly.
Apply the following change:
diff --git a/Makefile b/Makefile
index 37c8c38..cce99d0 100644
--- a/Makefile
+++ b/Makefile
@@ -95,6 +95,7 @@ all: $(BIN)
OBJS := \
map.o \
+ utils.o \
emulate.o \
io.o \
elf.o \
diff --git a/src/emulate.c b/src/emulate.c
index 7193c69..936d375 100644
--- a/src/emulate.c
+++ b/src/emulate.c
@@ -30,7 +30,7 @@ extern struct target_ops gdbstub_ops;
#include "riscv.h"
#include "riscv_private.h"
-#include "utils.c"
+#include "utils.h"
/* RISC-V exception code list */
#define RV_EXCEPTION_LIST \
Hi @jserv,
How should I test program counters?
I should try to implement something in assembly to check the usage of csr_csrrs(*rv, CSR_TIME, 0 right?
How should I test program counters? I should try to implement something in assembly to check the usage of
csr_csrrs(*rv, CSR_TIME, 0right?
You can simply write RISC-V assembly programs to validate CSR.
Notes:
- Assembly not fully working.
- Successfully create main and loop.
- Working on csr instructions and print
Notes:
- Assembly not fully working.
- Successfully create main and loop.
- Working on csr instructions and print
You don't have to print out the values of CSR. Instead, you can compare the difference between previous cycles and the present while running the loop. That is, you check if the changes of cycle counts is expected.
Notes:
- Assembly not fully working.
- Successfully create main and loop.
- Working on csr instructions and print
You don't have to print out the values of CSR. Instead, you can compare the difference between previous cycles and the present while running the loop. That is, check if the changes of cycle counts is expected since you know the instruction latency in advance. (CPI = 1 in
rv32emufor no pipeline)
Start working on assembly itself.
Close in favor of commit 53a6f9463c4b344746cb1154cbfb995e44f30300