Add a bunch of acc/tf functions. (mruff)

This commit is contained in:
steve 2002-06-07 02:58:58 +00:00
parent 4fed9d6532
commit d6b5c67313
10 changed files with 576 additions and 8 deletions

View File

@ -19,7 +19,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/ */
#if !defined(WINNT) && !defined(macintosh) #if !defined(WINNT) && !defined(macintosh)
#ident "$Id: acc_user.h,v 1.3 2002/06/02 19:03:29 steve Exp $" #ident "$Id: acc_user.h,v 1.4 2002/06/07 02:58:58 steve Exp $"
#endif #endif
/* /*
@ -48,22 +48,92 @@ EXTERN_C_START
*/ */
typedef struct __vpiHandle *handle; typedef struct __vpiHandle *handle;
/* OBJECT TYPES */
#define accScope 21
#define accScalar 300
#define accVector 302
/* type VALUES FOR t_setval_delay STRUCTURE */
#define accNoDelay 0
#define accInertialDelay 1
#define accTransportDelay 2
#define accPureTransportDelay 3
#define accForceFlag 4
#define accReleaseFlag 5
/* type VALUES FOR t_setval_value STRUCTURE */
#define accBinStrVal 1
#define accOctStrVal 2
#define accDecStrVal 3
#define accHexStrVal 4
#define accScalarVal 5
#define accIntVal 6
#define accRealVal 7
#define accStringVal 8
#define accVectorVal 9
/* type VALUES FOR t_acc_time STRUCTURE */
#define accTime 1
#define accSimTime 2
#define accRealTime 3
typedef struct t_acc_time {
int type;
int low, high;
double real;
} s_acc_time, *p_acc_time;
typedef struct t_setval_delay {
s_acc_time time;
int model;
} s_setval_delay, *p_setval_delay;
typedef struct t_acc_vecval {
int aval;
int bval;
} s_acc_vecval, *p_acc_vecval;
typedef struct t_setval_value {
int format;
union {
char*str;
int scalar;
int integer;
double real;
p_acc_vecval vector;
} value;
} s_setval_value, *p_setval_value, s_acc_value, *p_acc_value;
extern int acc_error_flag; extern int acc_error_flag;
extern int acc_initialize(void); extern int acc_initialize(void);
extern void acc_close(void); extern void acc_close(void);
extern char* acc_fetch_fullname(handle obj);
extern int acc_fetch_tfarg_int(int n);
extern char* acc_fetch_tfarg_str(int n);
extern handle acc_handle_tfarg(int n); extern handle acc_handle_tfarg(int n);
extern handle add_next_topmod(handle prev_topmod); extern handle acc_next_topmod(handle prev_topmod);
extern int acc_object_of_type(handle object, int type);
extern char*acc_product_version(void); extern char*acc_product_version(void);
extern int acc_set_value(handle obj, p_setval_value value,
p_setval_delay delay);
EXTERN_C_END EXTERN_C_END
/* /*
* $Log: acc_user.h,v $ * $Log: acc_user.h,v $
* Revision 1.4 2002/06/07 02:58:58 steve
* Add a bunch of acc/tf functions. (mruff)
*
* Revision 1.3 2002/06/02 19:03:29 steve * Revision 1.3 2002/06/02 19:03:29 steve
* Add acc_handle_tfarg and acc_next_topmode * Add acc_handle_tfarg and acc_next_topmode
* *

View File

@ -16,7 +16,7 @@
# 59 Temple Place - Suite 330 # 59 Temple Place - Suite 330
# Boston, MA 02111-1307, USA # Boston, MA 02111-1307, USA
# #
#ident "$Id: Makefile.in,v 1.11 2002/06/04 01:40:03 steve Exp $" #ident "$Id: Makefile.in,v 1.12 2002/06/07 02:58:58 steve Exp $"
# #
# #
SHELL = /bin/sh SHELL = /bin/sh
@ -44,10 +44,11 @@ CFLAGS = @CFLAGS@
LDFLAGS = @LDFLAGS@ LDFLAGS = @LDFLAGS@
STRIP = @STRIP@ STRIP = @STRIP@
A = a_close.o a_handle_tfarg.o a_initialize.o a_next_topmod.o \ A = a_close.o a_fetch_fullname.o a_fetch_tfarg.o a_handle_tfarg.o \
a_product_version.o a_initialize.o a_next_topmod.o a_object_of_type.o a_product_version.o \
O = asynch.o finish.o getinstance.o getsimtime.o io_print.o \ a_set_value.o
mc_scan_plusargs.o nump.o veriusertfs.o $A O = asynch.o finish.o getcstringp.o getinstance.o getlongp.o \
getp.o getsimtime.o io_print.o mc_scan_plusargs.o nump.o veriusertfs.o $A
all: libveriuser.a all: libveriuser.a

View File

@ -0,0 +1,39 @@
/* vi:sw=6
* Copyright (c) 2002 Michael Ruff (mruff at chiaro.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
*/
#if !defined(WINNT)
#ident "$Id: a_fetch_fullname.c,v 1.1 2002/06/07 02:58:58 steve Exp $"
#endif
#include <vpi_user.h>
#include <acc_user.h>
/*
* acc_fetch_fullname implemented using VPI interface
*/
char *acc_fetch_fullname(handle object)
{
return vpi_get_str(vpiFullName, object);
}
/*
* $Log: a_fetch_fullname.c,v $
* Revision 1.1 2002/06/07 02:58:58 steve
* Add a bunch of acc/tf functions. (mruff)
*
*/

