Add tf_synchronize and tf_multiply_long.

This commit is contained in:
steve 2003-04-23 15:01:29 +00:00
parent d5642e6bdf
commit 11b9adfa40
5 changed files with 156 additions and 34 deletions

View File

@ -16,7 +16,7 @@
# 59 Temple Place - Suite 330
# Boston, MA 02111-1307, USA
#
#ident "$Id: Makefile.in,v 1.20 2003/04/12 18:57:14 steve Exp $"
#ident "$Id: Makefile.in,v 1.21 2003/04/23 15:01:29 steve Exp $"
#
#
SHELL = /bin/sh
@ -52,7 +52,7 @@ 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_vcl.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 \
getp.o getsimtime.o io_print.o math.o mc_scan_plusargs.o nump.o putlongp.o \
putp.o spname.o typep.o workarea.o veriusertfs.o priv.o $A
all: dep libveriuser.a

View File

@ -17,13 +17,13 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#ifdef HAVE_CVS_IDENT
#ident "$Id: asynch.c,v 1.2 2002/08/12 01:35:02 steve Exp $"
#ident "$Id: asynch.c,v 1.3 2003/04/23 15:01:29 steve Exp $"
#endif
# include <veriuser.h>
/* Enables async misctf callbacks */
int async_misctf_enable;
int async_misctf_enable = 0;
/*
* Implement misctf async enable
@ -42,6 +42,9 @@ int tf_asynchoff(void)
/*
* $Log: asynch.c,v $
* Revision 1.3 2003/04/23 15:01:29 steve
* Add tf_synchronize and tf_multiply_long.
*
* Revision 1.2 2002/08/12 01:35:02 steve
* conditional ident string using autoconfig.
*

60
libveriuser/math.c Normal file
View File

@ -0,0 +1,60 @@
/*
* 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: math.c,v 1.1 2003/04/23 15:01:29 steve Exp $"
#endif
# include <string.h>
# include <stdlib.h>
# include <assert.h>
# include "vpi_user.h"
# include "veriuser.h"
void tf_multiply_long(PLI_INT32*aof_low1, PLI_INT32*aof_high1,
PLI_INT32 aof_low2, PLI_INT32 aof_high2)
{
if (sizeof(long) == 8) {
long a, b;
a = (*aof_high1 << 32) | (*aof_low1);
b = (aof_high2 << 32) | (aof_low2);
a *= b;
*aof_low1 = a & 0xffffffff;
a >>= 32;
*aof_high1 = a & 0xffffffff;
} else if (sizeof(long long) == 8) {
long long a, b;
a = (*aof_high1 << 32) | (*aof_low1);
b = ( aof_high2 << 32) | ( aof_low2);
a *= b;
*aof_low1 = a & 0xffffffff;
a >>= 32;
*aof_high1 = a & 0xffffffff;
} else {
assert(0);
}
}
/*
* $Log: math.c,v $
* Revision 1.1 2003/04/23 15:01:29 steve
* Add tf_synchronize and tf_multiply_long.
*
*/

View File

