Line 81... |
Line 81... |
/**********************************************************************//**
|
/**********************************************************************//**
|
* High-level CPU/processor test program.
|
* High-level CPU/processor test program.
|
*
|
*
|
* @note Applications has to be compiler with <USER_FLAGS+=-DRUN_CPUTEST>
|
* @note Applications has to be compiler with <USER_FLAGS+=-DRUN_CPUTEST>
|
*
|
*
|
* @return Irrelevant.
|
* @return 0 if execution was successful
|
**************************************************************************/
|
**************************************************************************/
|
int main() {
|
int main() {
|
|
|
register uint32_t tmp_a, tmp_b;
|
register uint32_t tmp_a, tmp_b;
|
volatile uint32_t dummy_dst __attribute__((unused));
|
volatile uint32_t dummy_dst __attribute__((unused));
|
Line 101... |
Line 101... |
#warning processor_check HAS NOT BEEN COMPILED! Use >>make USER_FLAGS+=-DRUN_CHECK clean_all exe<< to compile it.
|
#warning processor_check HAS NOT BEEN COMPILED! Use >>make USER_FLAGS+=-DRUN_CHECK clean_all exe<< to compile it.
|
|
|
// inform the user if you are actually executing this
|
// inform the user if you are actually executing this
|
neorv32_uart_printf("ERROR! processor_check has not been compiled. Use >>make USER_FLAGS+=-DRUN_CHECK clean_all exe<< to compile it.\n");
|
neorv32_uart_printf("ERROR! processor_check has not been compiled. Use >>make USER_FLAGS+=-DRUN_CHECK clean_all exe<< to compile it.\n");
|
|
|
return 0;
|
return 1;
|
#endif
|
#endif
|
|
|
// check if this is a simulation (using primary UART0)
|
// check if this is a simulation (using primary UART0)
|
if (UART0_CT & (1 << UART_CT_SIM_MODE)) {
|
if (UART0_CT & (1 << UART_CT_SIM_MODE)) {
|
is_simulation = 1;
|
is_simulation = 1;
|
Line 164... |
Line 164... |
install_err += neorv32_rte_exception_install(id, global_trap_handler);
|
install_err += neorv32_rte_exception_install(id, global_trap_handler);
|
}
|
}
|
|
|
if (install_err) {
|
if (install_err) {
|
neorv32_uart_printf("RTE install error (%i)!\n", install_err);
|
neorv32_uart_printf("RTE install error (%i)!\n", install_err);
|
return 0;
|
return 1;
|
}
|
}
|
|
|
// enable interrupt sources
|
// enable interrupt sources
|
neorv32_cpu_irq_enable(CSR_MIE_MSIE); // machine software interrupt
|
neorv32_cpu_irq_enable(CSR_MIE_MSIE); // machine software interrupt
|
neorv32_cpu_irq_enable(CSR_MIE_MTIE); // machine timer interrupt
|
neorv32_cpu_irq_enable(CSR_MIE_MTIE); // machine timer interrupt
|
Line 787... |
Line 787... |
|
|
// ----------------------------------------------------------
|
// ----------------------------------------------------------
|
// Machine timer interrupt (MTIME)
|
// Machine timer interrupt (MTIME)
|
// ----------------------------------------------------------
|
// ----------------------------------------------------------
|
neorv32_cpu_csr_write(CSR_MCAUSE, 0);
|
neorv32_cpu_csr_write(CSR_MCAUSE, 0);
|
neorv32_uart_printf("[%i] MTI (machine timer) IRQ: ", cnt_test);
|
neorv32_uart_printf("[%i] MTI (via MTIME): ", cnt_test);
|
|
|
if (neorv32_mtime_available()) {
|
if (neorv32_mtime_available()) {
|
cnt_test++;
|
cnt_test++;
|
|
|
// configure MTIME IRQ (and check overflow form low owrd to high word)
|
// configure MTIME IRQ (and check overflow form low owrd to high word)
|
Line 826... |
Line 826... |
|
|
// ----------------------------------------------------------
|
// ----------------------------------------------------------
|
// Machine software interrupt (MSI) via testbench
|
// Machine software interrupt (MSI) via testbench
|
// ----------------------------------------------------------
|
// ----------------------------------------------------------
|
neorv32_cpu_csr_write(CSR_MCAUSE, 0);
|
neorv32_cpu_csr_write(CSR_MCAUSE, 0);
|
neorv32_uart_printf("[%i] MSI (via testbench) IRQ: ", cnt_test);
|
neorv32_uart_printf("[%i] MSI (via testbench): ", cnt_test);
|
|
|
if (is_simulation) { // check if this is a simulation
|
if (is_simulation) { // check if this is a simulation
|
cnt_test++;
|
cnt_test++;
|
|
|
// trigger IRQ
|
// trigger IRQ
|
Line 854... |
Line 854... |
|
|
// ----------------------------------------------------------
|
// ----------------------------------------------------------
|
// Machine external interrupt (MEI) via testbench
|
// Machine external interrupt (MEI) via testbench
|
// ----------------------------------------------------------
|
// ----------------------------------------------------------
|
neorv32_cpu_csr_write(CSR_MCAUSE, 0);
|
neorv32_cpu_csr_write(CSR_MCAUSE, 0);
|
neorv32_uart_printf("[%i] MEI (via testbench) IRQ: ", cnt_test);
|
neorv32_uart_printf("[%i] MEI (via testbench): ", cnt_test);
|
|
|
if (is_simulation) { // check if this is a simulation
|
if (is_simulation) { // check if this is a simulation
|
cnt_test++;
|
cnt_test++;
|
|
|
// trigger IRQ
|
// trigger IRQ
|
Line 882... |
Line 882... |
|
|
// ----------------------------------------------------------
|
// ----------------------------------------------------------
|
// Non-maskable interrupt (NMI) via testbench
|
// Non-maskable interrupt (NMI) via testbench
|
// ----------------------------------------------------------
|
// ----------------------------------------------------------
|
neorv32_cpu_csr_write(CSR_MCAUSE, 0);
|
neorv32_cpu_csr_write(CSR_MCAUSE, 0);
|
neorv32_uart_printf("[%i] NMI (via testbench) IRQ: ", cnt_test);
|
neorv32_uart_printf("[%i] NMI (via testbench): ", cnt_test);
|
|
|
if (is_simulation) { // check if this is a simulation
|
if (is_simulation) { // check if this is a simulation
|
cnt_test++;
|
cnt_test++;
|
|
|
// trigger IRQ
|
// trigger IRQ
|
Line 1689... |
Line 1689... |
neorv32_uart_printf("\n\nTest results:\nOK: %i/%i\nFAILED: %i/%i\n\n", cnt_ok, cnt_test, cnt_fail, cnt_test);
|
neorv32_uart_printf("\n\nTest results:\nOK: %i/%i\nFAILED: %i/%i\n\n", cnt_ok, cnt_test, cnt_fail, cnt_test);
|
|
|
// final result
|
// final result
|
if (cnt_fail == 0) {
|
if (cnt_fail == 0) {
|
neorv32_uart_printf("%c[1m[CPU TEST COMPLETED SUCCESSFULLY!]%c[0m\n", 27, 27);
|
neorv32_uart_printf("%c[1m[CPU TEST COMPLETED SUCCESSFULLY!]%c[0m\n", 27, 27);
|
|
return 0;
|
}
|
}
|
else {
|
else {
|
neorv32_uart_printf("%c[1m[CPU TEST FAILED!]%c[0m\n", 27, 27);
|
neorv32_uart_printf("%c[1m[CPU TEST FAILED!]%c[0m\n", 27, 27);
|
|
return 1;
|
}
|
}
|
|
|
return 0;
|
|
}
|
}
|
|
|
|
|
/**********************************************************************//**
|
/**********************************************************************//**
|
* Simulation-based function to trigger CPU interrupts (MSI, MEI, FIRQ4..7).
|
* Simulation-based function to trigger CPU interrupts (MSI, MEI, FIRQ4..7).
|