View File

@ -0,0 +1,80 @@
/* vi:sw=6
* Copyright (c) 2002 Michael Ruff (mruff at chiaro.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
*/
#if !defined(WINNT)
#ident "$Id: a_fetch_tfarg.c,v 1.1 2002/06/07 02:58:58 steve Exp $"
#endif
#include <vpi_user.h>
#include <acc_user.h>
/*
* acc_fetch_tfarg routines implemented using VPI interface
*/
int acc_fetch_tfarg_int(int n)
{
vpiHandle sys_h, sys_i, arg_h = 0;
s_vpi_value value;
int rtn;
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--;
if (arg_h) {
value.format=vpiIntVal;
vpi_get_value(arg_h, &value);
rtn = value.value.integer;
} else {
rtn = 0;
}
return rtn;
}
char *acc_fetch_tfarg_str(int n)
{
vpiHandle sys_h, sys_i, arg_h = 0;
s_vpi_value value;
char *rtn;
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--;
if (arg_h) {
value.format=vpiStringVal;
vpi_get_value(arg_h, &value);
rtn = value.value.str;
} else {
rtn = (char *) 0;
}
return rtn;
}
/*
* $Log: a_fetch_tfarg.c,v $
* Revision 1.1 2002/06/07 02:58:58 steve
* Add a bunch of acc/tf functions. (mruff)
*
*/

View File

@ -0,0 +1,65 @@
/* vi:sw=6
* Copyright (c) 2002 Michael Ruff (mruff at chiaro.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
*/
#if !defined(WINNT)
#ident "$Id: a_object_of_type.c,v 1.1 2002/06/07 02:58:58 steve Exp $"
#endif
#include <assert.h>
#include <vpi_user.h>
#include <acc_user.h>
/*
* acc_object_of_type implemented using VPI interface
*/
int acc_object_of_type(handle object, int type)
{
int vtype;
int rtn = 0; /* false */
/* get VPI type of object */
vtype = vpi_get(vpiType, object);
switch (type) {
case accScope:
if (vtype == vpiModule || vtype == vpiNamedBegin ||
vtype == vpiNamedFork || vtype == vpiTask ||
vtype == vpiFunction) rtn = 1;
break;
case accScalar:
if (vtype == vpiReg || vtype == vpiNet)
rtn = vpi_get(vpiSize, object) == 1;
break;
case accVector:
if (vtype == vpiReg || vtype == vpiNet)
rtn = vpi_get(vpiSize, object) > 1;
break;
default:
vpi_printf("acc_object_of_type: Unknown type %d\n", type);
assert(0);
}
return rtn;
}
/*
* $Log: a_object_of_type.c,v $
* Revision 1.1 2002/06/07 02:58:58 steve
* Add a bunch of acc/tf functions. (mruff)
*
*/