@ -18,7 +18,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#ifdef HAVE_CVS_IDENT
#ident "$Id: veriusertfs.c,v 1.6 2003/02/16 02:23:14 steve Exp $"
#ident "$Id: veriusertfs.c,v 1.7 2003/04/23 15:01:29 steve Exp $"
#endif
/*
@ -46,7 +46,8 @@ static int calltf(char *);
static int callback(p_cb_data);
/*
* Register veriusertfs routines/wrappers.
* Register veriusertfs routines/wrappers. Iterate over the tfcell
* array, registering each function.
*/
void veriusertfs_register_table(p_tfcell vtable)
{
@ -69,20 +70,22 @@ void veriusertfs_register_table(p_tfcell vtable)
assert(data != NULL);
data->tf = tf;
/* build callback structure */
/* Build a VPI system task/function structure, and point
it to the pli_data that represents this
function. Supply wrapper functions for the system
task actions. */
(void) memset(&tf_data, 0, sizeof(s_vpi_systf_data));
switch (tf->type) {
case usertask:
tf_data.type = vpiSysTask;
case usertask:
tf_data.type = vpiSysTask;
break;
case userfunction:
tf_data.type = vpiSysFunc;
break;
default:
vpi_printf("veriusertfs: %s, unsupported type %d\n",
tf->tfname, tf->type);
continue;
case userfunction:
tf_data.type = vpiSysFunc;
break;
default:
vpi_printf("veriusertfs: %s, unsupported type %d\n",
tf->tfname, tf->type);
continue;
}
tf_data.tfname = tf->tfname;
@ -119,6 +122,13 @@ static int compiletf(char *data)
/* get call handle */
call_h = vpi_handle(vpiSysTfCall, NULL);
/* Attach the pli_data structure to the vpi handle of the
system task. This is how I manage the map from vpiHandle to
PLI1 pli data. We do it here (instead of during register)
because this is the first that I have both the vpiHandle
and the pli_data. */
vpi_put_userdata(call_h, pli);
/* default cb_data */
(void) memset(&cb_data, 0, sizeof(s_cb_data));
cb_data.cb_rtn = callback;
@ -129,10 +139,13 @@ static int compiletf(char *data)
cb_data.obj = call_h;
vpi_register_cb(&cb_data);
/* register paramvc misctf callback(s) */
cb_data.reason = cbValueChange;
arg_i = vpi_iterate(vpiArgument, call_h);
if (arg_i != NULL) {
/* If there is a misctf function, then create a value change
callback for all the arguments. In the tf_* API, misctf
functions get value change callbacks, controlled by the
tf_asyncon and tf_asyncoff functions. */
if (tf->misctf && ((arg_i = vpi_iterate(vpiArgument, call_h)) != NULL)) {
cb_data.reason = cbValueChange;
while ((arg_h = vpi_scan(arg_i)) != NULL) {
/* replicate user_data for each instance */
dp = (p_pli_data)calloc(1, sizeof(s_pli_data));
@ -160,6 +173,7 @@ static int compiletf(char *data)
*/
static int calltf(char *data)
{
int rc = 0;
p_pli_data pli;
p_tfcell tf;
@ -168,7 +182,10 @@ static int calltf(char *data)
tf = pli->tf;
/* execute calltf */
return (tf->calltf) ? tf->calltf(tf->data, reason_calltf) : 0;
if (tf->calltf)
rc = tf->calltf(tf->data, reason_calltf);
return rc;
}
/*
@ -183,31 +200,62 @@ static int callback(p_cb_data data)
int reason;
int paramvc = 0;
/* not enabled */
if (data->reason == cbValueChange && !async_misctf_enable) return 0;
/* not enabled */
if (data->reason == cbValueChange && !async_misctf_enable)
return 0;
/* cast back from opaque */
/* cast back from opaque */
pli = (p_pli_data)data->user_data;
tf = pli->tf;
switch (data->reason) {
case cbValueChange:
reason = reason_paramvc;
paramvc = pli->paramvc;
break;
case cbEndOfSimulation:
reason = reason_finish;
break;
default:
abort();
case cbValueChange:
reason = reason_paramvc;
paramvc = pli->paramvc;
break;
case cbEndOfSimulation:
reason = reason_finish;
break;
case cbReadWriteSynch:
reason = reason_synch;
break;
default:
assert(0);
}
/* execute misctf */
return (tf->misctf) ? tf->misctf(tf->data, reason, paramvc) : 0;
}
PLI_INT32 tf_isynchronize(void*obj)
{
vpiHandle sys = (vpiHandle)obj;
p_pli_data pli = vpi_get_userdata(sys);
s_cb_data cb;
s_vpi_time ti;
ti.type = vpiSuppressTime;
cb.reason = cbReadWriteSynch;
cb.cb_rtn = callback;
cb.obj = sys;
cb.time = &ti;
cb.user_data = pli;
vpi_register_cb(&cb);
return 0;
}
PLI_INT32 tf_synchronize(void)
{
return tf_isynchronize(tf_getinstance());
}
/*
* $Log: veriusertfs.c,v $
* Revision 1.7 2003/04/23 15:01:29 steve
* Add tf_synchronize and tf_multiply_long.
*
* Revision 1.6 2003/02/16 02:23:14 steve
* Change the IV veriusertfs_register to accept table pointers.
*

View File

@ -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.23 2003/04/12 18:57:13 steve Exp $"
#ident "$Id: veriuser.h,v 1.24 2003/04/23 15:01:29 steve Exp $"
#endif
/*
@ -164,6 +164,8 @@ extern void veriusertfs_register_table(p_tfcell vtable);
#define reason_checktf 1
#define reason_calltf 3
#define reason_paramvc 7
#define reason_synch 8
#define REASON_SYNCH reason_synch
#define reason_finish 9
#define reason_endofcompile 16
@ -262,6 +264,9 @@ extern PLI_INT32 tf_message(PLI_INT32 level, char*facility,
char*messno, char*fmt, ...)
__attribute__((format (printf,4,5)));
extern void tf_multiply_long(PLI_INT32*aof_low1, PLI_INT32*aof_high1,
PLI_INT32 aof_low2, PLI_INT32 aof_high2);
extern int tf_nump(void);
/* IEEE1364 NOTE: tf_putlongp is listed as returning in in the header
@ -281,6 +286,9 @@ extern PLI_INT32 tf_setworkarea(void*workarea);
task call. */
extern char* tf_spname(void);
extern PLI_INT32 tf_synchronize(void);
extern PLI_INT32 tf_isynchronize(void* sys);
extern PLI_INT32 tf_typep(PLI_INT32 narg);
extern void tf_warning(const char*, ...)
@ -290,6 +298,9 @@ EXTERN_C_END
/*
* $Log: veriuser.h,v $
* Revision 1.24 2003/04/23 15:01:29 steve
* Add tf_synchronize and tf_multiply_long.
*
* Revision 1.23 2003/04/12 18:57:13 steve
* More acc_ function stubs.
*