Line 335... |
Line 335... |
tmp_a = neorv32_cpu_csr_read(CSR_MCOUNTEREN);
|
tmp_a = neorv32_cpu_csr_read(CSR_MCOUNTEREN);
|
tmp_a |= (1<<CSR_MCOUNTEREN_CY); // re-allow access right
|
tmp_a |= (1<<CSR_MCOUNTEREN_CY); // re-allow access right
|
neorv32_cpu_csr_write(CSR_MCOUNTEREN, tmp_a);
|
neorv32_cpu_csr_write(CSR_MCOUNTEREN, tmp_a);
|
|
|
|
|
|
/*
|
|
// ----------------------------------------------------------
|
|
// Execute DRET in M-mode (has to trap!)
|
|
// ----------------------------------------------------------
|
|
neorv32_cpu_csr_write(CSR_MCAUSE, 0);
|
|
PRINT_STANDARD("[%i] DRET in M-mode: ", cnt_test);
|
|
|
|
// skip if U-mode is not implemented
|
|
if (neorv32_cpu_csr_read(CSR_MISA) & (1<<CSR_MISA_U)) {
|
|
|
|
cnt_test++;
|
|
|
|
asm volatile("dret");
|
|
|
|
if (neorv32_cpu_csr_read(CSR_MCAUSE) == TRAP_CODE_I_ILLEGAL) {
|
|
test_ok();
|
|
}
|
|
else {
|
|
test_fail();
|
|
}
|
|
|
|
}
|
|
else {
|
|
PRINT_STANDARD("skipped (n.a. without U-ext)\n");
|
|
}
|
|
*/
|
|
|
|
|
|
/*
|
|
// ----------------------------------------------------------
|
|
// Execute MRET in U-mode (has to trap!)
|
|
// ----------------------------------------------------------
|
|
neorv32_cpu_csr_write(CSR_MCAUSE, 0);
|
|
PRINT_STANDARD("[%i] MRET in U-mode: ", cnt_test);
|
|
|
|
// skip if U-mode is not implemented
|
|
if (neorv32_cpu_csr_read(CSR_MZEXT) & (1<<CSR_MZEXT_DEBUGMODE)) {
|
|
|
|
cnt_test++;
|
|
|
|
// switch to user mode (hart will be back in MACHINE mode when trap handler returns)
|
|
neorv32_cpu_goto_user_mode();
|
|
{
|
|
asm volatile("mret");
|
|
}
|
|
|
|
if (neorv32_cpu_csr_read(CSR_MCAUSE) == TRAP_CODE_I_ILLEGAL) {
|
|
test_ok();
|
|
}
|
|
else {
|
|
test_fail();
|
|
}
|
|
|
|
}
|
|
else {
|
|
PRINT_STANDARD("skipped (n.a. without U-ext)\n");
|
|
}
|
|
*/
|
|
|
|
|
// ----------------------------------------------------------
|
// ----------------------------------------------------------
|
// Test performance counter: setup as many events and counter as feasible
|
// Test performance counter: setup as many events and counter as feasible
|
// ----------------------------------------------------------
|
// ----------------------------------------------------------
|
neorv32_cpu_csr_write(CSR_MCAUSE, 0);
|
neorv32_cpu_csr_write(CSR_MCAUSE, 0);
|
PRINT_STANDARD("[%i] Configuring HPM events: ", cnt_test);
|
PRINT_STANDARD("[%i] Configuring HPM events: ", cnt_test);
|
Line 1289... |
Line 1349... |
cnt_test++;
|
cnt_test++;
|
|
|
// program wake-up timer
|
// program wake-up timer
|
neorv32_mtime_set_timecmp(neorv32_mtime_get_time() + 1000);
|
neorv32_mtime_set_timecmp(neorv32_mtime_get_time() + 1000);
|
|
|
// put CPU into sleep mode
|
// clear timeout wait flag
|
asm volatile ("wfi");
|
tmp_a = neorv32_cpu_csr_read(CSR_MSTATUS);
|
|
tmp_a &= ~(1 << CSR_MSTATUS_TW);
|
|
neorv32_cpu_csr_write(CSR_MSTATUS, tmp_a);
|
|
|
|
// switch to user mode (hart will be back in MACHINE mode when trap handler returns)
|
|
neorv32_cpu_goto_user_mode();
|
|
{
|
|
// only when mstatus.TW = 0 executing WFI in user mode is allowed
|
|
asm volatile ("wfi"); // put CPU into sleep mode
|
|
}
|
|
|
if (neorv32_cpu_csr_read(CSR_MCAUSE) != TRAP_CODE_MTI) {
|
if (neorv32_cpu_csr_read(CSR_MCAUSE) != TRAP_CODE_MTI) {
|
test_fail();
|
test_fail();
|
}
|
}
|
else {
|
else {
|