From 7c152685dc393ce461a2a8319a18875ecb35bb38 Mon Sep 17 00:00:00 2001 From: Cary R Date: Thu, 5 Jun 2008 19:25:19 -0700 Subject: [PATCH] Clean up more compiletf routines, etc. This patch cleans up some of the code to use common compiletf routines where appropriate. It also adds code to print the number of extra arguments and cleans up the messages a bit. --- vpi/sys_finish.c | 90 ++++--------------------------------- vpi/sys_icarus.c | 49 ++------------------ vpi/sys_lxt.c | 2 +- vpi/sys_lxt2.c | 2 +- vpi/sys_priv.c | 106 ++++++++++++++++++++++++++++++++++++++++++++ vpi/sys_priv.h | 7 +++ vpi/sys_time.c | 8 ++-- vpi/sys_vcd.c | 2 +- vpi/sys_vcdoff.c | 2 +- vpi/vams_simparam.c | 44 +++++++++++------- vpi/vcd_priv.c | 66 ++++++--------------------- vpi/vcd_priv.h | 2 - 12 files changed, 175 insertions(+), 205 deletions(-) diff --git a/vpi/sys_finish.c b/vpi/sys_finish.c index 504bb5475..f55dd312e 100644 --- a/vpi/sys_finish.c +++ b/vpi/sys_finish.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999 Stephen Williams (steve@icarus.com) + * Copyright (c) 1999-2008 Stephen Williams (steve@icarus.com) * * This source code is free software; you can redistribute it * and/or modify it in source code form under the terms of the GNU @@ -16,44 +16,11 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ -#ifdef HAVE_CVS_IDENT -#ident "$Id: sys_finish.c,v 1.11 2007/04/09 22:49:33 steve Exp $" -#endif -# include "vpi_config.h" - -# include "vpi_user.h" -# include - -static PLI_INT32 sys_finish_compiletf(PLI_BYTE8 *name) -{ - vpiHandle callh = vpi_handle(vpiSysTfCall, 0); - vpiHandle argv = vpi_iterate(vpiArgument, callh); - vpiHandle arg; - - /* The argument is optional. */ - if (argv == 0) return 0; - arg = vpi_scan(argv); - - /* A string diagnostic message level makes no sense. */ - if (vpi_get(vpiType, arg) == vpiConstant && - vpi_get(vpiConstType, arg) == vpiStringConst) { - vpi_printf("Error: %s does not take a string argument.\n", name); - vpi_control(vpiFinish, 1); - return 0; - } - - /* These functions take at most one argument (diagnostic message). */ - arg = vpi_scan(argv); - if (arg != 0) { - vpi_printf("Error: %s takes at most one argument.\n", name); - vpi_control(vpiFinish, 1); - return 0; - } - - /* vpi_scan returning 0 (NULL) has already freed argv. */ - return 0; -} +#include "vpi_config.h" +#include "vpi_user.h" +#include "sys_priv.h" +#include static PLI_INT32 sys_finish_calltf(PLI_BYTE8 *name) { @@ -88,55 +55,16 @@ void sys_finish_register() tf_data.type = vpiSysTask; tf_data.tfname = "$finish"; tf_data.calltf = sys_finish_calltf; - tf_data.compiletf = sys_finish_compiletf; + tf_data.compiletf = sys_one_opt_numeric_arg_compiletf; tf_data.sizetf = 0; - tf_data.user_data = (PLI_BYTE8*)"$finish"; + tf_data.user_data = "$finish"; vpi_register_systf(&tf_data); tf_data.type = vpiSysTask; tf_data.tfname = "$stop"; tf_data.calltf = sys_finish_calltf; - tf_data.compiletf = sys_finish_compiletf; + tf_data.compiletf = sys_one_opt_numeric_arg_compiletf; tf_data.sizetf = 0; - tf_data.user_data = (PLI_BYTE8*)"$stop"; + tf_data.user_data = "$stop"; vpi_register_systf(&tf_data); } - -/* - * $Log: sys_finish.c,v $ - * Revision 1.11 2007/04/09 22:49:33 steve - * More strict use of PLI_BYTE8 type. - * - * Revision 1.10 2006/10/30 22:45:37 steve - * Updates for Cygwin portability (pr1585922) - * - * Revision 1.9 2004/01/21 01:22:53 steve - * Give the vip directory its own configure and vpi_config.h - * - * Revision 1.8 2003/02/21 03:24:03 steve - * Make the $stop system task really vpiStop. - * - * Revision 1.7 2002/08/12 01:35:04 steve - * conditional ident string using autoconfig. - * - * Revision 1.6 2001/07/25 03:10:50 steve - * Create a config.h.in file to hold all the config - * junk, and support gcc 3.0. (Stephan Boettcher) - * - * Revision 1.5 2001/01/01 19:33:44 steve - * Add $stop that does a finish. - * - * Revision 1.4 2000/02/23 02:56:56 steve - * Macintosh compilers do not support ident. - * - * Revision 1.3 1999/08/28 02:10:44 steve - * Call the right vpiFinish code. - * - * Revision 1.2 1999/08/19 02:51:03 steve - * Add vpi_sim_control - * - * Revision 1.1 1999/08/15 01:23:56 steve - * Convert vvm to implement system tasks with vpi. - * - */ - diff --git a/vpi/sys_icarus.c b/vpi/sys_icarus.c index a493c2b06..d2e1921d2 100644 --- a/vpi/sys_icarus.c +++ b/vpi/sys_icarus.c @@ -20,54 +20,13 @@ #include #include "sys_priv.h" -/* - * Routine to finish the simulation and return a value to the - * calling environment. - */ -static PLI_INT32 finish_and_return_compiletf(PLI_BYTE8* ud) -{ - vpiHandle callh = vpi_handle(vpiSysTfCall, 0); - assert(callh); - vpiHandle argv = vpi_iterate(vpiArgument, callh); - (void) ud; /* Not used! */ - - /* We must have at least one argument. */ - if (argv == 0) { - vpi_printf("ERROR: %s line %d: ", vpi_get_str(vpiFile, callh), - (int)vpi_get(vpiLineNo, callh)); - vpi_printf("$finish_and_return requires an argument.\n"); - vpi_control(vpiFinish, 1); - return 0; - } - - /* This must be a numeric argument. */ - if (! is_numeric_obj(vpi_scan(argv))) { - vpi_printf("ERROR: %s line %d: ", vpi_get_str(vpiFile, callh), - (int)vpi_get(vpiLineNo, callh)); - vpi_printf("The argument to $finish_and_return must be numeric.\n"); - vpi_control(vpiFinish, 1); - return 0; - } - - /* We can only have one argument. */ - if (vpi_scan(argv) != 0) { - vpi_printf("ERROR: %s line %d: ", vpi_get_str(vpiFile, callh), - (int)vpi_get(vpiLineNo, callh)); - vpi_printf("$finish_and_return takes only a single argument.\n"); - vpi_control(vpiFinish, 1); - return 0; - } - - return 0; -} - -static PLI_INT32 finish_and_return_calltf(PLI_BYTE8* ud) +static PLI_INT32 finish_and_return_calltf(PLI_BYTE8* name) { vpiHandle callh = vpi_handle(vpiSysTfCall, 0); vpiHandle argv = vpi_iterate(vpiArgument, callh); vpiHandle arg; s_vpi_value val; - (void) ud; /* Not used! */ + (void) name; /* Not used! */ /* Get the return value. */ arg = vpi_scan(argv); @@ -92,9 +51,9 @@ void sys_special_register(void) tf_data.type = vpiSysTask; tf_data.calltf = finish_and_return_calltf; - tf_data.compiletf = finish_and_return_compiletf; + tf_data.compiletf = sys_one_numeric_arg_compiletf; tf_data.sizetf = 0; tf_data.tfname = "$finish_and_return"; - tf_data.user_data = 0; + tf_data.user_data = "$finish_and_return"; vpi_register_systf(&tf_data); } diff --git a/vpi/sys_lxt.c b/vpi/sys_lxt.c index 72689046e..df6563fab 100644 --- a/vpi/sys_lxt.c +++ b/vpi/sys_lxt.c @@ -782,7 +782,7 @@ void sys_lxt_register() tf_data.type = vpiSysTask; tf_data.tfname = "$dumplimit"; tf_data.calltf = sys_dumplimit_calltf; - tf_data.compiletf = sys_dumplimit_compiletf; + tf_data.compiletf = sys_one_numeric_arg_compiletf; tf_data.sizetf = 0; tf_data.user_data = "$dumplimit"; vpi_register_systf(&tf_data); diff --git a/vpi/sys_lxt2.c b/vpi/sys_lxt2.c index 92a11bbd9..debe0adad 100644 --- a/vpi/sys_lxt2.c +++ b/vpi/sys_lxt2.c @@ -797,7 +797,7 @@ void sys_lxt2_register() tf_data.type = vpiSysTask; tf_data.tfname = "$dumplimit"; tf_data.calltf = sys_dumplimit_calltf; - tf_data.compiletf = sys_dumplimit_compiletf; + tf_data.compiletf = sys_one_numeric_arg_compiletf; tf_data.sizetf = 0; tf_data.user_data = "$dumplimit"; vpi_register_systf(&tf_data); diff --git a/vpi/sys_priv.c b/vpi/sys_priv.c index 51625a214..8e72ecd73 100644 --- a/vpi/sys_priv.c +++ b/vpi/sys_priv.c @@ -18,6 +18,7 @@ */ #include +#include #include "sys_priv.h" PLI_UINT64 timerec_to_time64(const struct t_vpi_time*time) @@ -129,3 +130,108 @@ vpiHandle sys_func_module(vpiHandle obj) return obj; } + +/* + * Standard compiletf routines. + */ + +/* For system functions that do not take an argument. */ +PLI_INT32 sys_no_arg_compiletf(PLI_BYTE8 *name) +{ + vpiHandle callh = vpi_handle(vpiSysTfCall, 0); + vpiHandle argv = vpi_iterate(vpiArgument, callh); + + /* Make sure there are no arguments. */ + if (argv != 0) { + char msg [64]; + snprintf(msg, 64, "ERROR: %s line %d:", + vpi_get_str(vpiFile, callh), + (int)vpi_get(vpiLineNo, callh)); + + unsigned argc = 0; + while (vpi_scan(argv)) argc += 1; + + vpi_printf("%s %s does not take an argument.\n", msg, name); + vpi_printf("%*s Found %u extra argument%s.\n", + strlen(msg), " ", argc, argc == 1 ? "" : "s"); + vpi_control(vpiFinish, 1); + } + + return 0; +} + +/* For system functions that take a single numeric argument. */ +PLI_INT32 sys_one_numeric_arg_compiletf(PLI_BYTE8 *name) +{ + vpiHandle callh = vpi_handle(vpiSysTfCall, 0); + vpiHandle argv = vpi_iterate(vpiArgument, callh); + + /* Check that there is an argument and that it is numeric. */ + if (argv == 0) { + vpi_printf("ERROR: %s line %d: ", vpi_get_str(vpiFile, callh), + (int)vpi_get(vpiLineNo, callh)); + vpi_printf("%s requires a single numeric argument.\n", name); + vpi_control(vpiFinish, 1); + return 0; + } + + if (! is_numeric_obj(vpi_scan(argv))) { + vpi_printf("ERROR: %s line %d: ", vpi_get_str(vpiFile, callh), + (int)vpi_get(vpiLineNo, callh)); + vpi_printf("%s's argument must be numeric.\n", name); + vpi_control(vpiFinish, 1); + } + + /* Make sure there are no extra arguments. */ + if (vpi_scan(argv) != 0) { + char msg [64]; + snprintf(msg, 64, "ERROR: %s line %d:", + vpi_get_str(vpiFile, callh), + (int)vpi_get(vpiLineNo, callh)); + + unsigned argc = 1; + while (vpi_scan(argv)) argc += 1; + + vpi_printf("%s %s takes a single numeric argument.\n", msg, name); + vpi_printf("%*s Found %u extra argument%s.\n", + strlen(msg), " ", argc, argc == 1 ? "" : "s"); + vpi_control(vpiFinish, 1); + } + + return 0; +} + +/* For system functions that take a single optional numeric argument. */ +PLI_INT32 sys_one_opt_numeric_arg_compiletf(PLI_BYTE8 *name) +{ + vpiHandle callh = vpi_handle(vpiSysTfCall, 0); + vpiHandle argv = vpi_iterate(vpiArgument, callh); + + /* The argument is optional so just return if none are found. */ + if (argv == 0) return 0; + + if (! is_numeric_obj(vpi_scan(argv))) { + vpi_printf("ERROR: %s line %d: ", vpi_get_str(vpiFile, callh), + (int)vpi_get(vpiLineNo, callh)); + vpi_printf("%s's argument must be numeric.\n", name); + vpi_control(vpiFinish, 1); + } + + /* Make sure there are no extra arguments. */ + if (vpi_scan(argv) != 0) { + char msg [64]; + snprintf(msg, 64, "ERROR: %s line %d:", + vpi_get_str(vpiFile, callh), + (int)vpi_get(vpiLineNo, callh)); + + unsigned argc = 1; + while (vpi_scan(argv)) argc += 1; + + vpi_printf("%s %s takes a single numeric argument.\n", msg, name); + vpi_printf("%*s Found %u extra argument%s.\n", + strlen(msg), " ", argc, argc == 1 ? "" : "s"); + vpi_control(vpiFinish, 1); + } + + return 0; +} diff --git a/vpi/sys_priv.h b/vpi/sys_priv.h index 31a09a7bd..4f0d14a7b 100644 --- a/vpi/sys_priv.h +++ b/vpi/sys_priv.h @@ -50,4 +50,11 @@ extern unsigned is_string_obj(vpiHandle obj); extern vpiHandle sys_func_module(vpiHandle obj); +/* + * The standard compiletf routines. + */ +extern PLI_INT32 sys_no_arg_compiletf(PLI_BYTE8 *name); +extern PLI_INT32 sys_one_numeric_arg_compiletf(PLI_BYTE8 *name); +extern PLI_INT32 sys_one_opt_numeric_arg_compiletf(PLI_BYTE8 *name); + #endif diff --git a/vpi/sys_time.c b/vpi/sys_time.c index 034a7ce70..5d040f966 100644 --- a/vpi/sys_time.c +++ b/vpi/sys_time.c @@ -116,7 +116,7 @@ void sys_time_register() tf_data.tfname = "$time"; tf_data.sysfunctype = vpiTimeFunc; tf_data.calltf = sys_time_calltf; - tf_data.compiletf = 0; + tf_data.compiletf = sys_no_arg_compiletf; tf_data.sizetf = 0; tf_data.user_data = "$time"; vpi_register_systf(&tf_data); @@ -125,7 +125,7 @@ void sys_time_register() tf_data.tfname = "$realtime"; tf_data.sysfunctype = vpiRealFunc; tf_data.calltf = sys_realtime_calltf; - tf_data.compiletf = 0; + tf_data.compiletf = sys_no_arg_compiletf; tf_data.sizetf = 0; tf_data.user_data = "$realtime"; vpi_register_systf(&tf_data); @@ -134,7 +134,7 @@ void sys_time_register() tf_data.tfname = "$stime"; tf_data.sysfunctype = vpiIntFunc; tf_data.calltf = sys_time_calltf; - tf_data.compiletf = 0; + tf_data.compiletf = sys_no_arg_compiletf; tf_data.sizetf = 0; tf_data.user_data = "$stime"; vpi_register_systf(&tf_data); @@ -143,7 +143,7 @@ void sys_time_register() tf_data.tfname = "$simtime"; tf_data.sysfunctype = vpiTimeFunc; tf_data.calltf = sys_time_calltf; - tf_data.compiletf = 0; + tf_data.compiletf = sys_no_arg_compiletf; tf_data.sizetf = 0; tf_data.user_data = "$simtime"; vpi_register_systf(&tf_data); diff --git a/vpi/sys_vcd.c b/vpi/sys_vcd.c index b4c14185b..d83f8e2d6 100644 --- a/vpi/sys_vcd.c +++ b/vpi/sys_vcd.c @@ -795,7 +795,7 @@ void sys_vcd_register() tf_data.type = vpiSysTask; tf_data.tfname = "$dumplimit"; tf_data.calltf = sys_dumplimit_calltf; - tf_data.compiletf = sys_dumplimit_compiletf; + tf_data.compiletf = sys_one_numeric_arg_compiletf; tf_data.sizetf = 0; tf_data.user_data = "$dumplimit"; vpi_register_systf(&tf_data); diff --git a/vpi/sys_vcdoff.c b/vpi/sys_vcdoff.c index e12f750ef..b29f6a2b9 100644 --- a/vpi/sys_vcdoff.c +++ b/vpi/sys_vcdoff.c @@ -85,7 +85,7 @@ void sys_vcdoff_register() tf_data.type = vpiSysTask; tf_data.tfname = "$dumplimit"; tf_data.calltf = sys_dummy_calltf; - tf_data.compiletf = sys_dumplimit_compiletf; + tf_data.compiletf = sys_one_numeric_arg_compiletf; tf_data.sizetf = 0; tf_data.user_data = "$dumplimit"; vpi_register_systf(&tf_data); diff --git a/vpi/vams_simparam.c b/vpi/vams_simparam.c index e917e8475..bc094270e 100644 --- a/vpi/vams_simparam.c +++ b/vpi/vams_simparam.c @@ -34,7 +34,7 @@ /* * Check that the routines are called with the correct arguments. */ -static PLI_INT32 simparam_compiletf(PLI_BYTE8* ud) +static PLI_INT32 simparam_compiletf(PLI_BYTE8* name_ext) { vpiHandle callh = vpi_handle(vpiSysTfCall, 0); assert(callh != 0); @@ -45,7 +45,7 @@ static PLI_INT32 simparam_compiletf(PLI_BYTE8* ud) if (argv == 0) { vpi_printf("ERROR: %s line %d: ", vpi_get_str(vpiFile, callh), (int)vpi_get(vpiLineNo, callh)); - vpi_printf("$simparam%s requires an argument.\n", ud); + vpi_printf("$simparam%s requires a string argument.\n", name_ext); vpi_control(vpiFinish, 1); return 0; } @@ -55,7 +55,8 @@ static PLI_INT32 simparam_compiletf(PLI_BYTE8* ud) if (! is_string_obj(arg)) { vpi_printf("ERROR: %s line %d: ", vpi_get_str(vpiFile, callh), (int)vpi_get(vpiLineNo, callh)); - vpi_printf("The first argument to $simparam%s must be a string.\n", ud); + vpi_printf("The first argument to $simparam%s must be a string.\n", + name_ext); vpi_control(vpiFinish, 1); } @@ -64,12 +65,12 @@ static PLI_INT32 simparam_compiletf(PLI_BYTE8* ud) if (arg == 0) return 0; /* For the string version the default must also be a string. */ - if (strcmp(ud, "$str") == 0) { + if (strcmp(name_ext, "$str") == 0) { if (! is_string_obj(arg)) { vpi_printf("ERROR: %s line %d: ", vpi_get_str(vpiFile, callh), (int)vpi_get(vpiLineNo, callh)); vpi_printf("When provided, the second argument to $simparam%s" - "must be a string.\n", ud); + "must be a string.\n", name_ext); vpi_control(vpiFinish, 1); } /* For the rest the default must be numeric. */ @@ -78,23 +79,32 @@ static PLI_INT32 simparam_compiletf(PLI_BYTE8* ud) vpi_printf("ERROR: %s line %d: ", vpi_get_str(vpiFile, callh), (int)vpi_get(vpiLineNo, callh)); vpi_printf("When provided, the second argument to $simparam%s" - "must be numeric.\n", ud); + "must be numeric.\n", name_ext); vpi_control(vpiFinish, 1); } } /* We can only have two argument. */ if (vpi_scan(argv) != 0) { - vpi_printf("ERROR: %s line %d: ", vpi_get_str(vpiFile, callh), - (int)vpi_get(vpiLineNo, callh)); - vpi_printf("$simparam%s takes at most two arguments.\n", ud); - vpi_control(vpiFinish, 1); + char msg [64]; + snprintf(msg, 64, "ERROR: %s line %d:", + vpi_get_str(vpiFile, callh), + (int)vpi_get(vpiLineNo, callh)); + + unsigned argc = 1; + while (vpi_scan(argv)) argc += 1; + + vpi_printf("%s $simparam%s takes at most two arguments.\n", + msg, name_ext); + vpi_printf("%*s Found %u extra argument%s.\n", + strlen(msg), " ", argc, argc == 1 ? "" : "s"); + vpi_control(vpiFinish, 1); } return 0; } -static PLI_INT32 simparam_calltf(PLI_BYTE8* ud) +static PLI_INT32 simparam_calltf(PLI_BYTE8* name_ext) { vpiHandle callh = vpi_handle(vpiSysTfCall, 0); vpiHandle argv = vpi_iterate(vpiArgument, callh); @@ -153,7 +163,8 @@ static PLI_INT32 simparam_calltf(PLI_BYTE8* ud) if (! have_def_val) { vpi_printf("ERROR: %s line %d: ", vpi_get_str(vpiFile, callh), (int)vpi_get(vpiLineNo, callh)); - vpi_printf("unknown parameter name \"%s\".\n", param); + vpi_printf("$simparam%s unknown parameter name \"%s\".\n", + name_ext, param); } retval = defval; } @@ -168,7 +179,7 @@ static PLI_INT32 simparam_calltf(PLI_BYTE8* ud) return 0; } -static PLI_INT32 simparam_str_calltf(PLI_BYTE8* ud) +static PLI_INT32 simparam_str_calltf(PLI_BYTE8* name_ext) { vpiHandle callh = vpi_handle(vpiSysTfCall, 0); vpiHandle argv = vpi_iterate(vpiArgument, callh); @@ -217,7 +228,8 @@ static PLI_INT32 simparam_str_calltf(PLI_BYTE8* ud) if (defval == 0) { vpi_printf("ERROR: %s line %d: ", vpi_get_str(vpiFile, callh), (int)vpi_get(vpiLineNo, callh)); - vpi_printf("unknown parameter name \"%s\".\n", param); + vpi_printf("$simparam%s unknown parameter name \"%s\".\n", + name_ext, param); defval = strdup(""); } retval = defval; @@ -234,9 +246,9 @@ static PLI_INT32 simparam_str_calltf(PLI_BYTE8* ud) return 0; } -static PLI_INT32 simparam_str_sizetf(PLI_BYTE8* ud) +static PLI_INT32 simparam_str_sizetf(PLI_BYTE8* name_ext) { - (void) ud; //* Not used! */ + (void) name_ext; //* Not used! */ return MAX_STRING_RESULT; // 128 characters max! } diff --git a/vpi/vcd_priv.c b/vpi/vcd_priv.c index 389bae21f..1f18fd2a3 100644 --- a/vpi/vcd_priv.c +++ b/vpi/vcd_priv.c @@ -188,25 +188,10 @@ void set_nexus_ident(int nex, const char *id) /* * Since the compiletf routines are all the same they are located here, - * so we only need a single copy. + * so we only need a single copy. Some are generic enough they can use + * the ones in sys_priv.c (no arg, one numeric arg. */ -/* $dumpall, $dumpflush, $dumpoff and $dumpon do not take an argument. */ -PLI_INT32 sys_no_arg_compiletf(PLI_BYTE8 *name) -{ - vpiHandle callh = vpi_handle(vpiSysTfCall, 0); - vpiHandle argv = vpi_iterate(vpiArgument, callh); - - if (argv != 0) { - vpi_printf("ERROR: %s line %d: ", vpi_get_str(vpiFile, callh), - (int)vpi_get(vpiLineNo, callh)); - vpi_printf("%s does not take an argument.\n", name); - vpi_control(vpiFinish, 1); - } - - return 0; -} - /* $dumpfile takes a single string argument. */ PLI_INT32 sys_dumpfile_compiletf(PLI_BYTE8 *name) { @@ -217,7 +202,7 @@ PLI_INT32 sys_dumpfile_compiletf(PLI_BYTE8 *name) if (argv == 0) { vpi_printf("ERROR: %s line %d: ", vpi_get_str(vpiFile, callh), (int)vpi_get(vpiLineNo, callh)); - vpi_printf("%s requires an argument.\n", name); + vpi_printf("%s requires a single string argument.\n", name); vpi_control(vpiFinish, 1); return 0; } @@ -228,44 +213,19 @@ PLI_INT32 sys_dumpfile_compiletf(PLI_BYTE8 *name) vpi_control(vpiFinish, 1); } - /* Check that there is only a single argument. */ + /* Make sure there are no extra arguments. */ if (vpi_scan(argv) != 0) { - vpi_printf("ERROR: %s line %d: ", vpi_get_str(vpiFile, callh), - (int)vpi_get(vpiLineNo, callh)); - vpi_printf("%s takes a single argument.\n", name); - vpi_control(vpiFinish, 1); - } + char msg [64]; + snprintf(msg, 64, "ERROR: %s line %d:", + vpi_get_str(vpiFile, callh), + (int)vpi_get(vpiLineNo, callh)); - return 0; -} + unsigned argc = 1; + while (vpi_scan(argv)) argc += 1; -/* $dumplimit takes a single numeric argument. */ -PLI_INT32 sys_dumplimit_compiletf(PLI_BYTE8 *name) -{ - vpiHandle callh = vpi_handle(vpiSysTfCall, 0); - vpiHandle argv = vpi_iterate(vpiArgument, callh); - - /* Check that there is an argument and that it is numeric. */ - if (argv == 0) { - vpi_printf("ERROR: %s line %d: ", vpi_get_str(vpiFile, callh), - (int)vpi_get(vpiLineNo, callh)); - vpi_printf("%s requires an argument.\n", name); - vpi_control(vpiFinish, 1); - return 0; - } - - if (! is_numeric_obj(vpi_scan(argv))) { - vpi_printf("ERROR: %s line %d: ", vpi_get_str(vpiFile, callh), - (int)vpi_get(vpiLineNo, callh)); - vpi_printf("%s's argument must be numeric.\n", name); - vpi_control(vpiFinish, 1); - } - - /* Check that there is only a single argument. */ - if (vpi_scan(argv) != 0) { - vpi_printf("ERROR: %s line %d: ", vpi_get_str(vpiFile, callh), - (int)vpi_get(vpiLineNo, callh)); - vpi_printf("%s takes a single argument.\n", name); + vpi_printf("%s %s takes a single string argument.\n", msg, name); + vpi_printf("%*s Found %u extra argument%s.\n", + strlen(msg), " ", argc, argc == 1 ? "" : "s"); vpi_control(vpiFinish, 1); } diff --git a/vpi/vcd_priv.h b/vpi/vcd_priv.h index 2645f94f7..acc0544cd 100644 --- a/vpi/vcd_priv.h +++ b/vpi/vcd_priv.h @@ -44,9 +44,7 @@ extern const char*find_nexus_ident(int nex); extern void set_nexus_ident(int nex, const char *id); /* The compiletf routines are common for the VCD, LXT and LXT2 dumpers. */ -extern PLI_INT32 sys_no_arg_compiletf(PLI_BYTE8 *name); extern PLI_INT32 sys_dumpfile_compiletf(PLI_BYTE8 *name); -extern PLI_INT32 sys_dumplimit_compiletf(PLI_BYTE8 *name); extern PLI_INT32 sys_dumpvars_compiletf(PLI_BYTE8 *name); #endif