Make vvp exit with FAILURE if $fatal is used to exit the simulation.

This commit is contained in:
Stephen Williams 2019-10-14 14:11:50 -07:00
parent 1a40a6f902
commit 0abf91ca4e
4 changed files with 13 additions and 1 deletions

View File

@ -2161,6 +2161,9 @@ static PLI_INT32 sys_severity_calltf(ICARUS_VPI_CONST PLI_BYTE8*name)
free(dstr);
if (strncmp(name,"$fatal",6) == 0) {
/* Set the exit code from vvp as an error code. */
vpip_set_return_value(1);
/* Now tell the simulator to finish. */
vpi_control(vpiFinish, finish_number.value.integer);
}

View File

@ -42,6 +42,8 @@ static PLI_INT32 sys_finish_calltf(ICARUS_VPI_CONST PLI_BYTE8 *name)
return 0;
}
vpip_set_return_value(0);
vpi_control(vpiFinish, diag_msg);
return 0;
}

View File

@ -630,7 +630,14 @@ extern DLLEXPORT void (*vlog_startup_routines[])(void);
/* Format a scalar a la %v. The str points to a 4byte character
buffer. The value must be a vpiStrengthVal. */
extern void vpip_format_strength(char*str, s_vpi_value*value, unsigned bit);
/* Set the return value to return from the vvp run time. This is
usually 0 or 1. This is the exit code that the vvp process
returns, and in distinct from the finish_number that is an
argument to $fatal and other severity tasks. The $fatal and
$finish system tasks bundled with iverilog use this function to
tell vvp to exit SUCCESS or FAILURE. */
extern void vpip_set_return_value(int value);
extern s_vpi_vecval vpip_calc_clog2(vpiHandle arg);
extern void vpip_make_systf_system_defined(vpiHandle ref);

View File

@ -535,7 +535,7 @@ void stop_handler(int rc)
/* The user may be running in a non-interactive environment, so
* they want $stop and <Control-C> to be the same as $finish. */
if (stop_is_finish) {
vpip_set_return_value(stop_is_finish_exit_code);
vpip_set_return_value(stop_is_finish_exit_code);
schedule_finish(0);
return;
}