From 963b0c59527bdcedad9e3083a048076b93a3c53b Mon Sep 17 00:00:00 2001 From: steve Date: Thu, 13 Mar 2003 04:35:09 +0000 Subject: [PATCH] Add a bunch of new acc_ and tf_ functions. --- acc_user.h | 16 +++++++++- libveriuser/Makefile.in | 9 +++--- libveriuser/a_fetch_param.c | 51 ++++++++++++++++++++++++++++++++ libveriuser/a_fetch_tfarg.c | 10 +++++-- libveriuser/a_fetch_time.c | 40 +++++++++++++++++++++++++ libveriuser/a_fetch_type.c | 8 ++++- libveriuser/a_fetch_type_str.c | 8 ++++- libveriuser/a_handle_object.c | 42 ++++++++++++++++++++++++++ libveriuser/a_handle_parent.c | 43 +++++++++++++++++++++++++++ libveriuser/getcstringp.c | 8 +++-- libveriuser/getsimtime.c | 11 ++++++- libveriuser/spname.c | 42 ++++++++++++++++++++++++++ veriuser.h | 54 +++++++--------------------------- 13 files changed, 286 insertions(+), 56 deletions(-) create mode 100644 libveriuser/a_fetch_param.c create mode 100644 libveriuser/a_fetch_time.c create mode 100644 libveriuser/a_handle_object.c create mode 100644 libveriuser/a_handle_parent.c create mode 100644 libveriuser/spname.c diff --git a/acc_user.h b/acc_user.h index 91555fcaf..10312cd5e 100644 --- a/acc_user.h +++ b/acc_user.h @@ -19,7 +19,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ #ifdef HAVE_CVS_IDENT -#ident "$Id: acc_user.h,v 1.7 2003/02/17 06:39:47 steve Exp $" +#ident "$Id: acc_user.h,v 1.8 2003/03/13 04:35:09 steve Exp $" #endif /* @@ -141,12 +141,23 @@ extern int acc_fetch_location(p_location loc, handle obj); extern char* acc_fetch_name(handle obj); +extern double acc_fetch_paramval(handle obj); + extern int acc_fetch_tfarg_int(int n); extern char* acc_fetch_tfarg_str(int n); +typedef struct t_timescale_info { + PLI_INT16 unit; + PLI_INT16 precision; +} s_timescale_info, *p_timescale_info; +extern void acc_fetch_timescale_info(handle obj, p_timescale_info info); + extern PLI_INT32 acc_fetch_type(handle obj); extern char* acc_fetch_type_str(PLI_INT32 type); +extern handle acc_handle_object(const char*name); +extern handle acc_handle_parent(handle obj); + extern handle acc_handle_tfarg(int n); extern handle acc_handle_tfinst(void); @@ -166,6 +177,9 @@ EXTERN_C_END /* * $Log: acc_user.h,v $ + * Revision 1.8 2003/03/13 04:35:09 steve + * Add a bunch of new acc_ and tf_ functions. + * * Revision 1.7 2003/02/17 06:39:47 steve * Add at least minimal implementations for several * acc_ functions. Add support for standard ACC diff --git a/libveriuser/Makefile.in b/libveriuser/Makefile.in index 1305fbe5a..234335cb8 100644 --- a/libveriuser/Makefile.in +++ b/libveriuser/Makefile.in @@ -16,7 +16,7 @@ # 59 Temple Place - Suite 330 # Boston, MA 02111-1307, USA # -#ident "$Id: Makefile.in,v 1.18 2003/02/27 22:13:22 steve Exp $" +#ident "$Id: Makefile.in,v 1.19 2003/03/13 04:35:09 steve Exp $" # # SHELL = /bin/sh @@ -46,13 +46,14 @@ STRIP = @STRIP@ RANLIB = @RANLIB@ A = a_close.o a_configure.o a_fetch_argc.o a_fetch_argv.o a_fetch_fullname.o \ -a_fetch_location.o a_fetch_tfarg.o a_fetch_type.o a_fetch_type_str.o \ -a_handle_tfarg.o \ +a_fetch_location.o a_fetch_param.o a_fetch_tfarg.o a_fetch_time.o \ +a_fetch_type.o \ +a_fetch_type_str.o a_handle_object.o a_handle_parent.o a_handle_tfarg.o \ a_initialize.o a_next_topmod.o a_object_of_type.o a_product_version.o \ a_set_value.o a_version.o O = asynch.o finish.o getcstringp.o getinstance.o getlongp.o \ getp.o getsimtime.o io_print.o mc_scan_plusargs.o nump.o putlongp.o \ -putp.o typep.o workarea.o veriusertfs.o priv.o $A +putp.o spname.o typep.o workarea.o veriusertfs.o priv.o $A all: dep libveriuser.a diff --git a/libveriuser/a_fetch_param.c b/libveriuser/a_fetch_param.c new file mode 100644 index 000000000..73b39dcb3 --- /dev/null +++ b/libveriuser/a_fetch_param.c @@ -0,0 +1,51 @@ +/* + * Copyright (c) 2003 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 + * General Public License as published by the Free Software + * Foundation; either version 2 of the License, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * 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: a_fetch_param.c,v 1.1 2003/03/13 04:35:09 steve Exp $" +#endif + +#include +#include +#include + +double acc_fetch_paramval(handle object) +{ + s_vpi_value val; + + val.format = vpiObjTypeVal; + vpi_get_value(object, &val); + + switch (val.format) { + + case vpiStringVal: + return (double) (long)val.value.str; + + default: + assert(0); + return 0.0; + } +} + +/* + * $Log: a_fetch_param.c,v $ + * Revision 1.1 2003/03/13 04:35:09 steve + * Add a bunch of new acc_ and tf_ functions. + * + */ + diff --git a/libveriuser/a_fetch_tfarg.c b/libveriuser/a_fetch_tfarg.c index 2a3c56830..43412085d 100644 --- a/libveriuser/a_fetch_tfarg.c +++ b/libveriuser/a_fetch_tfarg.c @@ -17,7 +17,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ #ifdef HAVE_CVS_IDENT -#ident "$Id: a_fetch_tfarg.c,v 1.3 2003/02/17 06:39:47 steve Exp $" +#ident "$Id: a_fetch_tfarg.c,v 1.4 2003/03/13 04:35:09 steve Exp $" #endif #include @@ -55,17 +55,20 @@ char *acc_fetch_tfarg_str(int n) vpiHandle sys_h, sys_i, arg_h = 0; s_vpi_value value; char *rtn; + int idx = n; sys_h = vpi_handle(vpiSysTfCall, 0); sys_i = vpi_iterate(vpiArgument, sys_h); /* scan to nth argument */ - while (n > 0 && (arg_h = vpi_scan(sys_i))) n--; + while (idx > 0 && (arg_h = vpi_scan(sys_i))) + idx -= 1; if (arg_h) { value.format=vpiStringVal; vpi_get_value(arg_h, &value); rtn = __acc_newstring(value.value.str); + vpi_free_object(sys_i); } else { rtn = (char *) 0; } @@ -75,6 +78,9 @@ char *acc_fetch_tfarg_str(int n) /* * $Log: a_fetch_tfarg.c,v $ + * Revision 1.4 2003/03/13 04:35:09 steve + * Add a bunch of new acc_ and tf_ functions. + * * Revision 1.3 2003/02/17 06:39:47 steve * Add at least minimal implementations for several * acc_ functions. Add support for standard ACC diff --git a/libveriuser/a_fetch_time.c b/libveriuser/a_fetch_time.c new file mode 100644 index 000000000..236b86665 --- /dev/null +++ b/libveriuser/a_fetch_time.c @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2003 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 + * General Public License as published by the Free Software + * Foundation; either version 2 of the License, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * 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: a_fetch_time.c,v 1.1 2003/03/13 04:35:09 steve Exp $" +#endif + + +#include +#include +#include "priv.h" + +void acc_fetch_timescale_info(handle obj, p_timescale_info info) +{ + info->precision = vpi_get(vpiTimePrecision, 0); + info->unit = vpi_get(vpiTimeUnit, obj); +} + +/* + * $Log: a_fetch_time.c,v $ + * Revision 1.1 2003/03/13 04:35:09 steve + * Add a bunch of new acc_ and tf_ functions. + * + */ + diff --git a/libveriuser/a_fetch_type.c b/libveriuser/a_fetch_type.c index 8cb39ae31..483196e6f 100644 --- a/libveriuser/a_fetch_type.c +++ b/libveriuser/a_fetch_type.c @@ -17,7 +17,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ #ifdef HAVE_CVS_IDENT -#ident "$Id: a_fetch_type.c,v 1.1 2003/02/17 06:39:47 steve Exp $" +#ident "$Id: a_fetch_type.c,v 1.2 2003/03/13 04:35:09 steve Exp $" #endif # include @@ -34,6 +34,9 @@ PLI_INT32 acc_fetch_type(handle obj) case vpiNet: return accNet; + case vpiParameter: + return accParameter; + case vpiReg: return accReg; @@ -48,6 +51,9 @@ PLI_INT32 acc_fetch_type(handle obj) /* * $Log: a_fetch_type.c,v $ + * Revision 1.2 2003/03/13 04:35:09 steve + * Add a bunch of new acc_ and tf_ functions. + * * Revision 1.1 2003/02/17 06:39:47 steve * Add at least minimal implementations for several * acc_ functions. Add support for standard ACC diff --git a/libveriuser/a_fetch_type_str.c b/libveriuser/a_fetch_type_str.c index 912791b66..a9f7b515f 100644 --- a/libveriuser/a_fetch_type_str.c +++ b/libveriuser/a_fetch_type_str.c @@ -17,7 +17,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ #ifdef HAVE_CVS_IDENT -#ident "$Id: a_fetch_type_str.c,v 1.2 2003/02/19 04:37:04 steve Exp $" +#ident "$Id: a_fetch_type_str.c,v 1.3 2003/03/13 04:35:09 steve Exp $" #endif #include @@ -27,6 +27,9 @@ char* acc_fetch_type_str(PLI_INT32 type) { switch (type) { + case accReg: + return "accReg"; + case accParameter: return "accParameter"; @@ -43,6 +46,9 @@ char* acc_fetch_type_str(PLI_INT32 type) /* * $Log: a_fetch_type_str.c,v $ + * Revision 1.3 2003/03/13 04:35:09 steve + * Add a bunch of new acc_ and tf_ functions. + * * Revision 1.2 2003/02/19 04:37:04 steve * fullname for accConstant. * diff --git a/libveriuser/a_handle_object.c b/libveriuser/a_handle_object.c new file mode 100644 index 000000000..f10bb0f17 --- /dev/null +++ b/libveriuser/a_handle_object.c @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2003 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 + * General Public License as published by the Free Software + * Foundation; either version 2 of the License, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * 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: a_handle_object.c,v 1.1 2003/03/13 04:35:09 steve Exp $" +#endif + +#include +#include +#include "priv.h" + +handle acc_handle_object(const char*name) +{ + vpiHandle sys = vpi_handle(vpiSysTfCall, 0); + vpiHandle scope = vpi_handle(vpiScope, sys); + + vpiHandle res = vpi_handle_by_name(name, scope); + return res; +} + +/* + * $Log: a_handle_object.c,v $ + * Revision 1.1 2003/03/13 04:35:09 steve + * Add a bunch of new acc_ and tf_ functions. + * + */ + diff --git a/libveriuser/a_handle_parent.c b/libveriuser/a_handle_parent.c new file mode 100644 index 000000000..01506e211 --- /dev/null +++ b/libveriuser/a_handle_parent.c @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2003 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 + * General Public License as published by the Free Software + * Foundation; either version 2 of the License, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * 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: a_handle_parent.c,v 1.1 2003/03/13 04:35:09 steve Exp $" +#endif + +#include +#include +#include "priv.h" + +handle acc_handle_parent(handle obj) +{ + vpiHandle scope = vpi_handle(vpiScope, obj); + + while (scope && (vpi_get(vpiType, scope) != vpiModule)) + scope = vpi_handle(vpiScope, scope); + + return scope; +} + +/* + * $Log: a_handle_parent.c,v $ + * Revision 1.1 2003/03/13 04:35:09 steve + * Add a bunch of new acc_ and tf_ functions. + * + */ + diff --git a/libveriuser/getcstringp.c b/libveriuser/getcstringp.c index 0450ec0f6..cd6df20fc 100644 --- a/libveriuser/getcstringp.c +++ b/libveriuser/getcstringp.c @@ -17,7 +17,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ #ifdef HAVE_CVS_IDENT -#ident "$Id: getcstringp.c,v 1.2 2002/08/12 01:35:02 steve Exp $" +#ident "$Id: getcstringp.c,v 1.3 2003/03/13 04:35:09 steve Exp $" #endif #include @@ -28,11 +28,15 @@ */ char *tf_getcstringp(int n) { - return acc_fetch_tfarg_str(n); + char*res = acc_fetch_tfarg_str(n); + return res; } /* * $Log: getcstringp.c,v $ + * Revision 1.3 2003/03/13 04:35:09 steve + * Add a bunch of new acc_ and tf_ functions. + * * Revision 1.2 2002/08/12 01:35:02 steve * conditional ident string using autoconfig. * diff --git a/libveriuser/getsimtime.c b/libveriuser/getsimtime.c index 87409bd74..7d2c2cbaf 100644 --- a/libveriuser/getsimtime.c +++ b/libveriuser/getsimtime.c @@ -17,9 +17,10 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ #ifdef HAVE_CVS_IDENT -#ident "$Id: getsimtime.c,v 1.3 2003/03/06 00:27:54 steve Exp $" +#ident "$Id: getsimtime.c,v 1.4 2003/03/13 04:35:09 steve Exp $" #endif +#include #include /* @@ -38,8 +39,16 @@ int tf_getlongtime(int *hightime) int tf_getlongsimtime(int *hightime) \ __attribute__ ((weak, alias ("tf_getlongtime"))); +PLI_INT32 tf_igettimeprecision(void*obj) +{ + return vpi_get(vpiTimePrecision, 0); +} + /* * $Log: getsimtime.c,v $ + * Revision 1.4 2003/03/13 04:35:09 steve + * Add a bunch of new acc_ and tf_ functions. + * * Revision 1.3 2003/03/06 00:27:54 steve * Fill in required fields when getting time. * diff --git a/libveriuser/spname.c b/libveriuser/spname.c new file mode 100644 index 000000000..17658a714 --- /dev/null +++ b/libveriuser/spname.c @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2003 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 + * General Public License as published by the Free Software + * Foundation; either version 2 of the License, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * 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: spname.c,v 1.1 2003/03/13 04:35:09 steve Exp $" +#endif + +#include +#include +#include +#include "priv.h" + +char* tf_spname(void) +{ + vpiHandle sys = vpi_handle(vpiSysTfCall, 0); + vpiHandle scope = vpi_handle(vpiScope, sys); + + return __acc_newstring(vpi_get_str(vpiFullName, scope)); +} + +/* + * $Log: spname.c,v $ + * Revision 1.1 2003/03/13 04:35:09 steve + * Add a bunch of new acc_ and tf_ functions. + * + */ + diff --git a/veriuser.h b/veriuser.h index 6ba7bc0ae..030358aaa 100644 --- a/veriuser.h +++ b/veriuser.h @@ -19,7 +19,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ #ifdef HAVE_CVS_IDENT -#ident "$Id: veriuser.h,v 1.21 2003/02/26 01:25:51 steve Exp $" +#ident "$Id: veriuser.h,v 1.22 2003/03/13 04:35:09 steve Exp $" #endif /* @@ -251,6 +251,9 @@ extern int tf_getlongtime(int*high_bits); extern int tf_getp(int pnum); +extern PLI_INT32 tf_gettimeprecision(void); +extern PLI_INT32 tf_igettimeprecision(void*); + extern PLI_BYTE8* tf_getworkarea(void); extern PLI_INT32 tf_message(PLI_INT32 level, char*facility, @@ -271,6 +274,9 @@ extern void tf_putp(int pnum, int value); compatible with those who pass a PLI_BYTE8*. */ extern PLI_INT32 tf_setworkarea(void*workarea); +/* Return the complete, hierarchical name of the current scope. The + current scope is the scope containing the currently running system + task call. */ extern char* tf_spname(void); extern PLI_INT32 tf_typep(PLI_INT32 narg); @@ -282,6 +288,9 @@ EXTERN_C_END /* * $Log: veriuser.h,v $ + * Revision 1.22 2003/03/13 04:35:09 steve + * Add a bunch of new acc_ and tf_ functions. + * * Revision 1.21 2003/02/26 01:25:51 steve * Document new PLI1 bootstrap interface. * @@ -309,48 +318,5 @@ EXTERN_C_END * * Revision 1.15 2002/06/07 16:21:12 steve * Add tf_putlongp and tf_putp. - * - * Revision 1.14 2002/06/07 02:58:58 steve - * Add a bunch of acc/tf functions. (mruff) - * - * Revision 1.13 2002/06/04 01:42:58 steve - * Add misctf support to libveriuser - * - * Revision 1.12 2002/06/03 21:52:59 steve - * Fix return type of tf_getinstance. - * - * Revision 1.11 2002/06/03 00:08:42 steve - * Better typing for veriusertfs table. - * - * Revision 1.10 2002/06/02 18:54:59 steve - * Add tf_getinstance function. - * - * Revision 1.9 2002/05/31 18:25:51 steve - * Add tf_getlongtime (mruff) - * - * Revision 1.8 2002/05/31 04:26:44 steve - * Call padding reserved. - * - * Revision 1.7 2002/05/30 02:37:26 steve - * Add the veriusertf_register funciton. - * - * Revision 1.6 2002/05/30 02:12:17 steve - * Add tf_nump from mruff. - * - * Revision 1.5 2002/05/30 02:10:08 steve - * Add tf_error and tf_warning from mruff - * - * Revision 1.4 2002/05/24 20:29:07 steve - * Implement mc_scan_plusargs. - * - * Revision 1.3 2002/05/24 19:05:30 steve - * support GCC __attributes__ for printf formats. - * - * Revision 1.2 2002/05/23 03:35:42 steve - * Add the io_printf function to libveriuser. - * - * Revision 1.1 2002/05/19 05:21:00 steve - * Start the libveriuser library. - * */ #endif