Add a bunch more PLI1 routines.
This commit is contained in:
parent
3ef65d1298
commit
a9ce23d2e9
13
acc_user.h
13
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.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
|
||||
|
||||
/*
|
||||
|
|
@ -209,8 +209,12 @@ extern char* acc_fetch_defname(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);
|
||||
extern double acc_fetch_tfarg(PLI_INT32);
|
||||
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 {
|
||||
PLI_INT16 unit;
|
||||
|
|
@ -260,6 +264,9 @@ EXTERN_C_END
|
|||
|
||||
/*
|
||||
* $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
|
||||
* 1) Adds configure logic to clean up compiler warnings
|
||||
* 2) adds acc_compare_handle, acc_fetch_range, acc_next_scope and
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
/* 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
|
||||
* 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
|
||||
*/
|
||||
#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
|
||||
|
||||
#include <vpi_user.h>
|
||||
|
|
@ -25,73 +25,121 @@
|
|||
#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;
|
||||
int rtn;
|
||||
int idx = n;
|
||||
double rtn;
|
||||
|
||||
sys_h = vpi_handle(vpiSysTfCall, 0);
|
||||
sys_i = vpi_iterate(vpiArgument, sys_h);
|
||||
iter = vpi_iterate(vpiArgument, obj);
|
||||
|
||||
/* 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) {
|
||||
value.format=vpiIntVal;
|
||||
vpi_get_value(arg_h, &value);
|
||||
rtn = value.value.integer;
|
||||
vpi_free_object(sys_i);
|
||||
if (hand) {
|
||||
value.format=vpiRealVal;
|
||||
vpi_get_value(hand, &value);
|
||||
rtn = value.value.real;
|
||||
vpi_free_object(iter);
|
||||
} else {
|
||||
rtn = 0;
|
||||
rtn = 0.0;
|
||||
}
|
||||
|
||||
|
||||
if (pli_trace) {
|
||||
fprintf(pli_trace, "%s: acc_fetch_tfarg_int(%d) --> %d\n",
|
||||
vpi_get_str(vpiName, sys_h), n, rtn);
|
||||
fflush(pli_trace);
|
||||
fprintf(pli_trace, "%s: acc_fetch_itfarg(%d, %p) --> %f\n",
|
||||
vpi_get_str(vpiName, obj), n, obj, rtn);
|
||||
}
|
||||
|
||||
return rtn;
|
||||
}
|
||||
|
||||
char *acc_fetch_tfarg_str(int n)
|
||||
double acc_fetch_tfarg(int n)
|
||||
{
|
||||
vpiHandle sys_h, sys_i, arg_h = 0;
|
||||
s_vpi_value value;
|
||||
char *rtn;
|
||||
int idx = n;
|
||||
vpiHandle hand = vpi_handle(vpiScope, vpi_handle(vpiSysTfCall,0));
|
||||
return acc_fetch_itfarg_int(n, hand);
|
||||
}
|
||||
|
||||
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 */
|
||||
while (idx > 0 && (arg_h = vpi_scan(sys_i)))
|
||||
idx -= 1;
|
||||
while (idx > 0 && (hand = vpi_scan(iter))) idx--;
|
||||
|
||||
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;
|
||||
vpi_get_value(arg_h, &value);
|
||||
vpi_get_value(hand, &value);
|
||||
rtn = __acc_newstring(value.value.str);
|
||||
vpi_free_object(sys_i);
|
||||
vpi_free_object(iter);
|
||||
} else {
|
||||
rtn = (char *) 0;
|
||||
}
|
||||
|
||||
if (pli_trace) {
|
||||
fprintf(pli_trace, "%s: acc_fetch_tfarg_str(%d) --> \"%s\"\n",
|
||||
vpi_get_str(vpiName, sys_h), n, rtn? rtn : "");
|
||||
fflush(pli_trace);
|
||||
fprintf(pli_trace, "%s: acc_fetch_itfarg_str(%d, %p) --> \"%s\"\n",
|
||||
vpi_get_str(vpiName, obj),
|
||||
n, obj, rtn? 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 $
|
||||
* 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
|
||||
* Add PLI_TRACE tracing of PLI1 modules.
|
||||
*
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@
|
|||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
*/
|
||||
#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
|
||||
|
||||
#include <veriuser.h>
|
||||
|
|
@ -66,18 +66,6 @@ char *tf_strgettime(void)
|
|||
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)
|
||||
{
|
||||
s_vpi_time time;
|
||||
|
|
@ -90,18 +78,53 @@ PLI_INT32 tf_igetlongtime(PLI_INT32 *high, void*obj)
|
|||
return scaled & 0xffffffff;
|
||||
}
|
||||
|
||||
PLI_INT32 tf_getlongtime(PLI_INT32 *high)
|
||||
{
|
||||
return tf_igetlongtime(high, 0);
|
||||
}
|
||||
|
||||
/* Alias for commercial simulators */
|
||||
PLI_INT32 tf_getlongsimtime(PLI_INT32 *high) \
|
||||
__attribute__ ((weak, alias ("tf_getlongtime")));
|
||||
|
||||
void tf_scale_longdelay(void*obj, PLI_INT32 lo, PLI_INT32 hi,
|
||||
PLI_INT32 *low, PLI_INT32 *high)
|
||||
void tf_scale_longdelay(void*obj, PLI_INT32 low, PLI_INT32 high,
|
||||
PLI_INT32 *alow, PLI_INT32 *ahigh)
|
||||
{
|
||||
ivl_u64_t scaled = scale(hi, lo, obj);
|
||||
*high = (scaled >> 32) & 0xffffffff;
|
||||
*low = scaled & 0xffffffff;
|
||||
ivl_u64_t scaled = scale(high, low, obj);
|
||||
*ahigh = (scaled >> 32) & 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)
|
||||
{
|
||||
|
|
@ -130,6 +153,9 @@ PLI_INT32 tf_igettimeunit(void*obj)
|
|||
|
||||
/*
|
||||
* $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
|
||||
* 1) Adds configure logic to clean up compiler warnings
|
||||
* 2) adds acc_compare_handle, acc_fetch_range, acc_next_scope and
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@
|
|||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
*/
|
||||
#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
|
||||
|
||||
# include <string.h>
|
||||
|
|
@ -32,19 +32,34 @@ void tf_multiply_long(PLI_INT32*aof_low1, PLI_INT32*aof_high1,
|
|||
{
|
||||
ivl_u64_t a, b;
|
||||
a = *aof_high1;
|
||||
a <<= 32;
|
||||
a |= *aof_low1;
|
||||
a = (a << 32) | *aof_low1;
|
||||
b = aof_high2;
|
||||
b <<= 32;
|
||||
b |= aof_low2;
|
||||
b = (b << 32) | aof_low2;
|
||||
a *= b;
|
||||
*aof_high1 = (a >> 32) & 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 $
|
||||
* 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
|
||||
* 1) Adds configure logic to clean up compiler warnings
|
||||
* 2) adds acc_compare_handle, acc_fetch_range, acc_next_scope and
|
||||
|
|
|
|||
10
veriuser.h
10
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.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
|
||||
|
||||
/*
|
||||
|
|
@ -269,6 +269,9 @@ extern PLI_INT32 tf_getlongtime(PLI_INT32*);
|
|||
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_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_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,
|
||||
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_inump(void*);
|
||||
|
|
@ -337,6 +342,9 @@ EXTERN_C_END
|
|||
|
||||
/*
|
||||
* $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
|
||||
* 1) Adds configure logic to clean up compiler warnings
|
||||
* 2) adds acc_compare_handle, acc_fetch_range, acc_next_scope and
|
||||
|
|
|
|||
Loading…
Reference in New Issue