diff --git a/vpi/Makefile.in b/vpi/Makefile.in index 6119b939c..ed719718b 100644 --- a/vpi/Makefile.in +++ b/vpi/Makefile.in @@ -57,7 +57,7 @@ dep: # Object files for system.vpi O = sys_table.o sys_convert.o sys_deposit.o sys_display.o sys_fileio.o \ -sys_finish.o sys_plusargs.o sys_random.o sys_random_mti.o \ +sys_finish.o sys_icarus.o sys_plusargs.o sys_random.o sys_random_mti.o \ sys_readmem.o sys_readmem_lex.o sys_scanf.o sys_sdf.o \ sys_time.o sys_vcd.o sys_vcdoff.o vcd_priv.o \ mt19937int.o priv.o sdf_lexor.o sdf_parse.o stringheap.o diff --git a/vpi/sys_icarus.c b/vpi/sys_icarus.c new file mode 100644 index 000000000..ff6998d5f --- /dev/null +++ b/vpi/sys_icarus.c @@ -0,0 +1,67 @@ +/* + * Copyright (C) 2008 Cary R. (cygcary@yahoo.com) + * + * This program is free software; you can redistribute it and/or modify + * it 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., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +#include "vpi_config.h" +#include +#include + + +/* + * Routine to return the width in bits of a CPU word (long). + */ +static PLI_INT32 vvp_cpu_wordsize_calltf(PLI_BYTE8* ud) +{ + vpiHandle callh = vpi_handle(vpiSysTfCall, 0); + assert(callh != 0); + s_vpi_value val; + (void) ud; /* Not used! */ + + /* Calculate the result */ + val.format = vpiIntVal; + val.value.integer = 8*sizeof(long); + + /* Return the result */ + vpi_put_value(callh, &val, 0, vpiNoDelay); + + return 0; +} + +static PLI_INT32 size_32(PLI_BYTE8* ud) +{ + (void) ud; /* Not used! */ + + return 32; +} + +/* + * Register the function with Verilog. + */ +void sys_special_register(void) +{ + s_vpi_systf_data tf_data; + + /* Register the single argument functions. */ + tf_data.type = vpiSysFunc; + tf_data.sysfunctype = vpiIntFunc; + tf_data.calltf = vvp_cpu_wordsize_calltf; + tf_data.compiletf = 0; + tf_data.sizetf = size_32; + tf_data.tfname = "$vvp_cpu_wordsize"; + tf_data.user_data = 0; + vpi_register_systf(&tf_data); +} diff --git a/vpi/sys_table.c b/vpi/sys_table.c index d9edbe213..9658a469e 100644 --- a/vpi/sys_table.c +++ b/vpi/sys_table.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999 Stephen Williams (steve@icarus.com) + * Copyright (c) 1999-2008 Stephen Williams (steve@icarus.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 @@ -16,9 +16,6 @@ * 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_table.c,v 1.26 2006/08/03 05:06:04 steve Exp $" -#endif # include "vpi_config.h" # include "vpi_user.h" @@ -40,6 +37,7 @@ extern void sys_sdf_register(); extern void sys_time_register(); extern void sys_vcd_register(); extern void sys_vcdoff_register(); +extern void sys_special_register(); #ifdef HAVE_LIBZ #ifdef HAVE_LIBBZ2 @@ -181,6 +179,6 @@ void (*vlog_startup_routines[])() = { sys_time_register, sys_lxt_or_vcd_register, sys_sdf_register, + sys_special_register, 0 }; - diff --git a/vpi/system.sft b/vpi/system.sft index 76f82bd30..555f7cc37 100644 --- a/vpi/system.sft +++ b/vpi/system.sft @@ -14,3 +14,4 @@ $dist_poisson vpiSysFuncInt $dist_chi_square vpiSysFuncInt $dist_t vpiSysFuncInt $dist_erlang vpiSysFuncInt +$vvp_cpu_wordsize vpiSysFuncInt