diff --git a/Makefile.in b/Makefile.in index c5877702b..62599bf25 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.96 2001/05/20 15:09:39 steve Exp $" +#ident "$Id: Makefile.in,v 1.97 2001/06/12 03:53:10 steve Exp $" # # SHELL = /bin/sh @@ -59,7 +59,7 @@ TARGETS += tgt-pal endif -all: ivl@EXEEXT@ +all: ivl@EXEEXT@ libvpi.a for dir in $(SUBDIRS); do (cd $$dir ; $(MAKE) all); done cd vvm ; $(MAKE) all cd vpi ; $(MAKE) all @@ -120,6 +120,10 @@ Makefile: Makefile.in config.status ./config.status +libvpi.a: vpithunk.o + rm -f $@ + ar cvq $@ vpithunk.o + ifeq (@WIN32@,yes) ivl@EXEEXT@: $O ivl.def dlltool --dllname ivl@EXEEXT@ --def ivl.def \ @@ -160,7 +164,7 @@ lexor_keyword.cc: lexor_keyword.gperf gperf -o -i 7 -C -k 1-3,$$ -L ANSI-C -H keyword_hash -N check_identifier -t $(srcdir)/lexor_keyword.gperf > lexor_keyword.cc || (rm -f lexor_keyword.cc ; false) -install: all installdirs $(libdir)/ivl/ivl@EXEEXT@ $(libdir)/ivl/iverilog.conf $(includedir)/ivl_target.h $(includedir)/vpi_user.h +install: all installdirs $(libdir)/ivl/ivl@EXEEXT@ $(libdir)/ivl/iverilog.conf $(includedir)/ivl_target.h $(includedir)/vpi_user.h $(libdir)/libvpi.a cd vvm ; $(MAKE) install cd vpi ; $(MAKE) install cd ivlpp ; $(MAKE) install @@ -168,6 +172,9 @@ install: all installdirs $(libdir)/ivl/ivl@EXEEXT@ $(libdir)/ivl/iverilog.conf $ for tgt in $(SUBDIRS); do (cd $$tgt ; $(MAKE) install); done for tgt in $(TARGETS); do (cd $$tgt ; $(MAKE) install); done +$(libdir)/libvpi.a : ./libvpi.a + $(INSTALL_DATA) libvpi.a $(libdir)/libvpi.a + $(libdir)/ivl/ivl@EXEEXT@: ./ivl@EXEEXT@ $(INSTALL_PROGRAM) ./ivl@EXEEXT@ $(libdir)/ivl/ivl@EXEEXT@ $(STRIP) $(libdir)/ivl/ivl@EXEEXT@ @@ -199,3 +206,4 @@ uninstall: -include $(patsubst %.o, dep/%.d, $O) +-include $(patsubst %.o, dep/%.d, vpithunk.o) diff --git a/driver/main.c b/driver/main.c index 98a6a5d04..bd545f71b 100644 --- a/driver/main.c +++ b/driver/main.c @@ -17,7 +17,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ #if !defined(WINNT) -#ident "$Id: main.c,v 1.13 2001/05/20 18:22:02 steve Exp $" +#ident "$Id: main.c,v 1.14 2001/06/12 03:53:10 steve Exp $" #endif const char HELP[] = @@ -105,6 +105,8 @@ FILE *fp; char line[MAXSIZE]; char tmp[MAXSIZE]; +static char ivl_install_dir[MAXSIZE]; + /* * This is the default target type. It looks up the bits that are * needed to run the command from the configuration file (which is @@ -204,9 +206,9 @@ static int t_vvm(char*cmd, unsigned ncmd) } } - sprintf(tmp, "%s " RDYNAMIC " -fno-exceptions -o %s -I%s " - "-L%s %s.cc -lvvm -lvpip %s", CXX, opath, IVL_INC, IVL_LIB, - opath, DLLIB); + sprintf(tmp, "%s " RDYNAMIC " -s -fno-exceptions -o %s -I%s%s%s " + "-L%s%s%s %s.cc -lvvm -lvpip %s", CXX, opath, ivl_install_dir, + sep, "include", ivl_install_dir, sep, "lib", opath, DLLIB); if (verbose_flag) printf("compile: %s\n", tmp); @@ -451,12 +453,14 @@ int main(int argc, char **argv) #ifdef __MINGW32__ { - char basepath[1024],*s; + static char basepath[1024],*s; GetModuleFileName(NULL,basepath,1024); /* Get to the end. Search back twice for backslashes */ s = basepath + strlen(basepath); while (*s != '\\') s--; s--; while (*s != '\\') s--; + *s = '\0'; + strcpy(ivl_install_dir, basepath); strcpy(s,"\\lib\\ivl"); base = basepath; } @@ -596,6 +600,10 @@ int main(int argc, char **argv) /* * $Log: main.c,v $ + * Revision 1.14 2001/06/12 03:53:10 steve + * Change the VPI call process so that loaded .vpi modules + * use a function table instead of implicit binding. + * * Revision 1.13 2001/05/20 18:22:02 steve * Fix WIFEXITED macro. * diff --git a/t-vvm.cc b/t-vvm.cc index ef07bb99d..7d46db502 100644 --- a/t-vvm.cc +++ b/t-vvm.cc @@ -17,7 +17,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ #if !defined(WINNT) && !defined(macintosh) -#ident "$Id: t-vvm.cc,v 1.207 2001/05/20 15:09:39 steve Exp $" +#ident "$Id: t-vvm.cc,v 1.208 2001/06/12 03:53:10 steve Exp $" #endif # include @@ -1128,14 +1128,18 @@ int target_vvm::end_design(const Design*mod) out << "// **** end start_code" << endl; + out << "main(int argc, char*argv[])" << endl << "{" << endl; + out << " void vvm_vpi_init(void);" << endl; out << " vpip_set_vlog_info(argc, argv);" << endl; string vpi_module_path = mod->get_flag("VPI_MODULE_PATH"); if (vpi_module_path.length() > 0) out << " vvm_set_module_path(\"" << stresc(vpi_module_path) << "\");" << endl; + + out << " vvm_vpi_init();" << endl; string vpi_module_list = mod->get_flag("VPI_MODULE_LIST"); while (vpi_module_list.length()) { @@ -3634,6 +3638,10 @@ extern const struct target tgt_vvm = { }; /* * $Log: t-vvm.cc,v $ + * Revision 1.208 2001/06/12 03:53:10 steve + * Change the VPI call process so that loaded .vpi modules + * use a function table instead of implicit binding. + * * Revision 1.207 2001/05/20 15:09:39 steve * Mingw32 support (Venkat Iyer) * diff --git a/verilog.spec b/verilog.spec index d1dda0675..fd0749829 100644 --- a/verilog.spec +++ b/verilog.spec @@ -44,6 +44,7 @@ make prefix=$RPM_BUILD_ROOT/usr install %attr(-,root,root) /usr/lib/ivl/null.tgt %attr(-,root,root) /usr/lib/ivl/vvp.tgt %attr(-,root,root) /usr/lib/ivl/iverilog.conf +%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/include/ivl_target.h diff --git a/vpi/Makefile.in b/vpi/Makefile.in index d03c445a4..d6b8efe17 100644 --- a/vpi/Makefile.in +++ b/vpi/Makefile.in @@ -18,7 +18,7 @@ # 59 Temple Place - Suite 330 # Boston, MA 02111-1307, USA # -#ident "$Id: Makefile.in,v 1.26 2001/05/20 15:09:40 steve Exp $" +#ident "$Id: Makefile.in,v 1.27 2001/06/12 03:53:10 steve Exp $" # # SHELL = /bin/sh @@ -57,16 +57,8 @@ O = sys_table.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 \ mt19937int.o -ifeq (@WIN32@,yes) - SYSTEM_VPI_LDFLAGS= -L../vvm -lvvm -L../vpip -lvpip @EXTRALIBS@ - VPI_DEPLIBS=../vpip/libvpip.a ../vvm/libvvm.a -else - SYSTEM_VPI_LDFLAGS= - VPI_DEPLIBS= -endif - -system.vpi: $O $(VPI_DEPLIBS) - $(CC) @shared@ -o $@ $O $(SYSTEM_VPI_LDFLAGS) +system.vpi: $O ../libvpi.a + $(CC) @shared@ -o $@ $O -L.. -lvpi -liberty sys_readmem_lex.c: sys_readmem_lex.lex flex -t -Preadmem $(srcdir)/sys_readmem_lex.lex > sys_readmem_lex.c diff --git a/vpip/Makefile.in b/vpip/Makefile.in index ba5065d90..1919519af 100644 --- a/vpip/Makefile.in +++ b/vpip/Makefile.in @@ -18,7 +18,7 @@ # 59 Temple Place - Suite 330 # Boston, MA 02111-1307, USA # -#ident "$Id: Makefile.in,v 1.5 2001/05/20 17:13:27 steve Exp $" +#ident "$Id: Makefile.in,v 1.6 2001/06/12 03:53:10 steve Exp $" # # SHELL = /bin/sh @@ -53,15 +53,6 @@ vpi_mcd.o vpi_vlog_info.o -ifeq (@WIN32@,yes) -# In the DOS world, we make libvpip differently. -all: libvpip.a vpip.dll - -libvpip.a vpip.dll: $P vpip.def - $(CC) @shared@,--out-implib,libvpip.a -o vpip.dll vpip.def $P - -else - all: libvpip.a check: all @@ -73,7 +64,6 @@ libvpip.a: $P ld -r -o vpip.o $P rm -f $@ ar cvq $@ vpip.o -endif libvvm.a: $O rm -f $@ @@ -86,7 +76,7 @@ libvvm.a: $O clean: - rm -f *.o dep/*.d libvpip.a vpip.dll + rm -f *.o dep/*.d libvpip.a distclean: clean rm -f Makefile config.status config.log config.cache @@ -98,15 +88,6 @@ install:: all installdirs \ $(libdir)/libvpip.a: ./libvpip.a $(INSTALL_DATA) ./libvpip.a $(libdir)/libvpip.a -ifeq (@WIN32@,yes) -install :: $(bindir)/vpip.dll - -$(bindir)/vpip.dll: ./vpip.dll - $(INSTALL_PROGRAM) ./vpip.dll $(bindir)/vpip.dll - $(STRIP) $(bindir)/vpip.dll - -endif - $(includedir)/vpi_priv.h: $(srcdir)/vpi_priv.h $(INSTALL_DATA) $(srcdir)/vpi_priv.h $(includedir)/vpi_priv.h diff --git a/vpip/vpi_mcd.c b/vpip/vpi_mcd.c index 999f8cd12..bbc46f03c 100644 --- a/vpip/vpi_mcd.c +++ b/vpip/vpi_mcd.c @@ -17,7 +17,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ #if !defined(WINNT) && !defined(macintosh) -#ident "$Id: vpi_mcd.c,v 1.2 2001/03/22 02:23:45 steve Exp $" +#ident "$Id: vpi_mcd.c,v 1.3 2001/06/12 03:53:10 steve Exp $" #endif # include "vpi_priv.h" @@ -79,11 +79,6 @@ char *vpi_mcd_name(unsigned int mcd) return NULL; } -unsigned int vpi_mcd_open(char *name) -{ - return vpi_mcd_open_x(name, "w"); -} - unsigned int vpi_mcd_open_x(char *name, char *mode) { int i; @@ -101,15 +96,18 @@ got_entry: return 1<>i) & 1) { if(mcd_table[i].fp) @@ -118,8 +116,6 @@ int vpi_mcd_printf(unsigned int mcd, const char*fmt, ...) rc = EOF; } } - va_end(ap); - if(rc) return rc; else diff --git a/vpip/vpi_priv.c b/vpip/vpi_priv.c index 51d78d982..e6dd06d63 100644 --- a/vpip/vpi_priv.c +++ b/vpip/vpi_priv.c @@ -17,7 +17,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ #if !defined(WINNT) && !defined(macintosh) -#ident "$Id: vpi_priv.c,v 1.1 2001/03/14 19:27:44 steve Exp $" +#ident "$Id: vpi_priv.c,v 1.2 2001/06/12 03:53:10 steve Exp $" #endif # include "vpi_priv.h" @@ -202,14 +202,20 @@ vpiHandle vpi_handle_by_index(vpiHandle ref, int idx) return (ref->vpi_type->index_)(ref, idx); } -void vpi_printf(const char*fmt, ...) +extern void vpi_vprintf(const char*fmt, va_list ap) { - va_list ap; - va_start(ap, fmt); vprintf(fmt, ap); - va_end(ap); } +extern void vpi_printf(const char *fmt, ...) +{ + va_list ap; + va_start(fmt,ap); + vpi_vprintf(fmt,ap); + va_end(ap); +} + + /* * This function adds the information that the user supplies to a list * that I keep. @@ -235,6 +241,10 @@ void vpi_register_systf(const struct t_vpi_systf_data*systf) /* * $Log: vpi_priv.c,v $ + * Revision 1.2 2001/06/12 03:53:10 steve + * Change the VPI call process so that loaded .vpi modules + * use a function table instead of implicit binding. + * * Revision 1.1 2001/03/14 19:27:44 steve * Rearrange VPI support libraries. * diff --git a/vpip/vpi_simulation.c b/vpip/vpi_simulation.c index 4fd1b1f56..6c1b79834 100644 --- a/vpip/vpi_simulation.c +++ b/vpip/vpi_simulation.c @@ -17,11 +17,12 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ #if !defined(WINNT) && !defined(macintosh) -#ident "$Id: vpi_simulation.c,v 1.1 2001/03/14 19:27:44 steve Exp $" +#ident "$Id: vpi_simulation.c,v 1.2 2001/06/12 03:53:10 steve Exp $" #endif # include "vpi_priv.h" # include +# include # include struct vpip_event { @@ -39,7 +40,7 @@ struct vpip_simulation *vpip_get_simulation_obj(void) -void vpi_sim_control(int func, ...) +extern void vpi_sim_vcontrol(int func, va_list ap) { switch (func) { case vpiFinish: @@ -210,6 +211,10 @@ void vpip_simulation_run() /* * $Log: vpi_simulation.c,v $ + * Revision 1.2 2001/06/12 03:53:10 steve + * Change the VPI call process so that loaded .vpi modules + * use a function table instead of implicit binding. + * * Revision 1.1 2001/03/14 19:27:44 steve * Rearrange VPI support libraries. * diff --git a/vpithunk.c b/vpithunk.c new file mode 100644 index 000000000..70c350f70 --- /dev/null +++ b/vpithunk.c @@ -0,0 +1,172 @@ +#include +#include +#include "vpi_user.h" +#include "vpithunk.h" + +static p_vpi_thunk vpi_thunk_p = 0; + +#define VPITV_CALL(fn,args) { \ + if (vpi_thunk_p == 0) { \ + fprintf(stderr, "No Simulator registered, cannot handle vpi " \ + "call to " #fn "\n"); \ + return; \ + } \ + if (vpi_thunk_p->fn == 0) { \ + fprintf(stderr, "Simulator doesn't have a " #fn " function\n"); \ + return; \ + } \ + vpi_thunk_p->fn args; \ +} + +#define VPIT_CALL(fn,def,args) { \ + if (vpi_thunk_p == 0) { \ + fprintf(stderr, "No Simulator registered, cannot handle vpi " \ + "call to " #fn "\n"); \ + return def; \ + } \ + if (vpi_thunk_p->fn == 0) { \ + fprintf(stderr, "Simulator doesn't have a " #fn " function\n"); \ + return; \ + } \ + return vpi_thunk_p->fn args; \ +} + +DLLEXPORT int vpi_register_sim(p_vpi_thunk tp) +{ + vpi_thunk_p = 0; + if (tp->magic != VPI_THUNK_MAGIC) { + fprintf(stderr, "Thunk Magic Number mismatch. Got %08X, expected %08x\n", + tp->magic, VPI_THUNK_MAGIC); + return 0; + } + vpi_thunk_p = tp; + return 1; +} + +void vpi_register_systf(const struct t_vpi_systf_data *ss) +{ + VPITV_CALL(vpi_register_systf,(ss)); +} + +void vpi_printf(const char *fmt, ...) +{ + va_list ap; + va_start(ap, fmt); + VPITV_CALL(vpi_vprintf,(fmt,ap)); + va_end(ap); +} + +unsigned int vpi_mcd_close(unsigned int mcd) +{ + VPIT_CALL(vpi_mcd_close,-1,(mcd)); +} + + +char *vpi_mcd_name(unsigned int mcd) +{ + VPIT_CALL(vpi_mcd_name,0,(mcd)); +} + +unsigned int vpi_mcd_open(char *name) +{ + VPIT_CALL(vpi_mcd_open,-1,(name)); +} + +unsigned int vpi_mcd_open_x(char *name, char *mode) +{ + VPIT_CALL(vpi_mcd_open_x,-1, (name, mode)); +} + +int vpi_mcd_printf(unsigned int mcd, const char *fmt, ...) +{ + va_list ap; + va_start(ap, fmt); + VPIT_CALL(vpi_mcd_vprintf,0,(mcd,fmt,ap)); + va_end(ap); /* bad - never hit */ +} + +int vpi_mcd_fputc(unsigned int mcd, unsigned char x) +{ + VPIT_CALL(vpi_mcd_fputc, 0, (mcd, x)); +} + +int vpi_mcd_fgetc(unsigned int mcd) +{ + VPIT_CALL(vpi_mcd_fgetc, -1, (mcd)); +} + +extern vpiHandle vpi_register_cb(p_cb_data data) +{ + VPIT_CALL(vpi_register_cb,0,(data)); +} + +extern int vpi_remove_cb(vpiHandle ref) +{ + VPIT_CALL(vpi_remove_cb,0,(ref)); +} + +extern void vpi_sim_control(int operation, ...) +{ + va_list ap; + va_start(ap, operation); + VPITV_CALL(vpi_sim_vcontrol,(operation,ap)); + va_end(ap); /* bad - never hit */ +} + +extern vpiHandle vpi_handle(int type, vpiHandle ref) +{ + VPIT_CALL(vpi_handle, 0, (type, ref)); +} + +extern vpiHandle vpi_iterate(int type, vpiHandle ref) +{ + VPIT_CALL(vpi_iterate, 0, (type, ref)); +} + +extern vpiHandle vpi_scan(vpiHandle iter) +{ + VPIT_CALL(vpi_scan, 0, (iter)); +} + +extern vpiHandle vpi_handle_by_index(vpiHandle ref, int index) +{ + VPIT_CALL(vpi_handle_by_index,0,(ref, index)); +} + +extern void vpi_get_time(vpiHandle obj, s_vpi_time*t) +{ + VPITV_CALL(vpi_get_time, (obj,t)); +} + +extern int vpi_get(int property, vpiHandle ref) +{ + VPIT_CALL(vpi_get, 0, (property, ref)); + +} + +extern char* vpi_get_str(int property, vpiHandle ref) +{ + VPIT_CALL(vpi_get_str, 0, (property,ref)); +} + +extern void vpi_get_value(vpiHandle expr, p_vpi_value value) +{ + VPITV_CALL(vpi_get_value, (expr, value)); +} + +extern vpiHandle vpi_put_value(vpiHandle obj, p_vpi_value value, + p_vpi_time when, int flags) +{ + VPIT_CALL(vpi_put_value, 0, (obj, value, when, flags)); +} + +extern int vpi_free_object(vpiHandle ref) +{ + VPIT_CALL(vpi_free_object, -1, (ref)); +} + +extern int vpi_get_vlog_info(p_vpi_vlog_info vlog_info_p) +{ + VPIT_CALL(vpi_get_vlog_info, 0, (vlog_info_p)); +} + diff --git a/vpithunk.h b/vpithunk.h new file mode 100644 index 000000000..163f5291a --- /dev/null +++ b/vpithunk.h @@ -0,0 +1,51 @@ +#ifndef _VPI_THUNK_H_ +#define _VPI_THUNK_H_ 1 + +/* These functions are actually defined in lieu of the vpi functions + by the simulator. These prototypes should'nt go into vpi_user.h, + because we don't want the users to be seeing this stuff. They + are non-standard. We have to put them here, so that + including vpi_user.h doesn't require including stdarg.h */ + +EXTERN_C_START + +# include +extern void vpi_vprintf(const char*fmt, va_list ap); +extern int vpi_mcd_vprintf(unsigned int mcd, const char*fmt, va_list ap); +extern void vpi_sim_vcontrol(int operation, va_list ap); + +EXTERN_C_END + +#define VPI_THUNK_MAGIC (0x87836BA4) + +typedef struct { + int magic; + void (*vpi_register_systf)(const struct t_vpi_systf_data*ss); + void (*vpi_vprintf)(const char*fmt, va_list ap); + unsigned int (*vpi_mcd_close)(unsigned int mcd); + char *(*vpi_mcd_name)(unsigned int mcd); + unsigned int (*vpi_mcd_open)(char *name); + unsigned int (*vpi_mcd_open_x)(char *name, char *mode); + int (*vpi_mcd_vprintf)(unsigned int mcd, const char*fmt, va_list ap); + int (*vpi_mcd_fputc)(unsigned int mcd, unsigned char x); + int (*vpi_mcd_fgetc)(unsigned int mcd); + vpiHandle (*vpi_register_cb)(p_cb_data data); + int (*vpi_remove_cb)(vpiHandle ref); + void (*vpi_sim_vcontrol)(int operation, va_list ap); + vpiHandle (*vpi_handle)(int type, vpiHandle ref); + vpiHandle (*vpi_iterate)(int type, vpiHandle ref); + vpiHandle (*vpi_scan)(vpiHandle iter); + vpiHandle (*vpi_handle_by_index)(vpiHandle ref, int index); + void (*vpi_get_time)(vpiHandle obj, s_vpi_time*t); + int (*vpi_get)(int property, vpiHandle ref); + char* (*vpi_get_str)(int property, vpiHandle ref); + void (*vpi_get_value)(vpiHandle expr, p_vpi_value value); + vpiHandle (*vpi_put_value)(vpiHandle obj, p_vpi_value value, + p_vpi_time when, int flags); + int (*vpi_free_object)(vpiHandle ref); + int (*vpi_get_vlog_info)(p_vpi_vlog_info vlog_info_p); +} vpi_thunk, *p_vpi_thunk; + +DLLEXPORT int vpi_register_sim(p_vpi_thunk tp); + +#endif diff --git a/vvm/Makefile.in b/vvm/Makefile.in index 6cc510a28..392a77d4b 100644 --- a/vvm/Makefile.in +++ b/vvm/Makefile.in @@ -18,7 +18,7 @@ # 59 Temple Place - Suite 330 # Boston, MA 02111-1307, USA # -#ident "$Id: Makefile.in,v 1.43 2001/03/19 04:37:59 steve Exp $" +#ident "$Id: Makefile.in,v 1.44 2001/06/12 03:53:10 steve Exp $" # # SHELL = /bin/sh @@ -50,7 +50,8 @@ STRIP = @STRIP@ O = vvm_add_sub.o vvm_bit.o vvm_calltf.o vvm_clshift.o vvm_compare.o \ vvm_event.o vvm_ff.o vvm_force.o \ vvm_func.o vvm_gates.o vvm_idiv.o vvm_imod.o vvm_memory.o vvm_mult.o \ -vvm_mux.o vvm_nexus.o vvm_pevent.o vvm_signal.o vvm_thread.o vvm_udp.o +vvm_mux.o vvm_nexus.o vvm_pevent.o vvm_signal.o vvm_thread.o vvm_udp.o \ +vvm_vpi.o all: libvvm.a diff --git a/vvm/vvm_calltf.cc b/vvm/vvm_calltf.cc index feec05136..889f7427c 100644 --- a/vvm/vvm_calltf.cc +++ b/vvm/vvm_calltf.cc @@ -17,7 +17,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ #if !defined(WINNT) && !defined(macintosh) -#ident "$Id: vvm_calltf.cc,v 1.12 2001/01/14 17:12:59 steve Exp $" +#ident "$Id: vvm_calltf.cc,v 1.13 2001/06/12 03:53:10 steve Exp $" #endif # include "machine.h" @@ -32,6 +32,7 @@ # include # include # include "ivl_dlfcn.h" +# include "vpithunk.h" # define MAX_PATHLEN 1024 @@ -60,6 +61,7 @@ void vvm_set_module_path(const char*path) * tried. If you wish '.' be in th search path, include it. */ typedef void (*vlog_startup_routines_t)(void); +typedef int (*vpi_register_sim_t)(p_vpi_thunk tp); void vvm_load_vpi_module(const char*name) { @@ -100,6 +102,21 @@ void vvm_load_vpi_module(const char*name) return; } + void *regsub = ivl_dlsym(mod, LU "vpi_register_sim" TU); + vpi_register_sim_t simreg = (vpi_register_sim_t)regsub; + if (regsub == 0) { + cerr << name << ": Unable to locate vpi_register_sim" << endl; + ivl_dlclose(mod); + return; + } + + extern vpi_thunk vvmt; + if (((simreg)(&vvmt)) == 0) { + cerr << name << ": vpi_register_sim returned zero" << endl; + ivl_dlclose(mod); + return; + } + void*table = ivl_dlsym(mod, LU "vlog_startup_routines" TU); vlog_startup_routines_t*routines = (vlog_startup_routines_t*)table; if (routines == 0) { @@ -109,6 +126,7 @@ void vvm_load_vpi_module(const char*name) return; } + for (unsigned idx = 0 ; routines[idx] ; idx += 1) (routines[idx])(); } @@ -117,6 +135,10 @@ void vvm_load_vpi_module(const char*name) /* * $Log: vvm_calltf.cc,v $ + * Revision 1.13 2001/06/12 03:53:10 steve + * Change the VPI call process so that loaded .vpi modules + * use a function table instead of implicit binding. + * * Revision 1.12 2001/01/14 17:12:59 steve * possible HP/UX portability support. * diff --git a/vvm/vvm_vpi.cc b/vvm/vvm_vpi.cc new file mode 100644 index 000000000..bd0901b4c --- /dev/null +++ b/vvm/vvm_vpi.cc @@ -0,0 +1,33 @@ +#include +#include "vpi_user.h" +#include "vpithunk.h" + +vpi_thunk vvmt; + +void vvm_vpi_init() +{ + vvmt.magic = VPI_THUNK_MAGIC; + vvmt.vpi_register_systf = vpi_register_systf; + vvmt.vpi_vprintf = vpi_vprintf; + vvmt.vpi_mcd_close = vpi_mcd_close; + vvmt.vpi_mcd_name = vpi_mcd_name; + vvmt.vpi_mcd_open = vpi_mcd_open; + vvmt.vpi_mcd_open_x = vpi_mcd_open_x; + vvmt.vpi_mcd_vprintf = vpi_mcd_vprintf; + vvmt.vpi_mcd_fputc = vpi_mcd_fputc; + vvmt.vpi_mcd_fgetc = vpi_mcd_fgetc; + vvmt.vpi_register_cb = vpi_register_cb; + vvmt.vpi_remove_cb = vpi_remove_cb; + vvmt.vpi_sim_vcontrol = vpi_sim_vcontrol; + vvmt.vpi_handle = vpi_handle; + vvmt.vpi_iterate = vpi_iterate; + vvmt.vpi_scan = vpi_scan; + vvmt.vpi_handle_by_index = vpi_handle_by_index; + vvmt.vpi_get_time = vpi_get_time; + vvmt.vpi_get = vpi_get; + vvmt.vpi_get_str = vpi_get_str; + vvmt.vpi_get_value = vpi_get_value; + vvmt.vpi_put_value = vpi_put_value; + vvmt.vpi_free_object= vpi_free_object; + vvmt.vpi_get_vlog_info = vpi_get_vlog_info; +} diff --git a/vvp/Makefile.in b/vvp/Makefile.in index 8a77a8c8f..0dd437501 100644 --- a/vvp/Makefile.in +++ b/vvp/Makefile.in @@ -16,7 +16,7 @@ # 59 Temple Place - Suite 330 # Boston, MA 02111-1307, USA # -#ident "$Id: Makefile.in,v 1.22 2001/06/05 03:05:41 steve Exp $" +#ident "$Id: Makefile.in,v 1.23 2001/06/12 03:53:11 steve Exp $" # # SHELL = /bin/sh @@ -60,13 +60,13 @@ check: all V = vpi_modules.o vpi_const.o vpi_iter.o vpi_mcd.o vpi_priv.o \ vpi_scope.o vpi_signal.o vpi_tasks.o vpi_time.o vpi_memory.o \ -vpi_vthr_vector.o +vpi_vthr_vector.o vvp_vpi.o O = main.o parse.o parse_misc.o lexor.o arith.o bufif.o compile.o debug.o \ functor.o resolv.o symbols.o codes.o vthread.o schedule.o \ tables.o udp.o memory.o $V -vvp: $O +vvp: $O $(CXX) $(rdynamic) $(CXXFLAGS) $(LDFLAGS) -o vvp $O $(LIBS) $(dllib) diff --git a/vvp/main.cc b/vvp/main.cc index aa477ef95..9903163bb 100644 --- a/vvp/main.cc +++ b/vvp/main.cc @@ -17,7 +17,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ #if !defined(WINNT) -#ident "$Id: main.cc,v 1.14 2001/05/20 17:34:53 steve Exp $" +#ident "$Id: main.cc,v 1.15 2001/06/12 03:53:11 steve Exp $" #endif # include "config.h" @@ -43,6 +43,7 @@ unsigned module_cnt = 0; const char*module_tab[64]; extern void vpi_mcd_init(void); +extern void vvp_vpi_init(void); int main(int argc, char*argv[]) { @@ -81,6 +82,8 @@ int main(int argc, char*argv[]) vpi_mcd_init(); + vvp_vpi_init(); + compile_init(); #if 0 for (unsigned idx = 0 ; idx < module_cnt ; idx += 1) @@ -108,6 +111,10 @@ int main(int argc, char*argv[]) /* * $Log: main.cc,v $ + * Revision 1.15 2001/06/12 03:53:11 steve + * Change the VPI call process so that loaded .vpi modules + * use a function table instead of implicit binding. + * * Revision 1.14 2001/05/20 17:34:53 steve * declare getopt by hand in mingw32 compile. * diff --git a/vvp/vpi_mcd.cc b/vvp/vpi_mcd.cc index 2b24101c0..3fa9db0c7 100644 --- a/vvp/vpi_mcd.cc +++ b/vvp/vpi_mcd.cc @@ -17,7 +17,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ #if !defined(WINNT) && !defined(macintosh) -#ident "$Id: vpi_mcd.cc,v 1.3 2001/03/31 19:29:23 steve Exp $" +#ident "$Id: vpi_mcd.cc,v 1.4 2001/06/12 03:53:11 steve Exp $" #endif # include "vpi_priv.h" @@ -101,15 +101,13 @@ unsigned int vpi_mcd_open(char *name) return vpi_mcd_open_x(name,"w"); } -int vpi_mcd_printf(unsigned int mcd, const char*fmt, ...) +extern "C" int vpi_mcd_vprintf(unsigned int mcd, const char*fmt, va_list ap) { int i; int len; int rc; - va_list ap; rc = len = 0; - va_start(ap, fmt); for(i = 0; i < 31; i++) { if( (mcd>>i) & 1) { if(mcd_table[i].fp) @@ -118,7 +116,6 @@ int vpi_mcd_printf(unsigned int mcd, const char*fmt, ...) rc = EOF; } } - va_end(ap); if(rc) return rc; diff --git a/vvp/vpi_modules.cc b/vvp/vpi_modules.cc index 1db05e6c6..263824f60 100644 --- a/vvp/vpi_modules.cc +++ b/vvp/vpi_modules.cc @@ -17,15 +17,17 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ #if !defined(WINNT) -#ident "$Id: vpi_modules.cc,v 1.4 2001/05/22 02:14:47 steve Exp $" +#ident "$Id: vpi_modules.cc,v 1.5 2001/06/12 03:53:11 steve Exp $" #endif # include "config.h" # include "vpi_priv.h" # include "ivl_dlfcn.h" # include +# include "vpithunk.h" typedef void (*vlog_startup_routines_t)(void); +typedef int (*vpi_register_sim_t)(p_vpi_thunk tp); void vpip_load_module(const char*name, const char*path) { @@ -44,6 +46,22 @@ void vpip_load_module(const char*name, const char*path) return; } + void *regsub = ivl_dlsym(dll, LU "vpi_register_sim" TU); + vpi_register_sim_t simreg = (vpi_register_sim_t)regsub; + if (regsub == 0) { + fprintf(stderr, "%s: Unable to locate vpi_register_sim", name); + ivl_dlclose(dll); + return; + } + + extern vpi_thunk vvpt; + if (((simreg)(&vvpt)) == 0) { + fprintf(stderr, "%s: : vpi_register_sim returned zero", name); + ivl_dlclose(dll); + return; + } + + void*table = ivl_dlsym(dll, LU "vlog_startup_routines" TU); if (table == 0) { fprintf(stderr, "%s: no vlog_startup_routines\n", name); @@ -59,6 +77,10 @@ void vpip_load_module(const char*name, const char*path) /* * $Log: vpi_modules.cc,v $ + * Revision 1.5 2001/06/12 03:53:11 steve + * Change the VPI call process so that loaded .vpi modules + * use a function table instead of implicit binding. + * * Revision 1.4 2001/05/22 02:14:47 steve * Update the mingw build to not require cygwin files. * diff --git a/vvp/vpi_priv.cc b/vvp/vpi_priv.cc index 5f1d5cb9e..dfe5e1e47 100644 --- a/vvp/vpi_priv.cc +++ b/vvp/vpi_priv.cc @@ -17,7 +17,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ #if !defined(WINNT) -#ident "$Id: vpi_priv.cc,v 1.4 2001/06/10 16:47:49 steve Exp $" +#ident "$Id: vpi_priv.cc,v 1.5 2001/06/12 03:53:11 steve Exp $" #endif # include "vpi_priv.h" @@ -132,15 +132,11 @@ vpiHandle vpi_handle_by_index(vpiHandle ref, int idx) return (ref->vpi_type->index_)(ref, idx); } -void vpi_printf(const char*fmt, ...) +extern "C" void vpi_vprintf(const char*fmt, va_list ap) { - va_list ap; - va_start(ap, fmt); vprintf(fmt, ap); - va_end(ap); } - /* STUBS */ vpiHandle vpi_register_cb(p_cb_data data) @@ -156,7 +152,7 @@ int vpi_remove_cb(vpiHandle ref) return 0; } -void vpi_sim_control(int operation, ...) +extern "C" void vpi_sim_vcontrol(int operation, va_list ap) { switch (operation) { case vpiFinish: @@ -170,6 +166,10 @@ void vpi_sim_control(int operation, ...) /* * $Log: vpi_priv.cc,v $ + * Revision 1.5 2001/06/12 03:53:11 steve + * Change the VPI call process so that loaded .vpi modules + * use a function table instead of implicit binding. + * * Revision 1.4 2001/06/10 16:47:49 steve * support scan of scope from VPI. * diff --git a/vvp/vvp_vpi.cc b/vvp/vvp_vpi.cc new file mode 100644 index 000000000..35de087bf --- /dev/null +++ b/vvp/vvp_vpi.cc @@ -0,0 +1,32 @@ +#include +#include "vpi_user.h" +#include "vpithunk.h" + +vpi_thunk vvpt; + +void vvp_vpi_init() +{ + vvpt.magic = VPI_THUNK_MAGIC; + vvpt.vpi_register_systf = vpi_register_systf; + vvpt.vpi_vprintf = vpi_vprintf; + vvpt.vpi_mcd_close = vpi_mcd_close; + vvpt.vpi_mcd_name = vpi_mcd_name; + vvpt.vpi_mcd_open = vpi_mcd_open; + vvpt.vpi_mcd_open_x = vpi_mcd_open_x; + vvpt.vpi_mcd_vprintf = vpi_mcd_vprintf; + vvpt.vpi_mcd_fputc = vpi_mcd_fputc; + vvpt.vpi_mcd_fgetc = vpi_mcd_fgetc; + vvpt.vpi_register_cb = vpi_register_cb; + vvpt.vpi_remove_cb = vpi_remove_cb; + vvpt.vpi_sim_vcontrol = vpi_sim_vcontrol; + vvpt.vpi_handle = vpi_handle; + vvpt.vpi_iterate = vpi_iterate; + vvpt.vpi_scan = vpi_scan; + vvpt.vpi_handle_by_index = vpi_handle_by_index; + vvpt.vpi_get_time = vpi_get_time; + vvpt.vpi_get = vpi_get; + vvpt.vpi_get_str = vpi_get_str; + vvpt.vpi_get_value = vpi_get_value; + vvpt.vpi_put_value = vpi_put_value; + vvpt.vpi_free_object= vpi_free_object; +}