Implement $realtobits.
This commit is contained in:
parent
0aaf0218ca
commit
f40ea15cce
|
|
@ -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
|
||||||
*/
|
*/
|
||||||
#if !defined(WINNT)
|
#if !defined(WINNT)
|
||||||
#ident "$Id: config.h.in,v 1.7 2003/02/20 00:49:24 steve Exp $"
|
#ident "$Id: config.h.in,v 1.8 2003/03/07 02:44:33 steve Exp $"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(__cplusplus)
|
#if defined(__cplusplus)
|
||||||
|
|
@ -46,9 +46,13 @@
|
||||||
# undef HAVE_LIBZ
|
# undef HAVE_LIBZ
|
||||||
# undef HAVE_LIBBZ2
|
# undef HAVE_LIBBZ2
|
||||||
# undef HAVE_SYS_WAIT_H
|
# undef HAVE_SYS_WAIT_H
|
||||||
|
# undef WORD_BIGENDIAN
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* $Log: config.h.in,v $
|
* $Log: config.h.in,v $
|
||||||
|
* Revision 1.8 2003/03/07 02:44:33 steve
|
||||||
|
* Implement $realtobits.
|
||||||
|
*
|
||||||
* Revision 1.7 2003/02/20 00:49:24 steve
|
* Revision 1.7 2003/02/20 00:49:24 steve
|
||||||
* detect -lz and -lbz2 libraries.
|
* detect -lz and -lbz2 libraries.
|
||||||
*
|
*
|
||||||
|
|
|
||||||
|
|
@ -74,6 +74,7 @@ AC_SUBST(DLLIB)
|
||||||
AC_PROG_INSTALL
|
AC_PROG_INSTALL
|
||||||
|
|
||||||
AC_LANG_C
|
AC_LANG_C
|
||||||
|
AC_C_BIGENDIAN
|
||||||
|
|
||||||
AC_CANONICAL_HOST
|
AC_CANONICAL_HOST
|
||||||
# $host
|
# $host
|
||||||
|
|
|
||||||
|
|
@ -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: elab_expr.cc,v 1.69 2003/01/27 05:09:17 steve Exp $"
|
#ident "$Id: elab_expr.cc,v 1.70 2003/03/07 02:44:34 steve Exp $"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
# include "config.h"
|
# include "config.h"
|
||||||
|
|
@ -213,12 +213,14 @@ NetExpr* PECallFunction::elaborate_sfunc_(Design*des, NetScope*scope) const
|
||||||
|
|
||||||
unsigned wid = 32;
|
unsigned wid = 32;
|
||||||
|
|
||||||
if (strcmp(path_.peek_name(0), "$time") == 0)
|
if (strcmp(path_.peek_name(0), "$realtobits") == 0)
|
||||||
wid = 64;
|
wid = 64;
|
||||||
if (strcmp(path_.peek_name(0), "$simtime") == 0)
|
if (strcmp(path_.peek_name(0), "$simtime") == 0)
|
||||||
wid = 64;
|
wid = 64;
|
||||||
if (strcmp(path_.peek_name(0), "$stime") == 0)
|
if (strcmp(path_.peek_name(0), "$stime") == 0)
|
||||||
wid = 32;
|
wid = 32;
|
||||||
|
if (strcmp(path_.peek_name(0), "$time") == 0)
|
||||||
|
wid = 64;
|
||||||
|
|
||||||
|
|
||||||
/* How many parameters are there? The Verilog language allows
|
/* How many parameters are there? The Verilog language allows
|
||||||
|
|
@ -900,6 +902,9 @@ NetExpr* PEUnary::elaborate_expr(Design*des, NetScope*scope, bool) const
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* $Log: elab_expr.cc,v $
|
* $Log: elab_expr.cc,v $
|
||||||
|
* Revision 1.70 2003/03/07 02:44:34 steve
|
||||||
|
* Implement $realtobits.
|
||||||
|
*
|
||||||
* Revision 1.69 2003/01/27 05:09:17 steve
|
* Revision 1.69 2003/01/27 05:09:17 steve
|
||||||
* Spelling fixes.
|
* Spelling fixes.
|
||||||
*
|
*
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,7 @@
|
||||||
# 59 Temple Place - Suite 330
|
# 59 Temple Place - Suite 330
|
||||||
# Boston, MA 02111-1307, USA
|
# Boston, MA 02111-1307, USA
|
||||||
#
|
#
|
||||||
#ident "$Id: Makefile.in,v 1.38 2003/03/06 20:04:42 steve Exp $"
|
#ident "$Id: Makefile.in,v 1.39 2003/03/07 02:44:34 steve Exp $"
|
||||||
#
|
#
|
||||||
#
|
#
|
||||||
SHELL = /bin/sh
|
SHELL = /bin/sh
|
||||||
|
|
@ -57,9 +57,9 @@ dep:
|
||||||
$(CC) -Wall -I$(srcdir) -I.. $(CPPFLAGS) $(CFLAGS) -MD -c $< -o $*.o
|
$(CC) -Wall -I$(srcdir) -I.. $(CPPFLAGS) $(CFLAGS) -MD -c $< -o $*.o
|
||||||
mv $*.d dep
|
mv $*.d dep
|
||||||
|
|
||||||
O = sys_table.o sys_deposit.o sys_display.o sys_finish.o sys_plusargs.o \
|
O = sys_table.o sys_convert.o sys_deposit.o sys_display.o sys_finish.o \
|
||||||
sys_random.o sys_readmem.o sys_readmem_lex.o sys_time.o sys_vcd.o \
|
sys_plusargs.o sys_random.o sys_readmem.o sys_readmem_lex.o sys_time.o \
|
||||||
sys_vcdoff.o sys_lxt.o lxt_write.o vcd_priv.o \
|
sys_vcd.o sys_vcdoff.o sys_lxt.o lxt_write.o vcd_priv.o \
|
||||||
mt19937int.o stringheap.o
|
mt19937int.o stringheap.o
|
||||||
|
|
||||||
LIBS = @LIBS@
|
LIBS = @LIBS@
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,159 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 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
|
||||||
|
* General Public License as published by the Free Software
|
||||||
|
* Foundation; either version 2 of the License, or (at your option)
|
||||||
|
* any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||||
|
*/
|
||||||
|
#ifdef HAVE_CVS_IDENT
|
||||||
|
#ident "$Id: sys_convert.c,v 1.1 2003/03/07 02:44:34 steve Exp $"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
# include "vpi_user.h"
|
||||||
|
# include "config.h"
|
||||||
|
# include <stdio.h>
|
||||||
|
# include <math.h>
|
||||||
|
|
||||||
|
/*
|
||||||
|
*/
|
||||||
|
static void double2bits(double real, PLI_UINT32 bits[2])
|
||||||
|
{
|
||||||
|
union conv {
|
||||||
|
double rval;
|
||||||
|
unsigned char bval[sizeof(double)];
|
||||||
|
} conv;
|
||||||
|
|
||||||
|
conv.rval = real;
|
||||||
|
|
||||||
|
#ifdef WORDS_BIGENDIAN
|
||||||
|
bits[0] = conv.bval[7]
|
||||||
|
| (conv.bval[6] << 8)
|
||||||
|
| (conv.bval[5] <<16)
|
||||||
|
| (conv.bval[4] <<24);
|
||||||
|
bits[1] = conv.bval[3]
|
||||||
|
| (conv.bval[2] << 8)
|
||||||
|
| (conv.bval[1] <<16)
|
||||||
|
| (conv.bval[0] <<24);
|
||||||
|
#else
|
||||||
|
bits[0] = conv.bval[0]
|
||||||
|
| (conv.bval[1] << 8)
|
||||||
|
| (conv.bval[2] <<16)
|
||||||
|
| (conv.bval[3] <<24);
|
||||||
|
bits[1] = conv.bval[4]
|
||||||
|
| (conv.bval[5] << 8)
|
||||||
|
| (conv.bval[6] <<16)
|
||||||
|
| (conv.bval[7] <<24);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static int sizetf_64 (char*x) { return 64; }
|
||||||
|
|
||||||
|
static int sys_real2bits_compiletf(char *name)
|
||||||
|
{
|
||||||
|
vpiHandle call_hand, argv;
|
||||||
|
|
||||||
|
call_hand = vpi_handle(vpiSysTfCall, 0);
|
||||||
|
argv = vpi_iterate(vpiArgument, call_hand);
|
||||||
|
|
||||||
|
if (!argv) {
|
||||||
|
vpi_printf("ERROR: %s requires a parameter.\n",
|
||||||
|
vpi_get_str(vpiName, call_hand));
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int sys_real2bits_calltf(char *user)
|
||||||
|
{
|
||||||
|
vpiHandle sys, argv, arg;
|
||||||
|
s_vpi_value value;
|
||||||
|
static struct t_vpi_vecval res[2];
|
||||||
|
|
||||||
|
PLI_UINT32 bits[2];
|
||||||
|
|
||||||
|
/* find argument handle */
|
||||||
|
sys = vpi_handle(vpiSysTfCall, 0);
|
||||||
|
argv = vpi_iterate(vpiArgument, sys);
|
||||||
|
arg = vpi_scan(argv);
|
||||||
|
|
||||||
|
/* get current value in desired destination format */
|
||||||
|
value.format = vpiRealVal;
|
||||||
|
vpi_get_value(arg, &value);
|
||||||
|
|
||||||
|
double2bits(value.value.real, bits);
|
||||||
|
|
||||||
|
res[0].aval = bits[0];
|
||||||
|
res[0].bval = 0;
|
||||||
|
res[1].aval = bits[1];
|
||||||
|
res[1].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()
|
||||||
|
{
|
||||||
|
s_vpi_systf_data tf_data;
|
||||||
|
#if 0
|
||||||
|
tf_data.type = vpiSysFunc;
|
||||||
|
tf_data.tfname = "$bitstoreal";
|
||||||
|
tf_data.calltf = sys_convert_calltf;
|
||||||
|
tf_data.compiletf = sys_convert_compiletf;
|
||||||
|
tf_data.sizetf = sizetf_64;
|
||||||
|
tf_data.user_data = "0$bitstoreal";
|
||||||
|
vpi_register_systf(&tf_data);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if 0
|
||||||
|
tf_data.type = vpiSysFunc;
|
||||||
|
tf_data.tfname = "$itor";
|
||||||
|
tf_data.calltf = sys_convert_calltf;
|
||||||
|
tf_data.compiletf = sys_convert_compiletf;
|
||||||
|
tf_data.sizetf = sizetf_64;
|
||||||
|
tf_data.user_data = "1$itor";
|
||||||
|
vpi_register_systf(&tf_data);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
tf_data.type = vpiSysFunc;
|
||||||
|
tf_data.tfname = "$realtobits";
|
||||||
|
tf_data.calltf = sys_real2bits_calltf;
|
||||||
|
tf_data.compiletf = sys_real2bits_compiletf;
|
||||||
|
tf_data.sizetf = sizetf_64;
|
||||||
|
tf_data.user_data = "$realtobits";
|
||||||
|
vpi_register_systf(&tf_data);
|
||||||
|
|
||||||
|
#if 0
|
||||||
|
tf_data.type = vpiSysFunc;
|
||||||
|
tf_data.tfname = "$rtoi";
|
||||||
|
tf_data.calltf = sys_convert_calltf;
|
||||||
|
tf_data.compiletf = sys_convert_compiletf;
|
||||||
|
tf_data.sizetf = sizetf_32;
|
||||||
|
tf_data.user_data = "3$rtoi";
|
||||||
|
vpi_register_systf(&tf_data);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* $Log: sys_convert.c,v $
|
||||||
|
* Revision 1.1 2003/03/07 02:44:34 steve
|
||||||
|
* Implement $realtobits.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
@ -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_table.c,v 1.19 2003/03/06 20:04:42 steve Exp $"
|
#ident "$Id: sys_table.c,v 1.20 2003/03/07 02:44:34 steve Exp $"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
# include "config.h"
|
# include "config.h"
|
||||||
|
|
@ -26,6 +26,7 @@
|
||||||
# include <stdlib.h>
|
# include <stdlib.h>
|
||||||
# include <string.h>
|
# include <string.h>
|
||||||
|
|
||||||
|
extern void sys_convert_register();
|
||||||
extern void sys_finish_register();
|
extern void sys_finish_register();
|
||||||
extern void sys_deposit_register();
|
extern void sys_deposit_register();
|
||||||
extern void sys_display_register();
|
extern void sys_display_register();
|
||||||
|
|
@ -113,6 +114,7 @@ static void sys_lxt_or_vcd_register()
|
||||||
}
|
}
|
||||||
|
|
||||||
void (*vlog_startup_routines[])() = {
|
void (*vlog_startup_routines[])() = {
|
||||||
|
sys_convert_register,
|
||||||
sys_finish_register,
|
sys_finish_register,
|
||||||
sys_deposit_register,
|
sys_deposit_register,
|
||||||
sys_display_register,
|
sys_display_register,
|
||||||
|
|
@ -127,6 +129,9 @@ void (*vlog_startup_routines[])() = {
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* $Log: sys_table.c,v $
|
* $Log: sys_table.c,v $
|
||||||
|
* Revision 1.20 2003/03/07 02:44:34 steve
|
||||||
|
* Implement $realtobits.
|
||||||
|
*
|
||||||
* Revision 1.19 2003/03/06 20:04:42 steve
|
* Revision 1.19 2003/03/06 20:04:42 steve
|
||||||
* Add means to suppress wveform output
|
* Add means to suppress wveform output
|
||||||
*
|
*
|
||||||
|
|
@ -151,40 +156,5 @@ void (*vlog_startup_routines[])() = {
|
||||||
* Revision 1.12 2001/07/25 03:10:50 steve
|
* Revision 1.12 2001/07/25 03:10:50 steve
|
||||||
* Create a config.h.in file to hold all the config
|
* Create a config.h.in file to hold all the config
|
||||||
* junk, and support gcc 3.0. (Stephan Boettcher)
|
* junk, and support gcc 3.0. (Stephan Boettcher)
|
||||||
*
|
|
||||||
* Revision 1.11 2001/05/22 02:14:47 steve
|
|
||||||
* Update the mingw build to not require cygwin files.
|
|
||||||
*
|
|
||||||
* Revision 1.10 2001/05/20 15:09:40 steve
|
|
||||||
* Mingw32 support (Venkat Iyer)
|
|
||||||
*
|
|
||||||
* Revision 1.9 2001/04/26 00:01:33 steve
|
|
||||||
* Support $deposit to a wire or reg.
|
|
||||||
*
|
|
||||||
* Revision 1.8 2000/12/14 23:36:34 steve
|
|
||||||
* include vpi_user.h.
|
|
||||||
*
|
|
||||||
* Revision 1.7 2000/11/01 03:19:36 steve
|
|
||||||
* Add the general $time system function.
|
|
||||||
*
|
|
||||||
* Revision 1.6 2000/09/30 03:20:47 steve
|
|
||||||
* Cygwin port changes from Venkat
|
|
||||||
*
|
|
||||||
* Revision 1.5 2000/05/04 03:37:59 steve
|
|
||||||
* Add infrastructure for system functions, move
|
|
||||||
* $time to that structure and add $random.
|
|
||||||
*
|
|
||||||
* Revision 1.4 2000/02/23 02:56:56 steve
|
|
||||||
* Macintosh compilers do not support ident.
|
|
||||||
*
|
|
||||||
* Revision 1.3 1999/12/15 04:01:14 steve
|
|
||||||
* Add the VPI implementation of $readmemh.
|
|
||||||
*
|
|
||||||
* Revision 1.2 1999/11/07 20:33:30 steve
|
|
||||||
* Add VCD output and related system tasks.
|
|
||||||
*
|
|
||||||
* Revision 1.1 1999/08/15 01:23:56 steve
|
|
||||||
* Convert vvm to implement system tasks with vpi.
|
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue