From b82c18505116e987cd56d814c1cf80ff09aa1cfa Mon Sep 17 00:00:00 2001 From: Martin Whitaker Date: Mon, 14 Oct 2019 21:34:40 +0100 Subject: [PATCH] iverilog: Allow the user to specify the location of VPI modules. Make it explicit in the manual that a path can be supplied with the -m option, and when it is, search for a SFT file there, not in the base directory. --- driver/iverilog.man.in | 10 +++++++--- driver/main.c | 9 ++++++++- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/driver/iverilog.man.in b/driver/iverilog.man.in index 0f49fea4f..464a6acbf 100644 --- a/driver/iverilog.man.in +++ b/driver/iverilog.man.in @@ -190,9 +190,13 @@ prefixed by "I " and other files are prefixed by "M ". .B -m\fImodule\fP Add this module to the list of VPI modules to be loaded by the simulation. Many modules can be specified, and all will be loaded, in -the order specified. The system module is implicit and always included. -If a System Function Table file (.sft) exists for the module it -will be loaded automatically. +the order specified. The system module is implicit and always included +(and loaded last). If a System Function Table file (.sft) +exists for the module it will be loaded automatically. + +If the specified name includes at least one directory character, it is +assumed to be prefixed by the path to the module, otherwise the module +is assumed to be located in the \fIiverilog\fP base directory. .TP 8 .B -N\fIpath\fP This is used for debugging the compiler proper. Dump the final netlist diff --git a/driver/main.c b/driver/main.c index 56228637a..427c9d499 100644 --- a/driver/main.c +++ b/driver/main.c @@ -864,7 +864,14 @@ static void add_sft_file(const char *module) char *file; file = (char *) malloc(strlen(base)+1+strlen(module)+4+1); - sprintf(file, "%s%c%s.sft", base, sep, module); + // If the module name has at least one directory character + // in it, assume it includes the path, otherwise look in + // the base directory. + if (strchr(module, sep)) + sprintf(file, "%s.sft", module); + else + sprintf(file, "%s%c%s.sft", base, sep, module); + if (access(file, R_OK) == 0) fprintf(iconfig_file, "sys_func:%s\n", file); free(file);