adding CSR support to rtlsim driver

This commit is contained in:
Blaise Tine
2020-09-04 06:51:31 -04:00
parent dccea80b68
commit 112d8ab815
10 changed files with 167 additions and 42 deletions

View File

@@ -91,22 +91,22 @@ extern int vx_upload_kernel_file(vx_device_h device, const char* filename) {
return err;
}
extern int vx_get_perf(vx_device_h device, size_t* cycles, size_t* instrs) {
extern int vx_get_perf(vx_device_h device, int core_id, size_t* cycles, size_t* instrs) {
int ret = 0;
unsigned value;
if (cycles) {
ret |= vx_csr_get(device, 0, CSR_CYCLE_H, &value);
ret |= vx_csr_get(device, core_id, CSR_CYCLE_H, &value);
*cycles = value;
ret |= vx_csr_get(device, 0, CSR_CYCLE, &value);
ret |= vx_csr_get(device, core_id, CSR_CYCLE, &value);
*cycles = (*cycles << 32) | value;
}
if (instrs) {
ret |= vx_csr_get(device, 0, CSR_INSTRET_H, &value);
ret |= vx_csr_get(device, core_id, CSR_INSTRET_H, &value);
*instrs = value;
ret |= vx_csr_get(device, 0, CSR_INSTRET, &value);
ret |= vx_csr_get(device, core_id, CSR_INSTRET, &value);
*instrs = (*instrs << 32) | value;
}