118
libveriuser/a_set_value.c Normal file
View File

@ -0,0 +1,118 @@
/* vi:sw=6
* Copyright (c) 2002 Michael Ruff (mruff at chiaro.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
*/
#if !defined(WINNT)
#ident "$Id: a_set_value.c,v 1.1 2002/06/07 02:58:59 steve Exp $"
#endif
#include <assert.h>
#include <acc_user.h>
#include <vpi_user.h>
/*
* acc_set_value implemented using VPI interface
*/
int acc_set_value(handle object, p_setval_value value, p_setval_delay delay)
{
s_vpi_time when, *whenp;
s_vpi_value val;
int flags;
assert(delay);
assert(value);
assert(object);
/* map setval_delay.model to flags */
switch (delay->model) {
case accNoDelay: flags = vpiNoDelay; break;
case accInertialDelay: flags = vpiInertialDelay; break;
case accTransportDelay: flags = vpiTransportDelay; break;
case accPureTransportDelay: flags = vpiPureTransportDelay; break;
case accForceFlag: flags = vpiForceFlag; break;
case accReleaseFlag: flags = vpiReleaseFlag; break;
default: assert(0); break;
}
/* map acc_time to vpi_time */
if (delay->model != accNoDelay) {
switch (delay->time.type) {
case accSimTime: when.type = vpiSimTime; break;
case accRealTime: when.type = vpiScaledRealTime; break;
default: assert(0); break;
}
when.high = delay->time.high;
when.low = delay->time.low;
when.real = delay->time.real;
whenp = &when;
} else
whenp = 0;
/* map setval_value to vpi_value and flags */
switch (value->format) {
case accBinStrVal:
val.format = vpiBinStrVal;
val.value.str = value->value.str;
break;
case accOctStrVal:
val.format = vpiOctStrVal;
val.value.str = value->value.str;
break;
case accDecStrVal:
val.format = vpiDecStrVal;
val.value.str = value->value.str;
break;
case accHexStrVal:
val.format = vpiHexStrVal;
val.value.str = value->value.str;
break;
case accScalarVal:
val.format = vpiScalarVal;
val.value.scalar = value->value.scalar;
break;
case accIntVal:
val.format = vpiIntVal;
val.value.integer = value->value.integer;
break;
case accRealVal:
val.format = vpiRealVal;
val.value.real = value->value.real;
break;
case accStringVal:
val.format = vpiStringVal;
val.value.str = value->value.str;
break;
case accVectorVal:
val.format = vpiVectorVal;
val.value.vector = (p_vpi_vecval)value->value.vector;
break;
default: assert(0); break;
}
/* put value */
vpi_put_value(object, &val, whenp, flags);
return 1;
}
/*
* $Log: a_set_value.c,v $
* Revision 1.1 2002/06/07 02:58:59 steve
* Add a bunch of acc/tf functions. (mruff)
*
*/

39
libveriuser/getcstringp.c Normal file
View File

@ -0,0 +1,39 @@
/* vi:sw=6
* Copyright (c) 2002 Michael Ruff (mruff at chiaro.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
*/
#if !defined(WINNT)
#ident "$Id: getcstringp.c,v 1.1 2002/06/07 02:58:59 steve Exp $"
#endif
#include <veriuser.h>
#include <acc_user.h>
/*
* tf_getinstance implemented using equvalent acc_ routing
*/
char *tf_getcstringp(int n)
{
return acc_fetch_tfarg_str(n);
}
/*
* $Log: getcstringp.c,v $
* Revision 1.1 2002/06/07 02:58:59 steve
* Add a bunch of acc/tf functions. (mruff)
*
*/

78
libveriuser/getlongp.c Normal file
View File

