From a024efb615f2d4ebab4230655e7a6da346a5389f Mon Sep 17 00:00:00 2001 From: Martin Whitaker Date: Sun, 20 Oct 2013 22:59:53 +0100 Subject: [PATCH] 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. --- vpi/sys_display.c | 23 +++++++++++++++++++++-- vvp/vvp.man.in | 6 ++++++ 2 files changed, 27 insertions(+), 2 deletions(-) diff --git a/vpi/sys_display.c b/vpi/sys_display.c index 047c0dc6a..ba6b2a4e0 100644 --- a/vpi/sys_display.c +++ b/vpi/sys_display.c @@ -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"; diff --git a/vvp/vvp.man.in b/vvp/vvp.man.in index d8c9cff74..a6600b505 100644 --- a/vvp/vvp.man.in +++ b/vvp/vvp.man.in @@ -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