From d134f6f074b74bb5716f997b52da53c89bfeea00 Mon Sep 17 00:00:00 2001 From: Cary R Date: Fri, 21 Nov 2008 17:11:25 -0800 Subject: [PATCH] V0.8: fix $ungetc argument order. This patch mirrors what was done in development to fix $ungetc. --- vpi/sys_fileio.c | 37 +++++++++++++++++++++++-------------- 1 file changed, 23 insertions(+), 14 deletions(-) diff --git a/vpi/sys_fileio.c b/vpi/sys_fileio.c index c6ae4cbae..f7e1a0f7a 100644 --- a/vpi/sys_fileio.c +++ b/vpi/sys_fileio.c @@ -334,7 +334,7 @@ static PLI_INT32 sys_ungetc_compiletf(char*name) vpiHandle item = vpi_scan(argv); if (item == 0) { - vpi_printf("%s: mcd parameter missing.\n", name); + vpi_printf("%s: charater parameter missing.\n", name); return 0; } @@ -351,22 +351,38 @@ static PLI_INT32 sys_ungetc_compiletf(char*name) return 0; } + item = vpi_scan(argv); + type = vpi_get(vpiType, item); + switch (type) { + case vpiReg: + case vpiRealVal: + case vpiIntegerVar: + break; + default: + vpi_printf("ERROR: %s mcd parameter must be of integral", name); + vpi_printf(", got vpiType=%d\n", type); + vpi_free_object(argv); + return 0; + } + return 0; } static PLI_INT32 sys_ungetc_calltf(char *name) { unsigned int mcd; - unsigned char x; - s_vpi_value value, xvalue, rval; + unsigned char chr; + s_vpi_value value, rval; vpiHandle sys = vpi_handle(vpiSysTfCall, 0); vpiHandle argv = vpi_iterate(vpiArgument, sys); vpiHandle item = vpi_scan(argv); FILE *fp; - rval.format = vpiIntVal; + value.format = vpiIntVal; + vpi_get_value(item, &value); + chr = value.value.integer; - assert(item); + item = vpi_scan(argv); value.format = vpiIntVal; vpi_get_value(item, &value); @@ -378,12 +394,6 @@ static PLI_INT32 sys_ungetc_calltf(char *name) return 0; } - item = vpi_scan(argv); - - xvalue.format = vpiIntVal; - vpi_get_value(item, &xvalue); - x = xvalue.value.integer; - fp = vpi_get_file(mcd); if ( !fp ) { rval.value.integer = EOF; @@ -391,9 +401,8 @@ static PLI_INT32 sys_ungetc_calltf(char *name) return 0; } - ungetc(x, fp); - - rval.value.integer = 0; + rval.format = vpiIntVal; + rval.value.integer = ungetc(chr, fp); vpi_put_value(sys, &rval, 0, vpiNoDelay); return 0; }