@ -0,0 +1,78 @@
/* vi:sw=6
* Copyright (c) 2002 Michael Ruff (mruff at chiaro.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
*/
#if !defined(WINNT)
#ident "$Id: getlongp.c,v 1.1 2002/06/07 02:58:59 steve Exp $"
#endif
#include <stdlib.h>
#include <string.h>
#include <assert.h>
#include <veriuser.h>
#include <vpi_user.h>
/*
* tf_getlongp implemented using VPI interface
*/
int tf_getlongp(int *highvalue, int n)
{
vpiHandle sys_h, sys_i, arg_h = 0;
s_vpi_value value;
int len, rtn;
char *str, **end = 0;
assert(highvalue);
assert(n > 0);
/* get task/func handle */
sys_h = vpi_handle(vpiSysTfCall, 0);
sys_i = vpi_iterate(vpiArgument, sys_h);
/* find nth arg */
while (n > 0) {
if (!(arg_h = vpi_scan(sys_i))) assert(0);
n--;
}
/* get the value */
value.format = vpiHexStrVal;
vpi_get_value(arg_h, &value);
/* convert string to int(s) */
len = strlen(value.value.str);
if (len > 8) {
/* low word */
str = value.value.str + (len - 8);
rtn = (int) strtoul(str, end, 16);
/* high word */
*str = '\0';
*highvalue = (int) strtoul(value.value.str, end, 16);
} else {
*highvalue = 0;
rtn = (int) strtoul(value.value.str, end, 16);
}
return rtn;
}
/*
* $Log: getlongp.c,v $
* Revision 1.1 2002/06/07 02:58:59 steve
* Add a bunch of acc/tf functions. (mruff)
*
*/

69
libveriuser/getp.c Normal file
View File

@ -0,0 +1,69 @@
/* vi:sw=6
* Copyright (c) 2002 Michael Ruff (mruff at chiaro.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
*/
#if !defined(WINNT)
#ident "$Id: getp.c,v 1.1 2002/06/07 02:58:59 steve Exp $"
#endif
#include <assert.h>
#include <veriuser.h>
#include <vpi_user.h>
/*
* tf_getp implemented using VPI interface
*/
int tf_getp(int n)
{
vpiHandle sys_h, sys_i, arg_h = 0;
s_vpi_value value;
int rtn;
assert(n > 0);
/* get task/func handle */
sys_h = vpi_handle(vpiSysTfCall, 0);
sys_i = vpi_iterate(vpiArgument, sys_h);
/* find nth arg */
while (n > 0) {
if (!(arg_h = vpi_scan(sys_i))) assert(0);
n--;
}
/* If it is a constant string, return a pointer to it else int value */
if (vpi_get(vpiType, arg_h) == vpiConstant &&
vpi_get(vpiConstType, arg_h) == vpiStringConst)
{
value.format = vpiStringVal;
vpi_get_value(arg_h, &value);
rtn = (int) value.value.str; /* Oh my */
} else {
value.format = vpiIntVal;
vpi_get_value(arg_h, &value);
rtn = value.value.integer;
}
return rtn;
}
/*
* $Log: getp.c,v $
* Revision 1.1 2002/06/07 02:58:59 steve
* Add a bunch of acc/tf functions. (mruff)
*
*/

View File

@ -19,7 +19,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/ */
#if !defined(WINNT) && !defined(macintosh) #if !defined(WINNT) && !defined(macintosh)
#ident "$Id: veriuser.h,v 1.13 2002/06/04 01:42:58 steve Exp $" #ident "$Id: veriuser.h,v 1.14 2002/06/07 02:58:58 steve Exp $"
#endif #endif
/* /*
@ -104,10 +104,16 @@ extern int tf_dostop(void);
extern void tf_error(const char*, ...) extern void tf_error(const char*, ...)
__attribute__((format (printf,1,2))); __attribute__((format (printf,1,2)));
extern char* tf_getcstringp(int nparam);
extern char* tf_getinstance(void); extern char* tf_getinstance(void);
extern int tf_getlongp(int*aof_highvalue, int pnum);
extern int tf_getlongtime(int*high_bits); extern int tf_getlongtime(int*high_bits);
extern int tf_getp(int pnum);
extern int tf_nump(void); extern int tf_nump(void);
extern void tf_warning(const char*, ...) extern void tf_warning(const char*, ...)
@ -117,6 +123,9 @@ EXTERN_C_END
/* /*
* $Log: veriuser.h,v $ * $Log: veriuser.h,v $
* 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 * Revision 1.13 2002/06/04 01:42:58 steve
* Add misctf support to libveriuser * Add misctf support to libveriuser
* *