Add -compatible command line option to vvp.

This option is intended to make it easier to compare results from
Icarus with results from other simulators. For now, the only effect
it has is to change the default format for displaying real numbers
when no format string is supplied.
This commit is contained in:
Martin Whitaker 2013-10-20 22:59:53 +01:00
parent 20ad1ff261
commit a024efb615
2 changed files with 27 additions and 2 deletions

View File

@ -29,6 +29,23 @@
#define IS_MCD(mcd) !((mcd)>>31&1)
// Flag to enable better compatibility with other simulators
static unsigned compatible_flag = 0;
static void check_command_line_args(void)
{
struct t_vpi_vlog_info vlog_info;
vpi_get_vlog_info(&vlog_info);
for (unsigned idx = 0 ; idx < vlog_info.argc ; idx += 1) {
if (strcmp(vlog_info.argv[idx],"-compatible") == 0) {
compatible_flag = 1;
}
}
}
/* Printf wrapper to handle both MCD/FD */
static PLI_INT32 my_mcd_printf(PLI_UINT32 mcd, const char *fmt, ...)
{
@ -913,7 +930,7 @@ static char *get_display(unsigned int *rtnsz, const struct strobe_cb_info *info)
} else if (vpi_get(vpiConstType, item) == vpiRealConst) {
value.format = vpiRealVal;
vpi_get_value(item, &value);
sprintf(buf, "%#g", value.value.real);
sprintf(buf, compatible_flag ? "%g" : "%#g", value.value.real);
result = strdup(buf);
width = strlen(result);
} else {
@ -958,7 +975,7 @@ static char *get_display(unsigned int *rtnsz, const struct strobe_cb_info *info)
case vpiRealVar:
value.format = vpiRealVal;
vpi_get_value(item, &value);
sprintf(buf, "%#g", value.value.real);
sprintf(buf, compatible_flag ? "%g" : "%#g", value.value.real);
width = strlen(buf);
rtn = realloc(rtn, (size+width)*sizeof(char));
memcpy(rtn+size-1, buf, width);
@ -2051,6 +2068,8 @@ void sys_display_register()
s_vpi_systf_data tf_data;
vpiHandle res;
check_command_line_args();
/*============================== display */
tf_data.type = vpiSysTask;
tf_data.tfname = "$display";

View File

@ -144,6 +144,12 @@ to print information about the annotation.
.B -sdf-verbose
This is shorthand for \-sdf\-info \-sdf\-warn.
.TP 8
.B -compatible
This extended argument enables improved compatibility with other
simulators. At present this only affects the display format for
real numbers when no format string is supplied.
.SH ENVIRONMENT
.PP
The vvp command also accepts some environment variables that control