Add a bunch more PLI1 routines.

This commit is contained in:
steve 2003-06-13 19:23:41 +00:00
parent 3ef65d1298
commit a9ce23d2e9
5 changed files with 167 additions and 63 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
*/ */
#ifdef HAVE_CVS_IDENT #ifdef HAVE_CVS_IDENT
#ident "$Id: acc_user.h,v 1.17 2003/06/04 01:56:20 steve Exp $" #ident "$Id: acc_user.h,v 1.18 2003/06/13 19:23:41 steve Exp $"
#endif #endif
/* /*
@ -209,8 +209,12 @@ extern char* acc_fetch_defname(handle obj);
extern double acc_fetch_paramval(handle obj); extern double acc_fetch_paramval(handle obj);
extern int acc_fetch_tfarg_int(int n); extern double acc_fetch_tfarg(PLI_INT32);
extern char* acc_fetch_tfarg_str(int n); extern double acc_fetch_itfarg(PLI_INT32, handle);
extern PLI_INT32 acc_fetch_tfarg_int(PLI_INT32);
extern PLI_INT32 acc_fetch_itfarg_int(PLI_INT32, handle);
extern char* acc_fetch_tfarg_str(PLI_INT32);
extern char* acc_fetch_itfarg_str(PLI_INT32, handle);
typedef struct t_timescale_info { typedef struct t_timescale_info {
PLI_INT16 unit; PLI_INT16 unit;
@ -260,6 +264,9 @@ EXTERN_C_END
/* /*
* $Log: acc_user.h,v $ * $Log: acc_user.h,v $
* Revision 1.18 2003/06/13 19:23:41 steve
* Add a bunch more PLI1 routines.
*
* Revision 1.17 2003/06/04 01:56:20 steve * Revision 1.17 2003/06/04 01:56:20 steve
* 1) Adds configure logic to clean up compiler warnings * 1) Adds configure logic to clean up compiler warnings
* 2) adds acc_compare_handle, acc_fetch_range, acc_next_scope and * 2) adds acc_compare_handle, acc_fetch_range, acc_next_scope and

View File

@ -1,5 +1,5 @@
/* vi:sw=6 /* vi:sw=6
* Copyright (c) 2002 Michael Ruff (mruff at chiaro.com) * Copyright (c) 2002,2003 Michael Ruff (mruff at chiaro.com)
* *
* This source code is free software; you can redistribute it * This source code is free software; you can redistribute it
* and/or modify it in source code form under the terms of the GNU * and/or modify it in source code form under the terms of the GNU
@ -17,7 +17,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
*/ */
#ifdef HAVE_CVS_IDENT #ifdef HAVE_CVS_IDENT
#ident "$Id: a_fetch_tfarg.c,v 1.6 2003/05/18 00:16:35 steve Exp $" #ident "$Id: a_fetch_tfarg.c,v 1.7 2003/06/13 19:23:42 steve Exp $"
#endif #endif
#include <vpi_user.h> #include <vpi_user.h>
@ -25,73 +25,121 @@
#include "priv.h" #include "priv.h"
/* /*
* acc_fetch_tfarg routines implemented using VPI interface * acc_fetch_tfarg and friends implemented using VPI interface
*/ */
int acc_fetch_tfarg_int(int n) double acc_fetch_itfarg(PLI_INT32 n, handle obj)
{ {
vpiHandle sys_h, sys_i, arg_h = 0; vpiHandle iter, hand = 0;
s_vpi_value value; s_vpi_value value;
int rtn; int idx = n;
double rtn;
sys_h = vpi_handle(vpiSysTfCall, 0); iter = vpi_iterate(vpiArgument, obj);
sys_i = vpi_iterate(vpiArgument, sys_h);
/* scan to nth argument */ /* scan to nth argument */
while (n > 0 && (arg_h = vpi_scan(sys_i))) n--; while (idx > 0 && (hand = vpi_scan(iter))) idx--;
if (arg_h) { if (hand) {
value.format=vpiIntVal; value.format=vpiRealVal;
vpi_get_value(arg_h, &value); vpi_get_value(hand, &value);
rtn = value.value.integer; rtn = value.value.real;
vpi_free_object(sys_i); vpi_free_object(iter);
} else { } else {
rtn = 0; rtn = 0.0;
} }
if (pli_trace) { if (pli_trace) {
fprintf(pli_trace, "%s: acc_fetch_tfarg_int(%d) --> %d\n", fprintf(pli_trace, "%s: acc_fetch_itfarg(%d, %p) --> %f\n",
vpi_get_str(vpiName, sys_h), n, rtn); vpi_get_str(vpiName, obj), n, obj, rtn);
fflush(pli_trace);
} }
return rtn; return rtn;
} }
char *acc_fetch_tfarg_str(int n) double acc_fetch_tfarg(int n)
{ {
vpiHandle sys_h, sys_i, arg_h = 0; vpiHandle hand = vpi_handle(vpiScope, vpi_handle(vpiSysTfCall,0));
s_vpi_value value; return acc_fetch_itfarg_int(n, hand);
char *rtn; }
int idx = n;
sys_h = vpi_handle(vpiSysTfCall, 0);
sys_i = vpi_iterate(vpiArgument, sys_h); PLI_INT32 acc_fetch_itfarg_int(PLI_INT32 n, handle obj)
{
vpiHandle iter, hand = 0;
s_vpi_value value;
int idx = n;
int rtn;
iter = vpi_iterate(vpiArgument, obj);
/* scan to nth argument */ /* scan to nth argument */
while (idx > 0 && (arg_h = vpi_scan(sys_i))) while (idx > 0 && (hand = vpi_scan(iter))) idx--;
idx -= 1;
if (arg_h) { if (hand) {
value.format=vpiIntVal;
vpi_get_value(hand, &value);
rtn = value.value.integer;
vpi_free_object(iter);
} else {
rtn = 0;
}
if (pli_trace) {
fprintf(pli_trace, "%s: acc_fetch_itfarg_int(%d, %p) --> %d\n",
vpi_get_str(vpiName, obj), n, obj, rtn);
}
return rtn;
}
PLI_INT32 acc_fetch_tfarg_int(PLI_INT32 n)
{
vpiHandle hand = vpi_handle(vpiScope, vpi_handle(vpiSysTfCall,0));
return acc_fetch_itfarg_int(n, hand);
}
char *acc_fetch_itfarg_str(PLI_INT32 n, handle obj)
{
vpiHandle iter, hand = 0;
s_vpi_value value;
int idx = n;
char *rtn;
iter = vpi_iterate(vpiArgument, obj);
/* scan to nth argument */
while (idx > 0 && (hand = vpi_scan(iter))) idx -= 1;
if (hand) {
value.format=vpiStringVal; value.format=vpiStringVal;
vpi_get_value(arg_h, &value); vpi_get_value(hand, &value);
rtn = __acc_newstring(value.value.str); rtn = __acc_newstring(value.value.str);
vpi_free_object(sys_i); vpi_free_object(iter);
} else { } else {
rtn = (char *) 0; rtn = (char *) 0;
} }
if (pli_trace) { if (pli_trace) {
fprintf(pli_trace, "%s: acc_fetch_tfarg_str(%d) --> \"%s\"\n", fprintf(pli_trace, "%s: acc_fetch_itfarg_str(%d, %p) --> \"%s\"\n",
vpi_get_str(vpiName, sys_h), n, rtn? rtn : ""); vpi_get_str(vpiName, obj),
fflush(pli_trace); n, obj, rtn? rtn : "");
} }
return rtn; return rtn;
} }
char *acc_fetch_tfarg_str(PLI_INT32 n)
{
vpiHandle hand = vpi_handle(vpiScope, vpi_handle(vpiSysTfCall,0));
return acc_fetch_itfarg_str(n, hand);
}
/* /*
* $Log: a_fetch_tfarg.c,v $ * $Log: a_fetch_tfarg.c,v $
* Revision 1.7 2003/06/13 19:23:42 steve
* Add a bunch more PLI1 routines.
*
* Revision 1.6 2003/05/18 00:16:35 steve * Revision 1.6 2003/05/18 00:16:35 steve
* Add PLI_TRACE tracing of PLI1 modules. * Add PLI_TRACE tracing of PLI1 modules.
* *

View File

@ -17,7 +17,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
*/ */
#ifdef HAVE_CVS_IDENT #ifdef HAVE_CVS_IDENT
#ident "$Id: getsimtime.c,v 1.9 2003/06/04 01:56:20 steve Exp $" #ident "$Id: getsimtime.c,v 1.10 2003/06/13 19:23:42 steve Exp $"
#endif #endif
#include <veriuser.h> #include <veriuser.h>
@ -66,18 +66,6 @@ char *tf_strgettime(void)
return buf; return buf;
} }
PLI_INT32 tf_getlongtime(PLI_INT32 *high)
{
s_vpi_time time;
ivl_u64_t scaled;
time.type = vpiSimTime;
vpi_get_time (0, &time);
scaled = scale(time.high, time.low, 0);
*high = (scaled >> 32) & 0xffffffff;
return scaled & 0xffffffff;
}
PLI_INT32 tf_igetlongtime(PLI_INT32 *high, void*obj) PLI_INT32 tf_igetlongtime(PLI_INT32 *high, void*obj)
{ {
s_vpi_time time; s_vpi_time time;
@ -90,18 +78,53 @@ PLI_INT32 tf_igetlongtime(PLI_INT32 *high, void*obj)
return scaled & 0xffffffff; return scaled & 0xffffffff;
} }
PLI_INT32 tf_getlongtime(PLI_INT32 *high)
{
return tf_igetlongtime(high, 0);
}
/* Alias for commercial simulators */ /* Alias for commercial simulators */
PLI_INT32 tf_getlongsimtime(PLI_INT32 *high) \ PLI_INT32 tf_getlongsimtime(PLI_INT32 *high) \
__attribute__ ((weak, alias ("tf_getlongtime"))); __attribute__ ((weak, alias ("tf_getlongtime")));
void tf_scale_longdelay(void*obj, PLI_INT32 lo, PLI_INT32 hi, void tf_scale_longdelay(void*obj, PLI_INT32 low, PLI_INT32 high,
PLI_INT32 *low, PLI_INT32 *high) PLI_INT32 *alow, PLI_INT32 *ahigh)
{ {
ivl_u64_t scaled = scale(hi, lo, obj); ivl_u64_t scaled = scale(high, low, obj);
*high = (scaled >> 32) & 0xffffffff; *ahigh = (scaled >> 32) & 0xffffffff;
*low = scaled & 0xffffffff; *alow = scaled & 0xffffffff;
} }
void tf_unscale_longdelay(void*obj, PLI_INT32 low, PLI_INT32 high,
PLI_INT32 *alow, PLI_INT32 *ahigh)
{
ivl_u64_t unscaled;
vpiHandle hand = vpi_handle(vpiScope, vpi_handle(vpiSysTfCall,0));
unscaled = high;
unscaled = (unscaled << 32) | low;
unscaled *= pow(10, vpi_get(vpiTimeUnit, hand) -
vpi_get(vpiTimePrecision, 0));
*ahigh = (unscaled >> 32) & 0xffffffff;
*alow = unscaled & 0xffffffff;
}
void tf_scale_realdelay(void*obj, double real, double *areal)
{
vpiHandle hand = vpi_handle(vpiScope, vpi_handle(vpiSysTfCall,0));
*areal = real * pow(10, vpi_get(vpiTimePrecision, 0) -
vpi_get(vpiTimeUnit, hand));
}
void tf_unscale_realdelay(void*obj, double real, double *areal)
{
vpiHandle hand = vpi_handle(vpiScope, vpi_handle(vpiSysTfCall,0));
*areal = real * pow(10, vpi_get(vpiTimeUnit, hand) -
vpi_get(vpiTimePrecision, 0));
}
PLI_INT32 tf_gettimeprecision(void) PLI_INT32 tf_gettimeprecision(void)
{ {
@ -130,6 +153,9 @@ PLI_INT32 tf_igettimeunit(void*obj)
/* /*
* $Log: getsimtime.c,v $ * $Log: getsimtime.c,v $
* Revision 1.10 2003/06/13 19:23:42 steve
* Add a bunch more PLI1 routines.
*
* Revision 1.9 2003/06/04 01:56:20 steve * Revision 1.9 2003/06/04 01:56:20 steve
* 1) Adds configure logic to clean up compiler warnings * 1) Adds configure logic to clean up compiler warnings
* 2) adds acc_compare_handle, acc_fetch_range, acc_next_scope and * 2) adds acc_compare_handle, acc_fetch_range, acc_next_scope and

View File

@ -17,7 +17,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
*/ */
#ifdef HAVE_CVS_IDENT #ifdef HAVE_CVS_IDENT
#ident "$Id: math.c,v 1.2 2003/06/04 01:56:20 steve Exp $" #ident "$Id: math.c,v 1.3 2003/06/13 19:23:42 steve Exp $"
#endif #endif
# include <string.h> # include <string.h>
@ -32,19 +32,34 @@ void tf_multiply_long(PLI_INT32*aof_low1, PLI_INT32*aof_high1,
{ {
ivl_u64_t a, b; ivl_u64_t a, b;
a = *aof_high1; a = *aof_high1;
a <<= 32; a = (a << 32) | *aof_low1;
a |= *aof_low1;
b = aof_high2; b = aof_high2;
b <<= 32; b = (b << 32) | aof_low2;
b |= aof_low2;
a *= b; a *= b;
*aof_high1 = (a >> 32) & 0xffffffff;
*aof_low1 = a & 0xffffffff; *aof_low1 = a & 0xffffffff;
a >>= 32; }
*aof_high1 = a & 0xffffffff;
void tf_real_to_long(double real, PLI_INT32*low, PLI_INT32*high)
{
ivl_u64_t rtn = (ivl_u64_t)real;
*high = (rtn >> 32) & 0xffffffff;
*low = rtn & 0xffffffff;
}
void tf_long_to_real(PLI_INT32 low, PLI_INT32 high, double *real)
{
ivl_u64_t a;
a = high;
a = (a << 32) | low;
*real = (double)a;
} }
/* /*
* $Log: math.c,v $ * $Log: math.c,v $
* Revision 1.3 2003/06/13 19:23:42 steve
* Add a bunch more PLI1 routines.
*
* Revision 1.2 2003/06/04 01:56:20 steve * Revision 1.2 2003/06/04 01:56:20 steve
* 1) Adds configure logic to clean up compiler warnings * 1) Adds configure logic to clean up compiler warnings
* 2) adds acc_compare_handle, acc_fetch_range, acc_next_scope and * 2) adds acc_compare_handle, acc_fetch_range, acc_next_scope and

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
*/ */
#ifdef HAVE_CVS_IDENT #ifdef HAVE_CVS_IDENT
#ident "$Id: veriuser.h,v 1.32 2003/06/04 01:56:20 steve Exp $" #ident "$Id: veriuser.h,v 1.33 2003/06/13 19:23:41 steve Exp $"
#endif #endif
/* /*
@ -269,6 +269,9 @@ extern PLI_INT32 tf_getlongtime(PLI_INT32*);
extern PLI_INT32 tf_igetlongtime(PLI_INT32*, void*); extern PLI_INT32 tf_igetlongtime(PLI_INT32*, void*);
extern void tf_scale_longdelay(void*,PLI_INT32,PLI_INT32,PLI_INT32*,PLI_INT32*); extern void tf_scale_longdelay(void*,PLI_INT32,PLI_INT32,PLI_INT32*,PLI_INT32*);
extern void tf_unscale_longdelay(void*,PLI_INT32,PLI_INT32,PLI_INT32*,PLI_INT32*);
extern void tf_scale_realdelay(void*,double,double*);
extern void tf_unscale_realdelay(void*,double,double*);
extern PLI_INT32 tf_gettimeprecision(void); extern PLI_INT32 tf_gettimeprecision(void);
extern PLI_INT32 tf_igettimeprecision(void*); extern PLI_INT32 tf_igettimeprecision(void*);
@ -284,6 +287,8 @@ extern PLI_INT32 tf_message(PLI_INT32 level, char*facility,
extern void tf_multiply_long(PLI_INT32*aof_low1, PLI_INT32*aof_high1, extern void tf_multiply_long(PLI_INT32*aof_low1, PLI_INT32*aof_high1,
PLI_INT32 aof_low2, PLI_INT32 aof_high2); PLI_INT32 aof_low2, PLI_INT32 aof_high2);
extern void tf_real_to_long(double real, PLI_INT32*low, PLI_INT32*high);
extern void tf_long_to_real(PLI_INT32 low, PLI_INT32 high, double *real);
extern PLI_INT32 tf_nump(void); extern PLI_INT32 tf_nump(void);
extern PLI_INT32 tf_inump(void*); extern PLI_INT32 tf_inump(void*);
@ -337,6 +342,9 @@ EXTERN_C_END
/* /*
* $Log: veriuser.h,v $ * $Log: veriuser.h,v $
* Revision 1.33 2003/06/13 19:23:41 steve
* Add a bunch more PLI1 routines.
*
* Revision 1.32 2003/06/04 01:56:20 steve * Revision 1.32 2003/06/04 01:56:20 steve
* 1) Adds configure logic to clean up compiler warnings * 1) Adds configure logic to clean up compiler warnings
* 2) adds acc_compare_handle, acc_fetch_range, acc_next_scope and * 2) adds acc_compare_handle, acc_fetch_range, acc_next_scope and