Rework more compiletf and calltf routines in the vpi directory.
This is a major rework on the sys_fileio routines. They now have improved compiletf routines and the calltf routines are now standardized. Along the way a few bug were fixed as well. Some updates to other vpi files as well. I changed the order of the $fputc() arguments to match C and the rest of the system functions like it ($fungetc, etc.). I recently fixed $fungetc() so I'm assuming the $fputc() needs the same fix. It's an Icarus specific function.
This commit is contained in:
parent
f6bc1afcbb
commit
ebdf4e478a
1027
vpi/sys_fileio.c
1027
vpi/sys_fileio.c
File diff suppressed because it is too large
Load Diff
|
|
@ -766,7 +766,7 @@ void sys_lxt_register()
|
|||
tf_data.type = vpiSysTask;
|
||||
tf_data.tfname = "$dumpfile";
|
||||
tf_data.calltf = sys_dumpfile_calltf;
|
||||
tf_data.compiletf = sys_dumpfile_compiletf;
|
||||
tf_data.compiletf = sys_one_string_arg_compiletf;
|
||||
tf_data.sizetf = 0;
|
||||
tf_data.user_data = "$dumpfile";
|
||||
vpi_register_systf(&tf_data);
|
||||
|
|
|
|||
|
|
@ -781,7 +781,7 @@ void sys_lxt2_register()
|
|||
tf_data.type = vpiSysTask;
|
||||
tf_data.tfname = "$dumpfile";
|
||||
tf_data.calltf = sys_dumpfile_calltf;
|
||||
tf_data.compiletf = sys_dumpfile_compiletf;
|
||||
tf_data.compiletf = sys_one_string_arg_compiletf;
|
||||
tf_data.sizetf = 0;
|
||||
tf_data.user_data = "$dumpfile";
|
||||
vpi_register_systf(&tf_data);
|
||||
|
|
|
|||
107
vpi/sys_priv.c
107
vpi/sys_priv.c
|
|
@ -135,7 +135,7 @@ vpiHandle sys_func_module(vpiHandle obj)
|
|||
* Standard compiletf routines.
|
||||
*/
|
||||
|
||||
/* For system functions that do not take an argument. */
|
||||
/* For system tasks/functions that do not take an argument. */
|
||||
PLI_INT32 sys_no_arg_compiletf(PLI_BYTE8 *name)
|
||||
{
|
||||
vpiHandle callh = vpi_handle(vpiSysTfCall, 0);
|
||||
|
|
@ -160,7 +160,7 @@ PLI_INT32 sys_no_arg_compiletf(PLI_BYTE8 *name)
|
|||
return 0;
|
||||
}
|
||||
|
||||
/* For system functions that take a single numeric argument. */
|
||||
/* For system tasks/functions that take a single numeric argument. */
|
||||
PLI_INT32 sys_one_numeric_arg_compiletf(PLI_BYTE8 *name)
|
||||
{
|
||||
vpiHandle callh = vpi_handle(vpiSysTfCall, 0);
|
||||
|
|
@ -201,7 +201,7 @@ PLI_INT32 sys_one_numeric_arg_compiletf(PLI_BYTE8 *name)
|
|||
return 0;
|
||||
}
|
||||
|
||||
/* For system functions that take a single optional numeric argument. */
|
||||
/* For system tasks/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);
|
||||
|
|
@ -227,7 +227,106 @@ PLI_INT32 sys_one_opt_numeric_arg_compiletf(PLI_BYTE8 *name)
|
|||
unsigned argc = 1;
|
||||
while (vpi_scan(argv)) argc += 1;
|
||||
|
||||
vpi_printf("%s %s takes a single numeric argument.\n", msg, name);
|
||||
vpi_printf("%s %s takes at most one 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 tasks/functions that take two numeric arguments. */
|
||||
PLI_INT32 sys_two_numeric_args_compiletf(PLI_BYTE8 *name)
|
||||
{
|
||||
vpiHandle callh = vpi_handle(vpiSysTfCall, 0);
|
||||
vpiHandle argv = vpi_iterate(vpiArgument, callh);
|
||||
vpiHandle arg;
|
||||
|
||||
/* Check that there are two argument and that they are numeric. */
|
||||
if (argv == 0) {
|
||||
vpi_printf("ERROR: %s line %d: ", vpi_get_str(vpiFile, callh),
|
||||
(int)vpi_get(vpiLineNo, callh));
|
||||
vpi_printf("%s requires two numeric arguments.\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 first argument must be numeric.\n", name);
|
||||
vpi_control(vpiFinish, 1);
|
||||
}
|
||||
|
||||
arg = vpi_scan(argv);
|
||||
if (! arg) {
|
||||
vpi_printf("ERROR: %s line %d: ", vpi_get_str(vpiFile, callh),
|
||||
(int)vpi_get(vpiLineNo, callh));
|
||||
vpi_printf("%s requires a second (numeric) argument.\n", name);
|
||||
vpi_control(vpiFinish, 1);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (! is_numeric_obj(arg)) {
|
||||
vpi_printf("ERROR: %s line %d: ", vpi_get_str(vpiFile, callh),
|
||||
(int)vpi_get(vpiLineNo, callh));
|
||||
vpi_printf("%s's second 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 two numeric arguments.\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 tasks/functions that take a single string argument. */
|
||||
PLI_INT32 sys_one_string_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 a string. */
|
||||
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 string argument.\n", name);
|
||||
vpi_control(vpiFinish, 1);
|
||||
return 0;
|
||||
}
|
||||
if (! is_string_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 a string.\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 string argument.\n", msg, name);
|
||||
vpi_printf("%*s Found %u extra argument%s.\n",
|
||||
strlen(msg), " ", argc, argc == 1 ? "" : "s");
|
||||
vpi_control(vpiFinish, 1);
|
||||
|
|
|
|||
|
|
@ -56,5 +56,7 @@ extern vpiHandle sys_func_module(vpiHandle obj);
|
|||
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);
|
||||
extern PLI_INT32 sys_two_numeric_args_compiletf(PLI_BYTE8 *name);
|
||||
extern PLI_INT32 sys_one_string_arg_compiletf(PLI_BYTE8 *name);
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -779,7 +779,7 @@ void sys_vcd_register()
|
|||
tf_data.type = vpiSysTask;
|
||||
tf_data.tfname = "$dumpfile";
|
||||
tf_data.calltf = sys_dumpfile_calltf;
|
||||
tf_data.compiletf = sys_dumpfile_compiletf;
|
||||
tf_data.compiletf = sys_one_string_arg_compiletf;
|
||||
tf_data.sizetf = 0;
|
||||
tf_data.user_data = "$dumpfile";
|
||||
vpi_register_systf(&tf_data);
|
||||
|
|
|
|||
|
|
@ -69,7 +69,7 @@ void sys_vcdoff_register()
|
|||
tf_data.type = vpiSysTask;
|
||||
tf_data.tfname = "$dumpfile";
|
||||
tf_data.calltf = sys_dummy_calltf;
|
||||
tf_data.compiletf = sys_dumpfile_compiletf;
|
||||
tf_data.compiletf = sys_one_string_arg_compiletf;
|
||||
tf_data.sizetf = 0;
|
||||
tf_data.user_data = "$dumpfile";
|
||||
vpi_register_systf(&tf_data);
|
||||
|
|
|
|||
|
|
@ -68,7 +68,7 @@ typedef struct s_single_data {
|
|||
static t_single_data va_single_data[]= {
|
||||
{"$sqrt", sqrt},
|
||||
{"$ln", log},
|
||||
{"$log", log10}, /* FIXME: The $log function is replaced by the
|
||||
{"$log", log10}, /* NOTE: The $log function is replaced by the
|
||||
$log10 function to eliminate confusion with
|
||||
the natural log. In C, "log" is ln and log10
|
||||
is log-base-10. The $log is being left in for
|
||||
|
|
@ -141,8 +141,8 @@ typedef struct {
|
|||
* Standard error message routine. The format string must take one
|
||||
* string argument (the name of the function).
|
||||
*/
|
||||
static void va_error_message(vpiHandle callh, const char* format,
|
||||
const char* name) {
|
||||
static void va_error_message(vpiHandle callh, const char *format,
|
||||
const char *name) {
|
||||
vpi_printf("%s:%d: error: ", vpi_get_str(vpiFile, callh),
|
||||
(int)vpi_get(vpiLineNo, callh));
|
||||
vpi_printf(format, name);
|
||||
|
|
@ -153,8 +153,8 @@ static void va_error_message(vpiHandle callh, const char* format,
|
|||
/*
|
||||
* Process an argument.
|
||||
*/
|
||||
vpiHandle va_process_argument(vpiHandle callh, const char* name,
|
||||
vpiHandle arg, const char* post) {
|
||||
vpiHandle va_process_argument(vpiHandle callh, const char *name,
|
||||
vpiHandle arg, const char *post) {
|
||||
PLI_INT32 type;
|
||||
|
||||
if (arg == NULL) return 0;
|
||||
|
|
@ -178,7 +178,7 @@ vpiHandle va_process_argument(vpiHandle callh, const char* name,
|
|||
/*
|
||||
* Routine to check all the single argument math functions.
|
||||
*/
|
||||
static PLI_INT32 va_single_argument_compiletf(PLI_BYTE8* ud)
|
||||
static PLI_INT32 va_single_argument_compiletf(PLI_BYTE8 *ud)
|
||||
{
|
||||
assert(ud != 0);
|
||||
vpiHandle callh = vpi_handle(vpiSysTfCall, 0);
|
||||
|
|
@ -225,7 +225,7 @@ static PLI_INT32 va_single_argument_compiletf(PLI_BYTE8* ud)
|
|||
/*
|
||||
* Routine to implement the single argument math functions.
|
||||
*/
|
||||
static PLI_INT32 va_single_argument_calltf(PLI_BYTE8* ud)
|
||||
static PLI_INT32 va_single_argument_calltf(PLI_BYTE8 *ud)
|
||||
{
|
||||
vpiHandle callh = vpi_handle(vpiSysTfCall, 0);
|
||||
s_vpi_value val;
|
||||
|
|
@ -249,7 +249,7 @@ static PLI_INT32 va_single_argument_calltf(PLI_BYTE8* ud)
|
|||
/*
|
||||
* Routine to check all the double argument math functions.
|
||||
*/
|
||||
static PLI_INT32 va_double_argument_compiletf(PLI_BYTE8* ud)
|
||||
static PLI_INT32 va_double_argument_compiletf(PLI_BYTE8 *ud)
|
||||
{
|
||||
assert(ud != 0);
|
||||
vpiHandle callh = vpi_handle(vpiSysTfCall, 0);
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@
|
|||
/*
|
||||
* Check that the routines are called with the correct arguments.
|
||||
*/
|
||||
static PLI_INT32 simparam_compiletf(PLI_BYTE8* name_ext)
|
||||
static PLI_INT32 simparam_compiletf(PLI_BYTE8 *name_ext)
|
||||
{
|
||||
vpiHandle callh = vpi_handle(vpiSysTfCall, 0);
|
||||
assert(callh != 0);
|
||||
|
|
@ -104,7 +104,7 @@ static PLI_INT32 simparam_compiletf(PLI_BYTE8* name_ext)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static PLI_INT32 simparam_calltf(PLI_BYTE8* name_ext)
|
||||
static PLI_INT32 simparam_calltf(PLI_BYTE8 *name_ext)
|
||||
{
|
||||
vpiHandle callh = vpi_handle(vpiSysTfCall, 0);
|
||||
vpiHandle argv = vpi_iterate(vpiArgument, callh);
|
||||
|
|
@ -179,7 +179,7 @@ static PLI_INT32 simparam_calltf(PLI_BYTE8* name_ext)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static PLI_INT32 simparam_str_calltf(PLI_BYTE8* name_ext)
|
||||
static PLI_INT32 simparam_str_calltf(PLI_BYTE8 *name_ext)
|
||||
{
|
||||
vpiHandle callh = vpi_handle(vpiSysTfCall, 0);
|
||||
vpiHandle argv = vpi_iterate(vpiArgument, callh);
|
||||
|
|
@ -246,9 +246,9 @@ static PLI_INT32 simparam_str_calltf(PLI_BYTE8* name_ext)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static PLI_INT32 simparam_str_sizetf(PLI_BYTE8* name_ext)
|
||||
static PLI_INT32 simparam_str_sizetf(PLI_BYTE8 *name_ext)
|
||||
{
|
||||
(void) name_ext; //* Not used! */
|
||||
(void) name_ext; /* Not used! */
|
||||
|
||||
return MAX_STRING_RESULT; // 128 characters max!
|
||||
}
|
||||
|
|
|
|||
|
|
@ -189,49 +189,9 @@ 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. Some are generic enough they can use
|
||||
* the ones in sys_priv.c (no arg, one numeric arg.
|
||||
* the ones in sys_priv.c (no arg, one numeric argument, etc.).
|
||||
*/
|
||||
|
||||
/* $dumpfile takes a single string argument. */
|
||||
PLI_INT32 sys_dumpfile_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 a string. */
|
||||
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 string argument.\n", name);
|
||||
vpi_control(vpiFinish, 1);
|
||||
return 0;
|
||||
}
|
||||
if (! is_string_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 a string.\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 string 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;
|
||||
}
|
||||
|
||||
/* $dumpvars takes a variety of arguments. */
|
||||
PLI_INT32 sys_dumpvars_compiletf(PLI_BYTE8 *name)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -44,7 +44,6 @@ 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_dumpfile_compiletf(PLI_BYTE8 *name);
|
||||
extern PLI_INT32 sys_dumpvars_compiletf(PLI_BYTE8 *name);
|
||||
|
||||
#endif
|
||||
|
|
|
|||
Loading…
Reference in New Issue