Cleanup timeformat argument checking.

This commit is contained in:
steve 2007-04-10 04:56:26 +00:00
parent 65baeaed8f
commit 513fa72d99
1 changed files with 56 additions and 40 deletions

View File

@ -17,7 +17,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/ */
#ifdef HAVE_CVS_IDENT #ifdef HAVE_CVS_IDENT
#ident "$Id: sys_display.c,v 1.74 2007/03/14 04:05:51 steve Exp $" #ident "$Id: sys_display.c,v 1.75 2007/04/10 04:56:26 steve Exp $"
#endif #endif
# include "vpi_config.h" # include "vpi_config.h"
@ -1251,24 +1251,42 @@ static PLI_INT32 sys_fdisplay_calltf(PLI_BYTE8*name)
return 0; return 0;
} }
static PLI_INT32 sys_end_of_compile(p_cb_data cb_data)
{
/* The default timeformat prints times in unit of simulation
precision. */
timeformat_info.suff = strdup("");
timeformat_info.units = vpi_get(vpiTimePrecision, 0);
timeformat_info.prec = 0;
timeformat_info.width = 20;
return 0;
}
static PLI_INT32 sys_timeformat_compiletf(PLI_BYTE8*xx) static PLI_INT32 sys_timeformat_compiletf(PLI_BYTE8*xx)
{ {
vpiHandle sys = vpi_handle(vpiSysTfCall, 0); vpiHandle sys = vpi_handle(vpiSysTfCall, 0);
vpiHandle argv = vpi_iterate(vpiArgument, sys); vpiHandle argv = vpi_iterate(vpiArgument, sys);
vpiHandle tmp; vpiHandle tmp;
int lp;
assert(argv); if (argv) {
for (lp=0; lp<4; lp++) {
tmp = vpi_scan(argv); tmp = vpi_scan(argv);
assert(tmp); if (tmp) {
assert(vpi_get(vpiType, tmp) == vpiConstant); if (vpi_get(vpiType, tmp) != vpiConstant) {
vpi_printf("$timeformat's arguments must be");
tmp = vpi_scan(argv); vpi_printf(" constant.\n");
assert(tmp); vpi_control(vpiFinish, -1);
assert(vpi_get(vpiType, tmp) == vpiConstant); }
} else {
tmp = vpi_scan(argv); vpi_printf("$timeformat requires zero or four");
assert(tmp); vpi_printf(" arguments!\n");
assert(vpi_get(vpiType, tmp) == vpiConstant); vpi_control(vpiFinish, -1);
return 0;
}
}
vpi_free_object(argv);
}
return 0; return 0;
} }
@ -1278,6 +1296,8 @@ static PLI_INT32 sys_timeformat_calltf(PLI_BYTE8*xx)
s_vpi_value value; s_vpi_value value;
vpiHandle sys = vpi_handle(vpiSysTfCall, 0); vpiHandle sys = vpi_handle(vpiSysTfCall, 0);
vpiHandle argv = vpi_iterate(vpiArgument, sys); vpiHandle argv = vpi_iterate(vpiArgument, sys);
if (argv) {
vpiHandle units = vpi_scan(argv); vpiHandle units = vpi_scan(argv);
vpiHandle prec = vpi_scan(argv); vpiHandle prec = vpi_scan(argv);
vpiHandle suff = vpi_scan(argv); vpiHandle suff = vpi_scan(argv);
@ -1300,18 +1320,11 @@ static PLI_INT32 sys_timeformat_calltf(PLI_BYTE8*xx)
value.format = vpiIntVal; value.format = vpiIntVal;
vpi_get_value(wid, &value); vpi_get_value(wid, &value);
timeformat_info.width = value.value.integer; timeformat_info.width = value.value.integer;
} else {
return 0; /* If no arguments are given then use the default values. */
sys_end_of_compile(NULL);
} }
static PLI_INT32 sys_end_of_compile(p_cb_data cb_data)
{
/* The default timeformat prints times in unit of simulation
precision. */
timeformat_info.suff = strdup("");
timeformat_info.units = vpi_get(vpiTimePrecision, 0);
timeformat_info.prec = 0;
timeformat_info.width = 20;
return 0; return 0;
} }
@ -1560,6 +1573,9 @@ void sys_display_register()
/* /*
* $Log: sys_display.c,v $ * $Log: sys_display.c,v $
* Revision 1.75 2007/04/10 04:56:26 steve
* Cleanup timeformat argument checking.
*
* Revision 1.74 2007/03/14 04:05:51 steve * Revision 1.74 2007/03/14 04:05:51 steve
* VPI tasks take PLI_BYTE* by the standard. * VPI tasks take PLI_BYTE* by the standard.
* *