diff --git a/vvp/compile.cc b/vvp/compile.cc index 950f74fd9..ae67820c2 100644 --- a/vvp/compile.cc +++ b/vvp/compile.cc @@ -17,7 +17,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ #if !defined(WINNT) -#ident "$Id: compile.cc,v 1.89 2001/07/22 00:04:50 steve Exp $" +#ident "$Id: compile.cc,v 1.90 2001/07/26 03:13:51 steve Exp $" #endif # include "arith.h" @@ -234,16 +234,7 @@ void compile_init(void) void compile_load_vpi_module(char*name) { -#ifdef __MINGW32__ - char module_path[4096], *s; - GetModuleFileName(NULL,module_path,1024); - /* Get to the end. Search back twice for backslashes */ - s = module_path + strlen(module_path); - while (*s != '\\') s--; s--; - while (*s != '\\') s--; - strcpy(s,"\\lib\\ivl"); -#endif - vpip_load_module(name, module_path); + vpip_load_module(name); free(name); } @@ -1546,6 +1537,9 @@ vvp_ipoint_t debug_lookup_functor(const char*name) /* * $Log: compile.cc,v $ + * Revision 1.90 2001/07/26 03:13:51 steve + * Make the -M flag add module search paths. + * * Revision 1.89 2001/07/22 00:04:50 steve * Add the load/x instruction for bit selects. * diff --git a/vvp/main.cc b/vvp/main.cc index 809593411..4b5e94083 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.18 2001/07/21 21:18:55 steve Exp $" +#ident "$Id: main.cc,v 1.19 2001/07/26 03:13:51 steve Exp $" #endif # include "config.h" @@ -66,7 +66,6 @@ inline static double cycles_diff(struct tms *a, struct tms *b) { return 0; } #endif // ! defined(HAVE_TIMES) -const char*module_path = MODULE_DIR; unsigned module_cnt = 0; const char*module_tab[64]; @@ -84,6 +83,20 @@ int main(int argc, char*argv[]) char *logfile_name = 0x0; FILE *logfile = 0x0; +#ifdef __MINGW32__ + /* In the Windows world, we get the first module path + component relative the location where the binary lives. */ + { char path[4096], *s; + GetModuleFileName(NULL,path,1024); + /* Get to the end. Search back twice for backslashes */ + s = path + strlen(path); + while (*s != '\\') s--; s--; + while (*s != '\\') s--; + strcpy(s,"\\lib\\ivl"); + vpip_module_path[0] = strdup(path); + } +#endif + while ((opt = getopt(argc, argv, "dhl:M:m:v")) != EOF) switch (opt) { case 'd': debug_flag = true; @@ -93,19 +106,19 @@ int main(int argc, char*argv[]) "Usage: vvp [options] input-file\n" "Options:\n" #if defined(WITH_DEBUG) - " -d\t\t" "Enter the debugger.\n" + " -d Enter the debugger.\n" #endif - " -h\t\t" "Print this help message.\n" - " -l file\t" "Logfile, '-' for .\n" - " -M path\t" "VPI module directory path.\n" - " -m module\t" "Load vpi module.\n" - " -v\t\t" "Verbose progress messages.\n" ); + " -h Print this help message.\n" + " -l file Logfile, '-' for \n" + " -M path VPI module directory\n" + " -m module Load vpi module.\n" + " -v Verbose progress messages.\n" ); exit(0); case 'l': logfile_name = optarg; break; case 'M': - module_path = optarg; + vpip_module_path[vpip_module_path_cnt++] = optarg; break; case 'm': module_tab[module_cnt++] = optarg; @@ -154,10 +167,10 @@ int main(int argc, char*argv[]) vvp_vpi_init(); compile_init(); -#if 0 + for (unsigned idx = 0 ; idx < module_cnt ; idx += 1) - vpip_load_module(module_tab[idx], module_path); -#endif + vpip_load_module(module_tab[idx]); + if (int rc = compile_design(design_path)) return rc; compile_cleanup(); @@ -205,6 +218,9 @@ int main(int argc, char*argv[]) /* * $Log: main.cc,v $ + * Revision 1.19 2001/07/26 03:13:51 steve + * Make the -M flag add module search paths. + * * Revision 1.18 2001/07/21 21:18:55 steve * Add the -h flag for help. (Stephan Boettcher) * diff --git a/vvp/vpi_modules.cc b/vvp/vpi_modules.cc index 263824f60..0a891cf8d 100644 --- a/vvp/vpi_modules.cc +++ b/vvp/vpi_modules.cc @@ -17,7 +17,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ #if !defined(WINNT) -#ident "$Id: vpi_modules.cc,v 1.5 2001/06/12 03:53:11 steve Exp $" +#ident "$Id: vpi_modules.cc,v 1.6 2001/07/26 03:13:51 steve Exp $" #endif # include "config.h" @@ -29,29 +29,45 @@ 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) -{ - char buf[4096]; -#ifdef __MINGW32__ - char sep = '\\'; -#else - char sep = '/'; -#endif - sprintf(buf, "%s%c%s.vpi", path, sep, name); - //printf("Load %s...\n", buf); - ivl_dll_t dll = ivl_dlopen(buf); +char* vpip_module_path[64] = { + MODULE_DIR, + 0 +}; + +unsigned vpip_module_path_cnt = 1; + + +void vpip_load_module(const char*name) +{ +#ifdef __MINGW32__ + const char sep = '\\'; +#else + const char sep = '/'; +#endif + + ivl_dll_t dll = 0; + for (unsigned idx = 0 + ; (dll == 0) && (idx < vpip_module_path_cnt) + ; idx += 1) { + char buf[4096]; + sprintf(buf, "%s%c%s.vpi", vpip_module_path[idx], sep, name); + //printf("Load %s...\n", buf); + + dll = ivl_dlopen(buf); + } + if (dll == 0) { - fprintf(stderr, "%s: %s\n", name, dlerror()); + fprintf(stderr, "%s: Unable to find %s.vpi module\n", name, name); 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; + fprintf(stderr, "%s: Unable to locate vpi_register_sim", name); + ivl_dlclose(dll); + return; } extern vpi_thunk vvpt; @@ -77,6 +93,9 @@ void vpip_load_module(const char*name, const char*path) /* * $Log: vpi_modules.cc,v $ + * Revision 1.6 2001/07/26 03:13:51 steve + * Make the -M flag add module search paths. + * * 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. diff --git a/vvp/vpi_priv.h b/vvp/vpi_priv.h index 994d387bf..c1eeb0c07 100644 --- a/vvp/vpi_priv.h +++ b/vvp/vpi_priv.h @@ -19,7 +19,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ #if !defined(WINNT) -#ident "$Id: vpi_priv.h,v 1.19 2001/07/11 02:27:21 steve Exp $" +#ident "$Id: vpi_priv.h,v 1.20 2001/07/26 03:13:51 steve Exp $" #endif # include "vpi_user.h" @@ -215,9 +215,13 @@ vpiHandle vpip_make_vthr_vector(unsigned base, unsigned wid); * This function is called before any compilation to load VPI * modules. This gives the modules a chance to announce their * contained functions before compilation commences. It is called only - * once. + * once per module. */ -extern void vpip_load_module(const char*name, const char*path); +extern void vpip_load_module(const char*name); + +# define VPIP_MODULE_PATH_MAX 64 +extern char* vpip_module_path[64]; +extern unsigned vpip_module_path_cnt; /* * The vpip_build_vpi_call function creates a __vpiSysTaskCall object @@ -259,6 +263,9 @@ extern void vpip_set_time_precision(int pres); /* * $Log: vpi_priv.h,v $ + * Revision 1.20 2001/07/26 03:13:51 steve + * Make the -M flag add module search paths. + * * Revision 1.19 2001/07/11 02:27:21 steve * Add support for REadOnlySync and monitors. * diff --git a/vvp/vvp.man b/vvp/vvp.man index 3b4de4f67..7ab488e08 100644 --- a/vvp/vvp.man +++ b/vvp/vvp.man @@ -1,4 +1,4 @@ -.TH vvp 1 "$Date: 2001/07/21 21:15:51 $" Version "$Date: 2001/07/21 21:15:51 $" +.TH vvp 1 "$Date: 2001/07/26 03:13:51 $" Version "$Date: 2001/07/26 03:13:51 $" .SH NAME vvp - Icarus Verilog vvp runtime engine @@ -23,10 +23,10 @@ Specify logfile as '-' to send log output to . $display and friends send their output both to and . .TP 8 .B -M\fIpath\fP -This flag specifies the directory to use to locate VPI modules. This -is normally not used as the installer places the modules in the -default directory, but it can be used if you choose to use alternate -versions of VPI modules. +This flag adds a directory to the path list used to locate VPI +modules. The default path includes only the install directory for the +system.vpi module, but this flag can add other directories. Multiple +paths are allowed, and modules will be searched in order. .TP 8 .B -m\fImodule\fP Tell the vvp run time to load the named module before executing the