From ecb8a70bed97b6300e4d775788dbd7fc99044aef Mon Sep 17 00:00:00 2001 From: Ralf Habacker Date: Mon, 18 May 2026 07:49:42 +0200 Subject: [PATCH 1/5] iverilog: add missing -B options to man page and app usage --- driver/iverilog.man.in | 29 ++++++++++++++++++++++------- driver/main.c | 2 +- 2 files changed, 23 insertions(+), 8 deletions(-) diff --git a/driver/iverilog.man.in b/driver/iverilog.man.in index 60498549b..7ccc93ee9 100644 --- a/driver/iverilog.man.in +++ b/driver/iverilog.man.in @@ -4,7 +4,7 @@ iverilog - Icarus Verilog compiler .SH SYNOPSIS .B iverilog -[\-EiRSuVv] [\-Bpath] [\-ccmdfile|\-fcmdfile] [\-Dmacro[=defn]] +[\-EiRSuVv] [\-B[MPV]path] [\-ccmdfile|\-fcmdfile] [\-Dmacro[=defn]] [\-Pparameter=value] [\-pflag=value] [\-dname] [\-g1995\:|\-g2001\:|\-g2005\:|\-g2005-sv\:|\-g2009\:|\-g2012\:|\-g2017\:|\-g2023\:|\-g] [\-Iincludedir] [\-Lmoduledir] [\-mmodule] [\-M[mode=]file] [\-Nfile] @@ -21,13 +21,28 @@ further processing. The main target is \fIvvp\fP for simulation. .SH OPTIONS \fIiverilog\fP accepts the following options: .TP 8 -.B -B\fIbase\fP +.BI \-B path The \fIiverilog\fP program uses external programs and configuration -files to preprocess and compile the Verilog source. Normally, the path -used to locate these tools is built into the \fIiverilog\fP -program. However, the \fB\-B\fP switch allows the user to select a -different set of programs. The path given is used to locate -\fIivlpp\fP, \fIivl\fP, code generators and the VPI modules. +files to preprocess and compile Verilog source files. Normally, the +paths used to locate these tools are built into the +\fIiverilog\fP executable. The \fB\-B\fP option allows the user to +override these paths. +The specified path is used as the default base directory for locating +\fIivlpp\fP, \fIivl\fP, code generators, configuration files, and +VPI modules. +Specialized forms of this option may be used to override individual +tool paths: +.RS +.TP +.BI \-BM path +Directory for VPI modules. +.TP +.BI \-BP path +Directory for the \fIivlpp\fP preprocessor. +.TP +.BI \-BV path +Directory for the \fIvhdlpp\fP VHDL preprocessor. +.RE .TP 8 .B -c\fIfile\fP -f\fIfile\fP These flags specify an input file that contains a list of Verilog diff --git a/driver/main.c b/driver/main.c index 865a94e4c..fd1e563f8 100644 --- a/driver/main.c +++ b/driver/main.c @@ -38,7 +38,7 @@ const char NOTICE[] = ; const char HELP[] = -"Usage: iverilog [-EiRSuvV] [-B base] [-c cmdfile|-f cmdfile]\n" +"Usage: iverilog [-EiRSuvV] [-B[MPV] base] [-c cmdfile|-f cmdfile]\n" " [-g1995|-g2001|-g2005|-g2005-sv|-g2009|-g2012|-g2017|-g2023] [-g]\n" " [-D macro[=defn]] [-I includedir] [-L moduledir]\n" " [-M [mode=]depfile] [-m module]\n" From 8b861b417132dd6ae197c4151667301c0c282ef6 Mon Sep 17 00:00:00 2001 From: Ralf Habacker Date: Mon, 18 May 2026 07:50:07 +0200 Subject: [PATCH 2/5] iverilog: add -BI option to support custom location for the ivl parser --- driver/iverilog.man.in | 5 ++++- driver/main.c | 12 +++++++++--- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/driver/iverilog.man.in b/driver/iverilog.man.in index 7ccc93ee9..3c38f1abd 100644 --- a/driver/iverilog.man.in +++ b/driver/iverilog.man.in @@ -4,7 +4,7 @@ iverilog - Icarus Verilog compiler .SH SYNOPSIS .B iverilog -[\-EiRSuVv] [\-B[MPV]path] [\-ccmdfile|\-fcmdfile] [\-Dmacro[=defn]] +[\-EiRSuVv] [\-B[IMPV]path] [\-ccmdfile|\-fcmdfile] [\-Dmacro[=defn]] [\-Pparameter=value] [\-pflag=value] [\-dname] [\-g1995\:|\-g2001\:|\-g2005\:|\-g2005-sv\:|\-g2009\:|\-g2012\:|\-g2017\:|\-g2023\:|\-g] [\-Iincludedir] [\-Lmoduledir] [\-mmodule] [\-M[mode=]file] [\-Nfile] @@ -34,6 +34,9 @@ Specialized forms of this option may be used to override individual tool paths: .RS .TP +.BI \-BI path +Directory for the \fIivl\fP parser. +.TP .BI \-BM path Directory for VPI modules. .TP diff --git a/driver/main.c b/driver/main.c index fd1e563f8..56aa62cdf 100644 --- a/driver/main.c +++ b/driver/main.c @@ -38,7 +38,7 @@ const char NOTICE[] = ; const char HELP[] = -"Usage: iverilog [-EiRSuvV] [-B[MPV] base] [-c cmdfile|-f cmdfile]\n" +"Usage: iverilog [-EiRSuvV] [-B[IMPV] base] [-c cmdfile|-f cmdfile]\n" " [-g1995|-g2001|-g2005|-g2005-sv|-g2009|-g2012|-g2017|-g2023] [-g]\n" " [-D macro[=defn]] [-I includedir] [-L moduledir]\n" " [-M [mode=]depfile] [-m module]\n" @@ -112,6 +112,7 @@ extern void cfreset(FILE*fd, const char*path); const char*base = 0; const char*vpi_dir = 0; +const char*ivl_dir = 0; const char*ivlpp_dir = 0; const char*vhdlpp_dir= 0; const char*vhdlpp_work = 0; @@ -340,7 +341,7 @@ static int t_version_only(void) } fflush(0); - snprintf(tmp, sizeof tmp, "%s%civl -V -C\"%s\" -C\"%s\"", base, sep, + snprintf(tmp, sizeof tmp, "%s%civl -V -C\"%s\" -C\"%s\"", ivl_dir, sep, iconfig_path, iconfig_common_path); rc = system(tmp); if (rc != 0) { @@ -447,7 +448,7 @@ static int t_compile(void) #endif /* Build the ivl command. */ - snprintf(tmp, sizeof tmp, "%s%civl", base, sep); + snprintf(tmp, sizeof tmp, "%s%civl", ivl_dir, sep); rc = strlen(tmp); cmd = realloc(cmd, ncmd+rc+1); strcpy(cmd+ncmd, tmp); @@ -1224,6 +1225,9 @@ int main(int argc, char **argv) character of the path indicates which path the user is specifying. */ switch (optarg[0]) { + case 'I': /* Path for the ivl parser */ + ivl_dir = optarg+1; + break; case 'M': /* Path for the VPI modules */ vpi_dir = optarg+1; break; @@ -1375,6 +1379,8 @@ int main(int argc, char **argv) vpi_dir = base; if (ivlpp_dir == 0) ivlpp_dir = base; + if (ivl_dir == 0) + ivl_dir = base; if (vhdlpp_dir == 0) vhdlpp_dir = base; From 2e50fb2f0632ad47e1ad5ad6ff3a907df01b8e23 Mon Sep 17 00:00:00 2001 From: Ralf Habacker Date: Fri, 8 May 2026 19:13:19 +0200 Subject: [PATCH 3/5] iverilog: add -Bt option to find .conf when using -t in custom install or build dir --- driver/iverilog.man.in | 7 ++++++- driver/main.c | 10 ++++++++-- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/driver/iverilog.man.in b/driver/iverilog.man.in index 3c38f1abd..b5f4d1360 100644 --- a/driver/iverilog.man.in +++ b/driver/iverilog.man.in @@ -4,7 +4,7 @@ iverilog - Icarus Verilog compiler .SH SYNOPSIS .B iverilog -[\-EiRSuVv] [\-B[IMPV]path] [\-ccmdfile|\-fcmdfile] [\-Dmacro[=defn]] +[\-EiRSuVv] [\-B[IMPVt]path] [\-ccmdfile|\-fcmdfile] [\-Dmacro[=defn]] [\-Pparameter=value] [\-pflag=value] [\-dname] [\-g1995\:|\-g2001\:|\-g2005\:|\-g2005-sv\:|\-g2009\:|\-g2012\:|\-g2017\:|\-g2023\:|\-g] [\-Iincludedir] [\-Lmoduledir] [\-mmodule] [\-M[mode=]file] [\-Nfile] @@ -45,6 +45,11 @@ Directory for the \fIivlpp\fP preprocessor. .TP .BI \-BV path Directory for the \fIvhdlpp\fP VHDL preprocessor. +.TP +.BI \-Bt path +Directory used to locate target configuration files for the +\fB\-t\fP\fItarget\fP option. The configuration file name is +\fItarget\fP.conf. .RE .TP 8 .B -c\fIfile\fP -f\fIfile\fP diff --git a/driver/main.c b/driver/main.c index 56aa62cdf..95d02e91b 100644 --- a/driver/main.c +++ b/driver/main.c @@ -38,7 +38,7 @@ const char NOTICE[] = ; const char HELP[] = -"Usage: iverilog [-EiRSuvV] [-B[IMPV] base] [-c cmdfile|-f cmdfile]\n" +"Usage: iverilog [-EiRSuvV] [-B[IMPVt] base] [-c cmdfile|-f cmdfile]\n" " [-g1995|-g2001|-g2005|-g2005-sv|-g2009|-g2012|-g2017|-g2023] [-g]\n" " [-D macro[=defn]] [-I includedir] [-L moduledir]\n" " [-M [mode=]depfile] [-m module]\n" @@ -112,6 +112,7 @@ extern void cfreset(FILE*fd, const char*path); const char*base = 0; const char*vpi_dir = 0; +const char*tconfig_dir = 0; const char*ivl_dir = 0; const char*ivlpp_dir = 0; const char*vhdlpp_dir= 0; @@ -1237,6 +1238,9 @@ int main(int argc, char **argv) case 'V': /* Path for the vhdlpp VHDL processor */ vhdlpp_dir = optarg+1; break; + case 't': /* Path to target.conf for the -ttarget option */ + tconfig_dir = optarg+1; + break; default: /* Otherwise, this is a default base. */ base=optarg; break; @@ -1383,6 +1387,8 @@ int main(int argc, char **argv) ivl_dir = base; if (vhdlpp_dir == 0) vhdlpp_dir = base; + if (tconfig_dir == 0) + tconfig_dir = base; if (version_flag || verbose_flag) { printf("Icarus Verilog version " VERSION " (" VERSION_TAG ")\n\n"); @@ -1392,7 +1398,7 @@ int main(int argc, char **argv) /* Make a common conf file path to reflect the target. */ snprintf(iconfig_common_path, sizeof iconfig_common_path, "%s%c%s%s.conf", - base, sep, targ, synth_flag? "-s" : ""); + tconfig_dir, sep, targ, synth_flag? "-s" : ""); /* Write values to the iconfig file. */ fprintf(iconfig_file, "basedir:%s\n", base); From 0d74d5b211746f2aae8ccf4c8af9621fd7faf06d Mon Sep 17 00:00:00 2001 From: Ralf Habacker Date: Tue, 12 May 2026 11:45:41 +0200 Subject: [PATCH 4/5] iverilog: add test for the vvp example mentioned in the documentation This test was added to verify the new options in the `iverilog` program, which allow it to be run from a build directory. Since `iverilog` is not compatible with the MSYS2 runtime environment used in CI, the added test is excluded on this platform. --- configure.ac | 16 ++++++++++++++++ driver/Makefile.in | 20 ++++++++++++++++++++ driver/hello_world.v | 3 +++ 3 files changed, 39 insertions(+) create mode 100644 driver/hello_world.v diff --git a/configure.ac b/configure.ac index c3e1a5bfb..5560dc981 100644 --- a/configure.ac +++ b/configure.ac @@ -98,6 +98,22 @@ AC_SUBST(EXEEXT) # Combined check for Microsoft-related bogosities; sets WIN32 if found AX_WIN32 +# detect msys shell +AC_MSG_CHECKING([whether the shell is an MSYS2 runtime shell]) + +AS_CASE([$host_os:$MSYSTEM], + [*mingw*:UCRT64|*mingw*:MINGW64|*mingw*:MINGW32|*mingw*:CLANG64], [ + MSYS_SHELL=true + msys_shell_result=yes + ], + [ + MSYS_SHELL=false + msys_shell_result=no + ] +) +AC_MSG_RESULT([$msys_shell_result]) +AC_SUBST([MSYS_SHELL]) + # Check to see if we are using the Sun compiler. If so then configure # some of the flags to match the Sun compiler syntax. This is also used # in the aclocal.m4 file to configure the flags used to build and link diff --git a/driver/Makefile.in b/driver/Makefile.in index f0c6831ce..36b9abcd2 100644 --- a/driver/Makefile.in +++ b/driver/Makefile.in @@ -17,12 +17,18 @@ # SHELL = /bin/sh +EXEEXT = @EXEEXT@ +ENV_VVP=@ENV_VVP@ +MSYS_SHELL=@MSYS_SHELL@ + suffix = @install_suffix@ prefix = @prefix@ exec_prefix = @exec_prefix@ srcdir = @srcdir@ datarootdir = @datarootdir@ +builddir=@builddir@ +top_builddir=@top_builddir@ VPATH = $(srcdir) @@ -58,11 +64,25 @@ O = main.o substit.o cflexor.o cfparse.o all: dep iverilog@EXEEXT@ iverilog.man check: all + @if $(MSYS_SHELL); then \ + echo "iverilog: execution from a build directory not suppported for this runtime"; \ + else \ + echo "iverilog: create .vpp from .v file and run it"; \ + $(builddir)/iverilog@EXEEXT@ \ + -B$(top_builddir)/tgt-vvp \ + -BI$(top_builddir) \ + -BM$(top_builddir)/vpi \ + -BP$(top_builddir)/ivlpp \ + -Bt$(top_builddir)/tgt-vvp \ + $(verbose) -o top.vvp -s top $(srcdir)/hello_world.v; \ + $(ENV_VVP) $(top_builddir)/vvp/vvp$(suffix)@EXEEXT@ top.vvp; \ + fi clean: rm -f *.o cflexor.c cfparse.c cfparse.h cfparse.output rm -f iverilog@EXEEXT@ iverilog.man iverilog.pdf iverilog.ps rm -rf dep + rm -f test.conf top.vvp distclean: clean rm -f Makefile config.log diff --git a/driver/hello_world.v b/driver/hello_world.v new file mode 100644 index 000000000..33ca7ea79 --- /dev/null +++ b/driver/hello_world.v @@ -0,0 +1,3 @@ +module top; + initial $display("Hello World!"); +endmodule From 6a6ff90197318550d1439c2d64e14cbeaeb2d0db Mon Sep 17 00:00:00 2001 From: "Cary R." Date: Thu, 21 May 2026 09:27:48 -0700 Subject: [PATCH 5/5] Update clean target in Makefile to remove test.conf Remove test.conf from the clean target in Makefile. --- driver/Makefile.in | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/driver/Makefile.in b/driver/Makefile.in index 36b9abcd2..910d50599 100644 --- a/driver/Makefile.in +++ b/driver/Makefile.in @@ -82,7 +82,7 @@ clean: rm -f *.o cflexor.c cfparse.c cfparse.h cfparse.output rm -f iverilog@EXEEXT@ iverilog.man iverilog.pdf iverilog.ps rm -rf dep - rm -f test.conf top.vvp + rm -f top.vvp distclean: clean rm -f Makefile config.log