Add support for $rtoi
This commit is contained in:
parent
654ad4c97e
commit
7e9095acf2
|
|
@ -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: sys_convert.c,v 1.1 2003/03/07 02:44:34 steve Exp $"
|
#ident "$Id: sys_convert.c,v 1.2 2003/03/10 23:40:10 steve Exp $"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
# include "vpi_user.h"
|
# include "vpi_user.h"
|
||||||
|
|
@ -25,8 +25,6 @@
|
||||||
# include <stdio.h>
|
# include <stdio.h>
|
||||||
# include <math.h>
|
# include <math.h>
|
||||||
|
|
||||||
/*
|
|
||||||
*/
|
|
||||||
static void double2bits(double real, PLI_UINT32 bits[2])
|
static void double2bits(double real, PLI_UINT32 bits[2])
|
||||||
{
|
{
|
||||||
union conv {
|
union conv {
|
||||||
|
|
@ -57,10 +55,10 @@ static void double2bits(double real, PLI_UINT32 bits[2])
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int sizetf_32 (char*x) { return 32; }
|
||||||
static int sizetf_64 (char*x) { return 64; }
|
static int sizetf_64 (char*x) { return 64; }
|
||||||
|
|
||||||
static int sys_real2bits_compiletf(char *name)
|
static int sys_convert_compiletf(char *name)
|
||||||
{
|
{
|
||||||
vpiHandle call_hand, argv;
|
vpiHandle call_hand, argv;
|
||||||
|
|
||||||
|
|
@ -76,7 +74,7 @@ static int sys_real2bits_compiletf(char *name)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int sys_real2bits_calltf(char *user)
|
static int sys_realtobits_calltf(char *user)
|
||||||
{
|
{
|
||||||
vpiHandle sys, argv, arg;
|
vpiHandle sys, argv, arg;
|
||||||
s_vpi_value value;
|
s_vpi_value value;
|
||||||
|
|
@ -89,10 +87,11 @@ static int sys_real2bits_calltf(char *user)
|
||||||
argv = vpi_iterate(vpiArgument, sys);
|
argv = vpi_iterate(vpiArgument, sys);
|
||||||
arg = vpi_scan(argv);
|
arg = vpi_scan(argv);
|
||||||
|
|
||||||
/* get current value in desired destination format */
|
/* get value */
|
||||||
value.format = vpiRealVal;
|
value.format = vpiRealVal;
|
||||||
vpi_get_value(arg, &value);
|
vpi_get_value(arg, &value);
|
||||||
|
|
||||||
|
/* convert */
|
||||||
double2bits(value.value.real, bits);
|
double2bits(value.value.real, bits);
|
||||||
|
|
||||||
res[0].aval = bits[0];
|
res[0].aval = bits[0];
|
||||||
|
|
@ -109,50 +108,76 @@ static int sys_real2bits_calltf(char *user)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int sys_rtoi_calltf(char *user)
|
||||||
|
{
|
||||||
|
vpiHandle sys, argv, arg;
|
||||||
|
s_vpi_value value;
|
||||||
|
static struct t_vpi_vecval res;
|
||||||
|
|
||||||
|
/* find argument handle */
|
||||||
|
sys = vpi_handle(vpiSysTfCall, 0);
|
||||||
|
argv = vpi_iterate(vpiArgument, sys);
|
||||||
|
arg = vpi_scan(argv);
|
||||||
|
|
||||||
|
/* get value */
|
||||||
|
value.format = vpiRealVal;
|
||||||
|
vpi_get_value(arg, &value);
|
||||||
|
|
||||||
|
/* convert */
|
||||||
|
res.aval = (unsigned)value.value.real;
|
||||||
|
res.bval = 0;
|
||||||
|
|
||||||
|
value.format = vpiVectorVal;
|
||||||
|
value.value.vector = &res;
|
||||||
|
|
||||||
|
/* return converted value */
|
||||||
|
vpi_put_value(sys, &value, 0, vpiNoDelay);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
void sys_convert_register()
|
void sys_convert_register()
|
||||||
{
|
{
|
||||||
s_vpi_systf_data tf_data;
|
s_vpi_systf_data tf_data;
|
||||||
#if 0
|
|
||||||
tf_data.type = vpiSysFunc;
|
tf_data.type = vpiSysFunc;
|
||||||
tf_data.tfname = "$bitstoreal";
|
tf_data.tfname = "$bitstoreal";
|
||||||
tf_data.calltf = sys_convert_calltf;
|
|
||||||
tf_data.compiletf = sys_convert_compiletf;
|
|
||||||
tf_data.sizetf = sizetf_64;
|
tf_data.sizetf = sizetf_64;
|
||||||
tf_data.user_data = "0$bitstoreal";
|
tf_data.compiletf = sys_convert_compiletf;
|
||||||
|
tf_data.calltf = NULL; // sys_bitstoreal_calltf;
|
||||||
|
tf_data.user_data = NULL;
|
||||||
vpi_register_systf(&tf_data);
|
vpi_register_systf(&tf_data);
|
||||||
#endif
|
|
||||||
|
|
||||||
#if 0
|
|
||||||
tf_data.type = vpiSysFunc;
|
tf_data.type = vpiSysFunc;
|
||||||
tf_data.tfname = "$itor";
|
tf_data.tfname = "$itor";
|
||||||
tf_data.calltf = sys_convert_calltf;
|
|
||||||
tf_data.compiletf = sys_convert_compiletf;
|
|
||||||
tf_data.sizetf = sizetf_64;
|
tf_data.sizetf = sizetf_64;
|
||||||
tf_data.user_data = "1$itor";
|
tf_data.compiletf = sys_convert_compiletf;
|
||||||
|
tf_data.calltf = NULL; // sys_itor_calltf;
|
||||||
|
tf_data.user_data = NULL;
|
||||||
vpi_register_systf(&tf_data);
|
vpi_register_systf(&tf_data);
|
||||||
#endif
|
|
||||||
|
|
||||||
tf_data.type = vpiSysFunc;
|
tf_data.type = vpiSysFunc;
|
||||||
tf_data.tfname = "$realtobits";
|
tf_data.tfname = "$realtobits";
|
||||||
tf_data.calltf = sys_real2bits_calltf;
|
|
||||||
tf_data.compiletf = sys_real2bits_compiletf;
|
|
||||||
tf_data.sizetf = sizetf_64;
|
tf_data.sizetf = sizetf_64;
|
||||||
tf_data.user_data = "$realtobits";
|
tf_data.compiletf = sys_convert_compiletf;
|
||||||
|
tf_data.calltf = sys_realtobits_calltf;
|
||||||
|
tf_data.user_data = NULL;
|
||||||
vpi_register_systf(&tf_data);
|
vpi_register_systf(&tf_data);
|
||||||
|
|
||||||
#if 0
|
|
||||||
tf_data.type = vpiSysFunc;
|
tf_data.type = vpiSysFunc;
|
||||||
tf_data.tfname = "$rtoi";
|
tf_data.tfname = "$rtoi";
|
||||||
tf_data.calltf = sys_convert_calltf;
|
|
||||||
tf_data.compiletf = sys_convert_compiletf;
|
|
||||||
tf_data.sizetf = sizetf_32;
|
tf_data.sizetf = sizetf_32;
|
||||||
tf_data.user_data = "3$rtoi";
|
tf_data.compiletf = sys_convert_compiletf;
|
||||||
|
tf_data.calltf = sys_rtoi_calltf;
|
||||||
|
tf_data.user_data = NULL;
|
||||||
vpi_register_systf(&tf_data);
|
vpi_register_systf(&tf_data);
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* $Log: sys_convert.c,v $
|
* $Log: sys_convert.c,v $
|
||||||
|
* Revision 1.2 2003/03/10 23:40:10 steve
|
||||||
|
* Add support for $rtoi
|
||||||
|
*
|
||||||
* Revision 1.1 2003/03/07 02:44:34 steve
|
* Revision 1.1 2003/03/07 02:44:34 steve
|
||||||
* Implement $realtobits.
|
* Implement $realtobits.
|
||||||
*
|
*
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue