diff --git a/Makefile.in b/Makefile.in index 1d7af2777..4d3d1b35a 100644 --- a/Makefile.in +++ b/Makefile.in @@ -16,7 +16,7 @@ # 59 Temple Place - Suite 330 # Boston, MA 02111-1307, USA # -#ident "$Id: Makefile.in,v 1.121 2002/05/15 01:25:07 steve Exp $" +#ident "$Id: Makefile.in,v 1.122 2002/05/19 05:21:00 steve Exp $" # # SHELL = /bin/sh @@ -212,7 +212,7 @@ else WIN32_INSTALL = $(bindir)/iverilog-vpi endif -install: all installdirs $(libdir)/ivl/ivl@EXEEXT@ $(libdir)/ivl/iverilog.conf $(includedir)/ivl_target.h $(includedir)/vpi_user.h $(libdir)/libvpi.a $(WIN32_INSTALL) +install: all installdirs $(libdir)/ivl/ivl@EXEEXT@ $(libdir)/ivl/iverilog.conf $(includedir)/ivl_target.h $(includedir)/vpi_user.h $(includedir)/veriuser.h $(libdir)/libvpi.a $(WIN32_INSTALL) cd vpi ; $(MAKE) install cd ivlpp ; $(MAKE) install cd driver ; $(MAKE) install @@ -238,6 +238,9 @@ $(includedir)/ivl_target.h: $(srcdir)/ivl_target.h $(includedir)/vpi_user.h: $(srcdir)/vpi_user.h $(INSTALL_DATA) $(srcdir)/vpi_user.h $(includedir)/vpi_user.h +$(includedir)/veriuser.h: $(srcdir)/veriuser.h + $(INSTALL_DATA) $(srcdir)/veriuser.h $(includedir)/veriuser.h + # In windows installations, put a few examples and the quick_start # into the destination directory. ifeq (@WIN32@,yes) @@ -264,6 +267,7 @@ uninstall: rm -f $(bindir)/gverilog@EXEEXT@ rm -f $(includedir)/ivl_target.h rm -f $(includedir)/vpi_user.h + rm -f $(includedir)/veriuser.h cd driver ; $(MAKE) uninstall cd vpi ; $(MAKE) uninstall cd ivlpp ; $(MAKE) uninstall diff --git a/autoconf.sh b/autoconf.sh index 9bbdca34e..21b05cff1 100644 --- a/autoconf.sh +++ b/autoconf.sh @@ -9,7 +9,7 @@ echo "Autoconf in root..." autoconf -for dir in vpip vvp tgt-vvp tgt-fpga +for dir in vpip vvp tgt-vvp tgt-fpga libveriuser do echo "Autoconf in $dir..." ( cd $dir ; autoconf ) diff --git a/configure.in b/configure.in index 55ef3f41b..99073bfaf 100644 --- a/configure.in +++ b/configure.in @@ -245,6 +245,6 @@ AC_SUBST(shared) AC_MSG_RESULT($shared) -AC_CONFIG_SUBDIRS(vpip vvp tgt-vvp tgt-fpga) +AC_CONFIG_SUBDIRS(vpip vvp tgt-vvp tgt-fpga libveriuser) AC_OUTPUT(Makefile vpi/Makefile ivlpp/Makefile vvm/Makefile driver/Makefile tgt-null/Makefile tgt-stub/Makefile tgt-verilog/Makefile tgt-pal/Makefile) diff --git a/libveriuser/.cvsignore b/libveriuser/.cvsignore new file mode 100644 index 000000000..af87c8e2f --- /dev/null +++ b/libveriuser/.cvsignore @@ -0,0 +1,4 @@ +Makefile +configure +config.* +dep diff --git a/libveriuser/Makefile.in b/libveriuser/Makefile.in new file mode 100644 index 000000000..696e6d558 --- /dev/null +++ b/libveriuser/Makefile.in @@ -0,0 +1,83 @@ +# +# This source code is free software; you can redistribute it +# and/or modify it in source code form under the terms of the GNU +# Library 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 Library General Public License for more details. +# +# You should have received a copy of the GNU Library 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 +# +#ident "$Id: Makefile.in,v 1.1 2002/05/19 05:21:00 steve Exp $" +# +# +SHELL = /bin/sh + + +prefix = @prefix@ +exec_prefix = @exec_prefix@ +srcdir = @srcdir@ + +VPATH = $(srcdir) + +bindir = @bindir@ +libdir = @libdir@ +includedir = $(prefix)/include + +CC = @CC@ -I$(srcdir) -I$(srcdir)/.. +CXX = @CXX@ -I$(srcdir) -I$(srcdir)/.. +INSTALL = @INSTALL@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_DATA = @INSTALL_DATA@ + +CPPFLAGS = @CPPFLAGS@ @DEFS@ +CXXFLAGS = @CXXFLAGS@ +CFLAGS = @CFLAGS@ +LDFLAGS = @LDFLAGS@ +STRIP = @STRIP@ + +O = finish.o + +all: libveriuser.a + +check: all + +Makefile: Makefile.in config.status + ./config.status + +libveriuser.a: $O + rm -f $@ + ar cvq $@ $O + +%.o: %.c + @[ -d dep ] || mkdir dep + $(CC) -Wall $(CPPFLAGS) $(CFLAGS) -MD -c $< -o $*.o + mv $*.d dep + + +clean: + rm -f *.o dep/*.d libveriuser.a + +distclean: clean + rm -f Makefile config.status config.log config.cache + +install:: all installdirs $(libdir)/libveriuser.a + +$(libdir)/libveriuser.a: ./libveriuser.a + $(INSTALL_DATA) ./libveriuser.a $(libdir)/libveriuser.a + +installdirs: mkinstalldirs + $(srcdir)/mkinstalldirs $(includedir) $(libdir) + +uninstall:: + rm -f $(libdir)/libveriuser.a + +-include $(patsubst %.o, dep/%.d, $O $P) diff --git a/libveriuser/configure.in b/libveriuser/configure.in new file mode 100644 index 000000000..53ea1ad9e --- /dev/null +++ b/libveriuser/configure.in @@ -0,0 +1,20 @@ +AC_INIT(Makefile.in) + +AC_PROG_CC +AC_PROG_INSTALL + +AC_CYGWIN +AC_EXEEXT + +# Darwin requires -no-cpp-precomp +case "${host}" in + *-*-darwin*) + CPPFLAGS="-no-cpp-precomp" + CFLAGS="-no-cpp-precomp" + ;; +esac + +AC_SUBST(EXEEXT) +AC_SUBST(EXTRALIBS) + +AC_OUTPUT(Makefile) diff --git a/libveriuser/finish.c b/libveriuser/finish.c new file mode 100644 index 000000000..4b3716f71 --- /dev/null +++ b/libveriuser/finish.c @@ -0,0 +1,48 @@ +/* + * Copyright (c) 2002 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 + * 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 + */ +#if !defined(WINNT) +#ident "$Id: finish.c,v 1.1 2002/05/19 05:21:00 steve Exp $" +#endif + +# include +# include + + +/* + * Implement tf_dofinish and tf_dostop using vpi functions. + */ +int tf_dofinish(void) +{ + vpi_sim_control(vpiFinish, 0); + return 0; +} + +int tf_dostop(void) +{ + vpi_sim_control(vpiStop, 0); + return 0; +} + +/* + * $Log: finish.c,v $ + * Revision 1.1 2002/05/19 05:21:00 steve + * Start the libveriuser library. + * + */ + diff --git a/libveriuser/mkinstalldirs b/libveriuser/mkinstalldirs new file mode 100755 index 000000000..1f45b4704 --- /dev/null +++ b/libveriuser/mkinstalldirs @@ -0,0 +1,40 @@ +#! /bin/sh +# mkinstalldirs --- make directory hierarchy +# Author: Noah Friedman +# Created: 1993-05-16 +# Public domain + +# $Id: mkinstalldirs,v 1.1 2002/05/19 05:21:00 steve Exp $ + +errstatus=0 + +for file +do + set fnord `echo ":$file" | sed -ne 's/^:\//#/;s/^://;s/\// /g;s/^#/\//;p'` + shift + + pathcomp= + for d + do + pathcomp="$pathcomp$d" + case "$pathcomp" in + -* ) pathcomp=./$pathcomp ;; + esac + + if test ! -d "$pathcomp"; then + echo "mkdir $pathcomp" 1>&2 + + mkdir "$pathcomp" || lasterr=$? + + if test ! -d "$pathcomp"; then + errstatus=$lasterr + fi + fi + + pathcomp="$pathcomp/" + done +done + +exit $errstatus + +# mkinstalldirs ends here diff --git a/verilog.spec b/verilog.spec index 93c278365..dd93b1649 100644 --- a/verilog.spec +++ b/verilog.spec @@ -50,9 +50,11 @@ make prefix=$RPM_BUILD_ROOT/usr install %attr(-,root,root) /usr/lib/libvpi.a %attr(-,root,root) /usr/lib/libvvm.a %attr(-,root,root) /usr/lib/libvpip.a +%attr(-,root,root) /usr/lib/libveriuser.a %attr(-,root,root) /usr/include/ivl_target.h %attr(-,root,root) /usr/include/vpi_priv.h %attr(-,root,root) /usr/include/vpi_user.h +%attr(-,root,root) /usr/include/veriuser.h %attr(-,root,root) /usr/include/vvm.h %attr(-,root,root) /usr/include/vvm_calltf.h %attr(-,root,root) /usr/include/vvm_func.h diff --git a/veriuser.h b/veriuser.h new file mode 100644 index 000000000..a20c4c642 --- /dev/null +++ b/veriuser.h @@ -0,0 +1,55 @@ +#ifndef __veriuser_H +#define __veriuser_H +/* + * Copyright (c) 2002 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 + * 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 + */ +#if !defined(WINNT) && !defined(macintosh) +#ident "$Id: veriuser.h,v 1.1 2002/05/19 05:21:00 steve Exp $" +#endif + +/* + * This header file contains the definitions and declarations needed + * by an Icarus Verilog user using tf_ routines. + * + * NOTE: Icarus Verilog does not support tf_ routines. This is just a + * stub. The functions that are implemented here are actually + * implemented using VPI routines. + */ + +#ifdef __cplusplus +# define EXTERN_C_START extern "C" { +# define EXTERN_C_END } +#else +# define EXTERN_C_START +# define EXTERN_C_END +#endif + +EXTERN_C_START + +extern int tf_dofinish(void); +extern int tf_dostop(void); + +EXTERN_C_END + +/* + * $Log: veriuser.h,v $ + * Revision 1.1 2002/05/19 05:21:00 steve + * Start the libveriuser library. + * + */ +#endif diff --git a/vpithunk.c b/vpithunk.c index 9a85f9d97..ed90d7a04 100644 --- a/vpithunk.c +++ b/vpithunk.c @@ -3,6 +3,26 @@ #include "vpi_user.h" #include "vpithunk.h" +/* + * This code is linked into the VPI module, not the simulator. The + * module uses the symbols defined in here to call implementations + * supplied by the simulator, which loaded this module with dlopen or + * the equivilent. + * + * The vpi_thunk_p pointer points to a table of function pointers that + * point to all the functions that a simulator is expected to provide. + * The vlog_register_sim is a function that the simulator is expected + * to call with a value for the vpi_thunk_p pointer. This is how the + * run time linkage to all the functions in the make program are made. + * + * In Icarus Verilog, the VPI module is also supposed to export a + * vlog_startup_routines table. This is something that the programmer + * does, so the libvpi library, and the vlog_register_sim function, + * are invisible to the user. + * + * The simulator is careful to call the vpi_register_sim function from + * a loaded module before executing the startup routines. + */ static p_vpi_thunk vpi_thunk_p = 0; #define VPITV_CALL(fn,args) { \ @@ -174,4 +194,3 @@ extern int vpi_get_vlog_info(p_vpi_vlog_info vlog_info_p) { VPIT_CALL(vpi_get_vlog_info, 0, (vlog_info_p)); } -