Cleanup timeformat argument checking.
This commit is contained in:
parent
65baeaed8f
commit
513fa72d99
|
|
@ -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) {
|
||||||
tmp = vpi_scan(argv);
|
for (lp=0; lp<4; lp++) {
|
||||||
assert(tmp);
|
tmp = vpi_scan(argv);
|
||||||
assert(vpi_get(vpiType, tmp) == vpiConstant);
|
if (tmp) {
|
||||||
|
if (vpi_get(vpiType, tmp) != vpiConstant) {
|
||||||
tmp = vpi_scan(argv);
|
vpi_printf("$timeformat's arguments must be");
|
||||||
assert(tmp);
|
vpi_printf(" constant.\n");
|
||||||
assert(vpi_get(vpiType, tmp) == vpiConstant);
|
vpi_control(vpiFinish, -1);
|
||||||
|
}
|
||||||
tmp = vpi_scan(argv);
|
} else {
|
||||||
assert(tmp);
|
vpi_printf("$timeformat requires zero or four");
|
||||||
assert(vpi_get(vpiType, tmp) == vpiConstant);
|
vpi_printf(" arguments!\n");
|
||||||
|
vpi_control(vpiFinish, -1);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
vpi_free_object(argv);
|
||||||
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
@ -1278,40 +1296,35 @@ 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);
|
||||||
vpiHandle units = vpi_scan(argv);
|
|
||||||
vpiHandle prec = vpi_scan(argv);
|
|
||||||
vpiHandle suff = vpi_scan(argv);
|
|
||||||
vpiHandle wid = vpi_scan(argv);
|
|
||||||
|
|
||||||
vpi_free_object(argv);
|
if (argv) {
|
||||||
|
vpiHandle units = vpi_scan(argv);
|
||||||
|
vpiHandle prec = vpi_scan(argv);
|
||||||
|
vpiHandle suff = vpi_scan(argv);
|
||||||
|
vpiHandle wid = vpi_scan(argv);
|
||||||
|
|
||||||
value.format = vpiIntVal;
|
vpi_free_object(argv);
|
||||||
vpi_get_value(units, &value);
|
|
||||||
timeformat_info.units = value.value.integer;
|
|
||||||
|
|
||||||
value.format = vpiIntVal;
|
value.format = vpiIntVal;
|
||||||
vpi_get_value(prec, &value);
|
vpi_get_value(units, &value);
|
||||||
timeformat_info.prec = value.value.integer;
|
timeformat_info.units = value.value.integer;
|
||||||
|
|
||||||
value.format = vpiStringVal;
|
value.format = vpiIntVal;
|
||||||
vpi_get_value(suff, &value);
|
vpi_get_value(prec, &value);
|
||||||
timeformat_info.suff = strdup(value.value.str);
|
timeformat_info.prec = value.value.integer;
|
||||||
|
|
||||||
value.format = vpiIntVal;
|
value.format = vpiStringVal;
|
||||||
vpi_get_value(wid, &value);
|
vpi_get_value(suff, &value);
|
||||||
timeformat_info.width = value.value.integer;
|
timeformat_info.suff = strdup(value.value.str);
|
||||||
|
|
||||||
return 0;
|
value.format = vpiIntVal;
|
||||||
}
|
vpi_get_value(wid, &value);
|
||||||
|
timeformat_info.width = value.value.integer;
|
||||||
|
} else {
|
||||||
|
/* 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.
|
||||||
*
|
*
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue