Move $fatal argument value check from compiletf to calltf.

Move check of the value $fatal is called with from the compiletf to
the calltf routine, since the value may not be known at compiletf
time.  If the value is invalid, it just prints a warning that $fatal
was called with a bad finish_number, and resets it to the default 1.

Changes the compile time check for a numeric argument to a warning.

Also, fixes bug where $fatal called without an argument causes problems.
This commit is contained in:
Jared Casper 2010-03-08 22:25:12 -08:00 committed by Stephen Williams
parent 316006b98b
commit 3a4fac7b43
1 changed files with 14 additions and 17 deletions

View File

@ -1857,26 +1857,13 @@ static PLI_INT32 sys_fatal_compiletf(PLI_BYTE8*name)
if (argv) {
vpiHandle arg;
s_vpi_value val;
/* Check that finish_number is numeric */
arg = vpi_scan(argv);
if (! is_numeric_obj(arg)) {
vpi_printf("ERROR: %s:%d: ", vpi_get_str(vpiFile, callh),
vpi_printf("WARNING: %s:%d: ", vpi_get_str(vpiFile, callh),
(int)vpi_get(vpiLineNo, callh));
vpi_printf("%s's first argument must be numeric\n", name);
vpi_control(vpiFinish, 1);
return 0;
}
/* Check that it is 0, 1, or 2 */
val.format = vpiIntVal;
vpi_get_value(arg, &val);
if ((val.value.integer < 0) || (val.value.integer > 2)) {
vpi_printf("ERROR: %s:%d: ", vpi_get_str(vpiFile, callh),
(int)vpi_get(vpiLineNo, callh));
vpi_printf("%s's finish_number must be 0, 1, or 2\n", name);
vpi_control(vpiFinish, 1);
vpi_printf("%s's first argument should be numeric\n", name);
}
}
if (sys_check_args(callh, argv, name, 0, 0)) vpi_control(vpiFinish, 1);
@ -1891,16 +1878,26 @@ static PLI_INT32 sys_severity_calltf(PLI_BYTE8*name)
PLI_UINT64 now64;
char *sstr, *t, *dstr;
unsigned int size, location=0;
s_vpi_value finish_number;
s_vpi_value finish_number = {vpiIntVal};
finish_number.value.integer = 1;
callh = vpi_handle(vpiSysTfCall, 0);
argv = vpi_iterate(vpiArgument, callh);
if (strncmp(name,"$fatal",6) == 0) {
if (strncmp(name,"$fatal",6) == 0 && argv) {
vpiHandle arg = vpi_scan(argv);
finish_number.format = vpiIntVal;
vpi_get_value(arg, &finish_number);
if ((finish_number.value.integer < 0) ||
(finish_number.value.integer > 2)) {
vpi_printf("WARNING: %s:%d: ", vpi_get_str(vpiFile, callh),
(int)vpi_get(vpiLineNo, callh));
vpi_printf("$fatal called with finish_number of %d, "
"but it must be 0, 1, or 2\n",
finish_number.value.integer);
finish_number.value.integer = 1;
}
}
/* convert name to upper and drop $ to get severity string */