Add tf_getp/putp support for integers
and real valued arguments. Add tf_mipname function.
This commit is contained in:
parent
bf664c67b4
commit
e7b3168466
|
|
@ -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,31 +17,32 @@
|
||||||
* 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: getp.c,v 1.3 2003/03/15 05:42:39 steve Exp $"
|
#ident "$Id: getp.c,v 1.4 2003/05/29 03:46:21 steve Exp $"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
# include <assert.h>
|
# include <assert.h>
|
||||||
# include <veriuser.h>
|
# include <veriuser.h>
|
||||||
# include <vpi_user.h>
|
# include <vpi_user.h>
|
||||||
|
# include "priv.h"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* tf_getp implemented using VPI interface
|
* tf_getp and friends, implemented using VPI interface
|
||||||
*/
|
*/
|
||||||
int tf_getp(int n)
|
PLI_INT32 tf_igetp(PLI_INT32 n, void *obj)
|
||||||
{
|
{
|
||||||
vpiHandle sys_h, sys_i, arg_h = 0;
|
vpiHandle sys_h, sys_i, arg_h = 0;
|
||||||
s_vpi_value value;
|
s_vpi_value value;
|
||||||
int rtn;
|
int rtn = 0;
|
||||||
|
|
||||||
assert(n > 0);
|
assert(n > 0);
|
||||||
|
|
||||||
/* get task/func handle */
|
/* get task/func handle */
|
||||||
sys_h = vpi_handle(vpiSysTfCall, 0);
|
sys_h = (vpiHandle)obj;
|
||||||
sys_i = vpi_iterate(vpiArgument, sys_h);
|
sys_i = vpi_iterate(vpiArgument, sys_h);
|
||||||
|
|
||||||
/* find nth arg */
|
/* find nth arg */
|
||||||
while (n > 0) {
|
while (n > 0) {
|
||||||
if (!(arg_h = vpi_scan(sys_i))) assert(0);
|
if (!(arg_h = vpi_scan(sys_i))) { goto out; }
|
||||||
n--;
|
n--;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -60,11 +61,80 @@ int tf_getp(int n)
|
||||||
|
|
||||||
vpi_free_object(sys_i);
|
vpi_free_object(sys_i);
|
||||||
|
|
||||||
|
out:
|
||||||
|
if (pli_trace) {
|
||||||
|
fprintf(pli_trace, "tf_igetp(n=%d, obj=%p) --> %d\n",
|
||||||
|
n, obj, rtn);
|
||||||
|
fflush(pli_trace);
|
||||||
|
}
|
||||||
|
|
||||||
return rtn;
|
return rtn;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
PLI_INT32 tf_getp(PLI_INT32 n)
|
||||||
|
{
|
||||||
|
int rtn = tf_igetp(n, vpi_handle(vpiSysTfCall, 0));
|
||||||
|
|
||||||
|
return rtn;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
double tf_igetrealp(PLI_INT32 n, void *obj)
|
||||||
|
{
|
||||||
|
vpiHandle sys_h, sys_i, arg_h = 0;
|
||||||
|
s_vpi_value value;
|
||||||
|
double rtn = 0.0;
|
||||||
|
|
||||||
|
assert(n > 0);
|
||||||
|
|
||||||
|
/* get task/func handle */
|
||||||
|
sys_h = (vpiHandle)obj;
|
||||||
|
sys_i = vpi_iterate(vpiArgument, sys_h);
|
||||||
|
|
||||||
|
/* find nth arg */
|
||||||
|
while (n > 0) {
|
||||||
|
if (!(arg_h = vpi_scan(sys_i))) { goto out; }
|
||||||
|
n--;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (vpi_get(vpiType, arg_h) == vpiConstant &&
|
||||||
|
vpi_get(vpiConstType, arg_h) == vpiStringConst)
|
||||||
|
{
|
||||||
|
rtn = 0.0;
|
||||||
|
} else {
|
||||||
|
value.format = vpiRealVal;
|
||||||
|
vpi_get_value(arg_h, &value);
|
||||||
|
rtn = value.value.real;
|
||||||
|
}
|
||||||
|
|
||||||
|
vpi_free_object(sys_i);
|
||||||
|
|
||||||
|
out:
|
||||||
|
if (pli_trace) {
|
||||||
|
fprintf(pli_trace, "tf_igetrealp(n=%d, obj=%p) --> %f\n",
|
||||||
|
n, obj, rtn);
|
||||||
|
fflush(pli_trace);
|
||||||
|
}
|
||||||
|
|
||||||
|
return rtn;
|
||||||
|
}
|
||||||
|
|
||||||
|
double tf_getrealp(PLI_INT32 n)
|
||||||
|
{
|
||||||
|
double rtn = tf_igetrealp(n, vpi_handle(vpiSysTfCall, 0));
|
||||||
|
|
||||||
|
return rtn;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* $Log: getp.c,v $
|
* $Log: getp.c,v $
|
||||||
|
* Revision 1.4 2003/05/29 03:46:21 steve
|
||||||
|
* Add tf_getp/putp support for integers
|
||||||
|
* and real valued arguments.
|
||||||
|
*
|
||||||
|
* Add tf_mipname function.
|
||||||
|
*
|
||||||
* Revision 1.3 2003/03/15 05:42:39 steve
|
* Revision 1.3 2003/03/15 05:42:39 steve
|
||||||
* free argument iterators.
|
* free argument iterators.
|
||||||
*
|
*
|
||||||
|
|
|
||||||
|
|
@ -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,36 +17,37 @@
|
||||||
* 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: putp.c,v 1.3 2003/03/15 05:42:39 steve Exp $"
|
#ident "$Id: putp.c,v 1.4 2003/05/29 03:46:21 steve Exp $"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
# include <assert.h>
|
# include <assert.h>
|
||||||
# include <veriuser.h>
|
# include <veriuser.h>
|
||||||
# include <vpi_user.h>
|
# include <vpi_user.h>
|
||||||
|
# include "priv.h"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* tf_putp implemented using VPI interface
|
* tf_putp and friends implemented using VPI interface
|
||||||
*/
|
*/
|
||||||
void tf_putp(int n, int value)
|
PLI_INT32 tf_iputp(PLI_INT32 n, PLI_INT32 value, void *obj)
|
||||||
{
|
{
|
||||||
vpiHandle sys_h, sys_i, arg_h = 0;
|
vpiHandle sys_h, sys_i, arg_h = 0;
|
||||||
s_vpi_value val;
|
s_vpi_value val;
|
||||||
int type;
|
int rtn = 0, type;
|
||||||
|
|
||||||
assert(n >= 0);
|
assert(n >= 0);
|
||||||
|
|
||||||
/* get task/func handle */
|
/* get task/func handle */
|
||||||
sys_h = vpi_handle(vpiSysTfCall, 0);
|
sys_h = (vpiHandle)obj;
|
||||||
sys_i = vpi_iterate(vpiArgument, sys_h);
|
sys_i = vpi_iterate(vpiArgument, sys_h);
|
||||||
|
|
||||||
type = vpi_get(vpiType, sys_h);
|
type = vpi_get(vpiType, sys_h);
|
||||||
|
|
||||||
/* verify function */
|
/* verify function */
|
||||||
assert(!(n == 0 && type != vpiSysFuncCall));
|
if (n == 0 && type != vpiSysFuncCall) { rtn = 1; goto free; }
|
||||||
|
|
||||||
/* find nth arg */
|
/* find nth arg */
|
||||||
while (n > 0) {
|
while (n > 0) {
|
||||||
if (!(arg_h = vpi_scan(sys_i))) assert(0);
|
if (!(arg_h = vpi_scan(sys_i))) { rtn = 1; goto out; }
|
||||||
n--;
|
n--;
|
||||||
}
|
}
|
||||||
if (!arg_h) arg_h = sys_h;
|
if (!arg_h) arg_h = sys_h;
|
||||||
|
|
@ -56,11 +57,83 @@ void tf_putp(int n, int value)
|
||||||
val.value.integer = value;
|
val.value.integer = value;
|
||||||
(void)vpi_put_value(arg_h, &val, 0, vpiNoDelay);
|
(void)vpi_put_value(arg_h, &val, 0, vpiNoDelay);
|
||||||
|
|
||||||
|
free:
|
||||||
vpi_free_object(sys_i);
|
vpi_free_object(sys_i);
|
||||||
|
|
||||||
|
out:
|
||||||
|
if (pli_trace) {
|
||||||
|
fprintf(pli_trace, "tf_iputp(n=%d, value=%d, obj=%p) --> %d\n",
|
||||||
|
n, value, obj, rtn);
|
||||||
|
fflush(pli_trace);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return rtn;
|
||||||
|
}
|
||||||
|
|
||||||
|
PLI_INT32 tf_putp(PLI_INT32 n, PLI_INT32 value)
|
||||||
|
{
|
||||||
|
int rtn = tf_iputp(n, value, vpi_handle(vpiSysTfCall, 0));
|
||||||
|
|
||||||
|
return rtn;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
PLI_INT32 tf_iputrealp(PLI_INT32 n, double value, void *obj)
|
||||||
|
{
|
||||||
|
vpiHandle sys_h, sys_i, arg_h = 0;
|
||||||
|
s_vpi_value val;
|
||||||
|
int rtn = 0, type;
|
||||||
|
|
||||||
|
assert(n >= 0);
|
||||||
|
|
||||||
|
/* get task/func handle */
|
||||||
|
sys_h = (vpiHandle)obj;
|
||||||
|
sys_i = vpi_iterate(vpiArgument, sys_h);
|
||||||
|
|
||||||
|
type = vpi_get(vpiType, sys_h);
|
||||||
|
|
||||||
|
/* verify function */
|
||||||
|
if (n == 0 && type != vpiSysFuncCall) { rtn = 1; goto free; }
|
||||||
|
|
||||||
|
/* find nth arg */
|
||||||
|
while (n > 0) {
|
||||||
|
if (!(arg_h = vpi_scan(sys_i))) { rtn = 1; goto out; }
|
||||||
|
n--;
|
||||||
|
}
|
||||||
|
if (!arg_h) arg_h = sys_h;
|
||||||
|
|
||||||
|
/* fill in vpi_value */
|
||||||
|
val.format = vpiRealVal;
|
||||||
|
val.value.real = value;
|
||||||
|
(void)vpi_put_value(arg_h, &val, 0, vpiNoDelay);
|
||||||
|
|
||||||
|
free:
|
||||||
|
vpi_free_object(sys_i);
|
||||||
|
|
||||||
|
out:
|
||||||
|
if (pli_trace) {
|
||||||
|
fprintf(pli_trace, "tf_iputrealp(n=%d, value=%f, obj=%p) --> %d\n",
|
||||||
|
n, value, obj, rtn);
|
||||||
|
fflush(pli_trace);
|
||||||
|
}
|
||||||
|
|
||||||
|
return rtn;
|
||||||
|
}
|
||||||
|
|
||||||
|
PLI_INT32 tf_putrealp(PLI_INT32 n, double value)
|
||||||
|
{
|
||||||
|
int rtn = tf_iputrealp(n, value, vpi_handle(vpiSysTfCall, 0));
|
||||||
|
|
||||||
|
return rtn;
|
||||||
|
}
|
||||||
/*
|
/*
|
||||||
* $Log: putp.c,v $
|
* $Log: putp.c,v $
|
||||||
|
* Revision 1.4 2003/05/29 03:46:21 steve
|
||||||
|
* Add tf_getp/putp support for integers
|
||||||
|
* and real valued arguments.
|
||||||
|
*
|
||||||
|
* Add tf_mipname function.
|
||||||
|
*
|
||||||
* Revision 1.3 2003/03/15 05:42:39 steve
|
* Revision 1.3 2003/03/15 05:42:39 steve
|
||||||
* free argument iterators.
|
* free argument iterators.
|
||||||
*
|
*
|
||||||
|
|
|
||||||
|
|
@ -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: spname.c,v 1.2 2003/05/18 00:16:35 steve Exp $"
|
#ident "$Id: spname.c,v 1.3 2003/05/29 03:46:21 steve Exp $"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
|
@ -43,8 +43,24 @@ char* tf_spname(void)
|
||||||
return rtn;
|
return rtn;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
char *tf_imipname(void *obj)
|
||||||
|
{
|
||||||
|
return vpi_get_str(vpiFullName, vpi_handle(vpiScope, (vpiHandle)obj));
|
||||||
|
}
|
||||||
|
|
||||||
|
char *tf_mipname(void)
|
||||||
|
{
|
||||||
|
return tf_imipname(vpi_handle(vpiSysTfCall,0));
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* $Log: spname.c,v $
|
* $Log: spname.c,v $
|
||||||
|
* Revision 1.3 2003/05/29 03:46:21 steve
|
||||||
|
* Add tf_getp/putp support for integers
|
||||||
|
* and real valued arguments.
|
||||||
|
*
|
||||||
|
* Add tf_mipname function.
|
||||||
|
*
|
||||||
* Revision 1.2 2003/05/18 00:16:35 steve
|
* Revision 1.2 2003/05/18 00:16:35 steve
|
||||||
* Add PLI_TRACE tracing of PLI1 modules.
|
* Add PLI_TRACE tracing of PLI1 modules.
|
||||||
*
|
*
|
||||||
|
|
|
||||||
29
veriuser.h
29
veriuser.h
|
|
@ -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.27 2003/05/28 03:38:05 steve Exp $"
|
#ident "$Id: veriuser.h,v 1.28 2003/05/29 03:46:21 steve Exp $"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
@ -249,7 +249,11 @@ extern PLI_BYTE8* tf_getinstance(void);
|
||||||
|
|
||||||
extern int tf_getlongp(int*aof_highvalue, int pnum);
|
extern int tf_getlongp(int*aof_highvalue, int pnum);
|
||||||
|
|
||||||
extern int tf_getp(int pnum);
|
extern PLI_INT32 tf_getp(PLI_INT32);
|
||||||
|
extern PLI_INT32 tf_igetp(PLI_INT32, void*);
|
||||||
|
|
||||||
|
extern double tf_getrealp(PLI_INT32);
|
||||||
|
extern double tf_igetrealp(PLI_INT32, void*);
|
||||||
|
|
||||||
extern char *tf_strgettime(void);
|
extern char *tf_strgettime(void);
|
||||||
extern PLI_INT32 tf_gettime(void);
|
extern PLI_INT32 tf_gettime(void);
|
||||||
|
|
@ -272,15 +276,19 @@ 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 int tf_nump(void);
|
extern PLI_INT32 tf_nump(void);
|
||||||
extern int tf_inump(void*);
|
extern PLI_INT32 tf_inump(void*);
|
||||||
|
|
||||||
/* IEEE1364 NOTE: tf_putlongp is listed as returning in in the header
|
/* IEEE1364 NOTE: tf_putlongp is listed as returning in in the header
|
||||||
file shown in the standard, but as returning void in the detailed
|
file shown in the standard, but as returning void in the detailed
|
||||||
description of the function. So I call it void. Same for tf_putp. */
|
description of the function. So I call it void. */
|
||||||
extern void tf_putlongp(int pnum, int lowvalue, int highvalue);
|
extern void tf_putlongp(int pnum, int lowvalue, int highvalue);
|
||||||
|
|
||||||
extern void tf_putp(int pnum, int value);
|
extern PLI_INT32 tf_putp(PLI_INT32, PLI_INT32);
|
||||||
|
extern PLI_INT32 tf_iputp(PLI_INT32, PLI_INT32, void*);
|
||||||
|
|
||||||
|
extern PLI_INT32 tf_putrealp(PLI_INT32, double);
|
||||||
|
extern PLI_INT32 tf_iputrealp(PLI_INT32, double, void*);
|
||||||
|
|
||||||
/* Activate the misctf function after a delay. The units are of the
|
/* Activate the misctf function after a delay. The units are of the
|
||||||
current scope. The tf_isetdelay variant specifies a particular
|
current scope. The tf_isetdelay variant specifies a particular
|
||||||
|
|
@ -299,6 +307,9 @@ extern PLI_INT32 tf_setworkarea(void*workarea);
|
||||||
task call. */
|
task call. */
|
||||||
extern char* tf_spname(void);
|
extern char* tf_spname(void);
|
||||||
|
|
||||||
|
extern char* tf_mipname(void);
|
||||||
|
extern char* tf_imipname(void*);
|
||||||
|
|
||||||
extern PLI_INT32 tf_synchronize(void);
|
extern PLI_INT32 tf_synchronize(void);
|
||||||
extern PLI_INT32 tf_isynchronize(void* sys);
|
extern PLI_INT32 tf_isynchronize(void* sys);
|
||||||
|
|
||||||
|
|
@ -311,6 +322,12 @@ EXTERN_C_END
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* $Log: veriuser.h,v $
|
* $Log: veriuser.h,v $
|
||||||
|
* Revision 1.28 2003/05/29 03:46:21 steve
|
||||||
|
* Add tf_getp/putp support for integers
|
||||||
|
* and real valued arguments.
|
||||||
|
*
|
||||||
|
* Add tf_mipname function.
|
||||||
|
*
|
||||||
* Revision 1.27 2003/05/28 03:38:05 steve
|
* Revision 1.27 2003/05/28 03:38:05 steve
|
||||||
* Implement tf_inump
|
* Implement tf_inump
|
||||||
*
|
*
|
||||||
|
|
|
||||||
|
|
@ -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: vpi_const.cc,v 1.28 2003/03/17 23:47:25 steve Exp $"
|
#ident "$Id: vpi_const.cc,v 1.29 2003/05/29 03:46:21 steve Exp $"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
# include "vpi_priv.h"
|
# include "vpi_priv.h"
|
||||||
|
|
@ -317,6 +317,36 @@ static void binary_vpiStringVal(struct __vpiBinaryConst*rfp, p_vpi_value vp)
|
||||||
vp->value.str = rbuf;
|
vp->value.str = rbuf;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int bits2int(struct __vpiBinaryConst*rfp)
|
||||||
|
{
|
||||||
|
unsigned val = 0;
|
||||||
|
unsigned bit_val = 0;
|
||||||
|
unsigned bit_limit = rfp->nbits;
|
||||||
|
if (bit_limit > 8*sizeof(val))
|
||||||
|
bit_limit = 8*sizeof(val);
|
||||||
|
|
||||||
|
for (unsigned idx = 0 ; idx < bit_limit ; idx += 1) {
|
||||||
|
unsigned nibble = idx/4;
|
||||||
|
unsigned shift = 2 * (idx%4);
|
||||||
|
bit_val = (rfp->bits[nibble] >> shift) & 3;
|
||||||
|
if (bit_val > 1) {
|
||||||
|
return 0;
|
||||||
|
} else {
|
||||||
|
val |= bit_val << idx;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* sign extend */
|
||||||
|
if (rfp->signed_flag && bit_val) {
|
||||||
|
for (unsigned idx = rfp->nbits; idx <sizeof(val)*8; idx++)
|
||||||
|
{
|
||||||
|
val |= bit_val << idx;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return val;
|
||||||
|
}
|
||||||
|
|
||||||
static void binary_value(vpiHandle ref, p_vpi_value vp)
|
static void binary_value(vpiHandle ref, p_vpi_value vp)
|
||||||
{
|
{
|
||||||
assert(ref->vpi_type->type_code == vpiConstant);
|
assert(ref->vpi_type->type_code == vpiConstant);
|
||||||
|
|
@ -385,33 +415,7 @@ static void binary_value(vpiHandle ref, p_vpi_value vp)
|
||||||
}
|
}
|
||||||
|
|
||||||
case vpiIntVal: {
|
case vpiIntVal: {
|
||||||
unsigned val = 0;
|
vp->value.integer = bits2int(rfp);
|
||||||
unsigned bit_val = 0;
|
|
||||||
unsigned bit_limit = rfp->nbits;
|
|
||||||
if (bit_limit > 8*sizeof(val))
|
|
||||||
bit_limit = 8*sizeof(val);
|
|
||||||
|
|
||||||
for (unsigned idx = 0 ; idx < bit_limit ; idx += 1) {
|
|
||||||
unsigned nibble = idx/4;
|
|
||||||
unsigned shift = 2 * (idx%4);
|
|
||||||
bit_val = (rfp->bits[nibble] >> shift) & 3;
|
|
||||||
if (bit_val > 1) {
|
|
||||||
vp->value.integer = 0;
|
|
||||||
return;
|
|
||||||
} else {
|
|
||||||
val |= bit_val << idx;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* sign extend */
|
|
||||||
if (rfp->signed_flag && bit_val) {
|
|
||||||
for (unsigned idx = rfp->nbits; idx <sizeof(val)*8; idx++)
|
|
||||||
{
|
|
||||||
val |= bit_val << idx;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
vp->value.integer = val;
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -458,6 +462,10 @@ static void binary_value(vpiHandle ref, p_vpi_value vp)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
case vpiRealVal:
|
||||||
|
vp->value.real = (double)bits2int(rfp);
|
||||||
|
break;
|
||||||
|
|
||||||
case vpiStringVal:
|
case vpiStringVal:
|
||||||
binary_vpiStringVal(rfp, vp);
|
binary_vpiStringVal(rfp, vp);
|
||||||
break;
|
break;
|
||||||
|
|
@ -633,6 +641,12 @@ vpiHandle vpip_make_dec_const(int value)
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* $Log: vpi_const.cc,v $
|
* $Log: vpi_const.cc,v $
|
||||||
|
* Revision 1.29 2003/05/29 03:46:21 steve
|
||||||
|
* Add tf_getp/putp support for integers
|
||||||
|
* and real valued arguments.
|
||||||
|
*
|
||||||
|
* Add tf_mipname function.
|
||||||
|
*
|
||||||
* Revision 1.28 2003/03/17 23:47:25 steve
|
* Revision 1.28 2003/03/17 23:47:25 steve
|
||||||
* Make a safe copy of const string values.
|
* Make a safe copy of const string values.
|
||||||
*
|
*
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,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: vpi_vthr_vector.cc,v 1.15 2003/05/28 03:10:52 steve Exp $"
|
#ident "$Id: vpi_vthr_vector.cc,v 1.16 2003/05/29 03:46:21 steve Exp $"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
@ -412,6 +412,10 @@ static void vthr_real_get_value(vpiHandle ref, s_vpi_value*vp)
|
||||||
vp->value.real = val;
|
vp->value.real = val;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case vpiIntVal:
|
||||||
|
vp->value.integer = (int)(val + 0.5);
|
||||||
|
break;
|
||||||
|
|
||||||
case vpiDecStrVal:
|
case vpiDecStrVal:
|
||||||
sprintf(rbuf, "%0.0f", val);
|
sprintf(rbuf, "%0.0f", val);
|
||||||
vp->value.str = rbuf;
|
vp->value.str = rbuf;
|
||||||
|
|
@ -447,6 +451,9 @@ static void vthr_real_get_value(vpiHandle ref, s_vpi_value*vp)
|
||||||
}
|
}
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
fprintf(stderr, "vvp error: get %d not supported "
|
||||||
|
"by vpiConstant (Real)\n", vp->format);
|
||||||
|
|
||||||
vp->format = vpiSuppressVal;
|
vp->format = vpiSuppressVal;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
@ -480,6 +487,12 @@ vpiHandle vpip_make_vthr_word(unsigned base, const char*type)
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* $Log: vpi_vthr_vector.cc,v $
|
* $Log: vpi_vthr_vector.cc,v $
|
||||||
|
* Revision 1.16 2003/05/29 03:46:21 steve
|
||||||
|
* Add tf_getp/putp support for integers
|
||||||
|
* and real valued arguments.
|
||||||
|
*
|
||||||
|
* Add tf_mipname function.
|
||||||
|
*
|
||||||
* Revision 1.15 2003/05/28 03:10:52 steve
|
* Revision 1.15 2003/05/28 03:10:52 steve
|
||||||
* Some asserts that check for thread vector overflow.
|
* Some asserts that check for thread vector overflow.
|
||||||
*
|
*
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue