diff --git a/libveriuser/getp.c b/libveriuser/getp.c index cd65a7481..857d4bb5d 100644 --- a/libveriuser/getp.c +++ b/libveriuser/getp.c @@ -17,10 +17,11 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ #ifdef HAVE_CVS_IDENT -#ident "$Id: getp.c,v 1.4 2003/05/29 03:46:21 steve Exp $" +#ident "$Id: getp.c,v 1.5 2003/05/30 04:22:13 steve Exp $" #endif # include +# include # include # include # include "priv.h" @@ -127,8 +128,68 @@ double tf_getrealp(PLI_INT32 n) } +char *tf_istrgetp(PLI_INT32 n, PLI_INT32 fmt, void *obj) +{ + vpiHandle sys_h, sys_i, arg_h = 0; + s_vpi_value value; + char *rtn = 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) + { + value.format = vpiStringVal; + vpi_get_value(arg_h, &value); + rtn = value.value.str; + } else { + value.format = -1; + switch (tolower(fmt)) { + case 'b': value.format = vpiBinStrVal; break; + case 'o': value.format = vpiOctStrVal; break; + case 'd': value.format = vpiDecStrVal; break; + case 'h': value.format = vpiHexStrVal; break; + } + if (value.format > 0) { + vpi_get_value(arg_h, &value); + rtn = value.value.str; + } + } + + vpi_free_object(sys_i); + +out: + if (pli_trace) { + fprintf(pli_trace, "tf_istrgetp(n=%d, fmt=%c, obj=%p) --> \"%s\"\n", + n, fmt, obj, rtn); + fflush(pli_trace); + } + + return rtn; +} + +char *tf_strgetp(PLI_INT32 n, PLI_INT32 fmt) +{ + char *rtn = tf_istrgetp(n, fmt, vpi_handle(vpiSysTfCall, 0)); + + return rtn; +} + /* * $Log: getp.c,v $ + * Revision 1.5 2003/05/30 04:22:13 steve + * Add tf_strgetp functions. + * * Revision 1.4 2003/05/29 03:46:21 steve * Add tf_getp/putp support for integers * and real valued arguments. diff --git a/veriuser.h b/veriuser.h index 5a8253ea6..843e63656 100644 --- a/veriuser.h +++ b/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.30 2003/05/30 04:18:31 steve Exp $" +#ident "$Id: veriuser.h,v 1.31 2003/05/30 04:22:13 steve Exp $" #endif /* @@ -257,6 +257,9 @@ extern PLI_INT32 tf_igetp(PLI_INT32, void*); extern double tf_getrealp(PLI_INT32); extern double tf_igetrealp(PLI_INT32, void*); +extern char *tf_strgetp(PLI_INT32, PLI_INT32); +extern char *tf_istrgetp(PLI_INT32, PLI_INT32, void*); + extern char *tf_strgettime(void); extern PLI_INT32 tf_gettime(void); @@ -329,6 +332,9 @@ EXTERN_C_END /* * $Log: veriuser.h,v $ + * Revision 1.31 2003/05/30 04:22:13 steve + * Add tf_strgetp functions. + * * Revision 1.30 2003/05/30 04:18:31 steve * Add acc_next function. * diff --git a/vvp/vpi_const.cc b/vvp/vpi_const.cc index 18d7e31bf..5904d7119 100644 --- a/vvp/vpi_const.cc +++ b/vvp/vpi_const.cc @@ -17,7 +17,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ #ifdef HAVE_CVS_IDENT -#ident "$Id: vpi_const.cc,v 1.29 2003/05/29 03:46:21 steve Exp $" +#ident "$Id: vpi_const.cc,v 1.30 2003/05/30 04:22:13 steve Exp $" #endif # include "vpi_priv.h" @@ -414,6 +414,15 @@ static void binary_value(vpiHandle ref, p_vpi_value vp) break; } + case vpiOctStrVal: { + unsigned nchar = (rfp->nbits+2)/3; + rbuf = need_result_buf(nchar + 1, RBUF_VAL); + vpip_bits_to_oct_str(rfp->bits, rfp->nbits, + rbuf, nchar+1, rfp->signed_flag); + vp->value.str = rbuf; + break; + } + case vpiIntVal: { vp->value.integer = bits2int(rfp); break; @@ -641,6 +650,9 @@ vpiHandle vpip_make_dec_const(int value) /* * $Log: vpi_const.cc,v $ + * Revision 1.30 2003/05/30 04:22:13 steve + * Add tf_strgetp functions. + * * Revision 1.29 2003/05/29 03:46:21 steve * Add tf_getp/putp support for integers * and real valued arguments.