From 572124e1e975d26b8bc3df86d25a65c79b678410 Mon Sep 17 00:00:00 2001 From: Martin Whitaker Date: Sun, 2 Oct 2016 18:57:32 +0100 Subject: [PATCH] Allow library files to be specified on the iverilog command line. This was already supported in command files, using the '-v' flag. '-v' is already in use on the command line, so use '-l' instead, and make that an alias for '-v' in command files. (cherry picked from commit 7ddc514518a535ef0a63674bfe03f0223bb5e55b) --- driver/cflexor.lex | 5 +++-- driver/iverilog.man.in | 24 ++++++++++++++++++++---- driver/main.c | 8 ++++++-- 3 files changed, 29 insertions(+), 8 deletions(-) diff --git a/driver/cflexor.lex b/driver/cflexor.lex index b0ba1a40b..3f3e46e80 100644 --- a/driver/cflexor.lex +++ b/driver/cflexor.lex @@ -4,7 +4,7 @@ %{ /* - * Copyright (c) 2001-2014 Stephen Williams (steve@icarus.com) + * Copyright (c) 2001-2016 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 @@ -124,7 +124,8 @@ int cmdfile_stack_ptr = 0; "-c" { return TOK_Dc; } "-f" { return TOK_Dc; } - /* Notice the -v flag. */ + /* Notice the -l or -v flag. */ +"-l" { return TOK_Dv; } "-v" { return TOK_Dv; } /* Notice the -y flag. */ diff --git a/driver/iverilog.man.in b/driver/iverilog.man.in index 2d3a62344..fbbaa14a5 100644 --- a/driver/iverilog.man.in +++ b/driver/iverilog.man.in @@ -1,14 +1,15 @@ -.TH iverilog 1 "Mar 5th, 2016" "" "Version %M.%n%E" +.TH iverilog 1 "Oct 2nd, 2016" "" "Version %M.%n%E" .SH NAME iverilog - Icarus Verilog compiler .SH SYNOPSIS .B iverilog [\-ESVv] [\-Bpath] [\-ccmdfile|\-fcmdfile] [\-Dmacro[=defn]] -[\-Pparameter=value] [\-pflag=value] -[\-dname] [\-g1995|\-g2001|\-g2005|\-g2005-sv|\-g2009|\-g2012|\-g] +[\-Pparameter=value] [\-pflag=value] [\-dname] +[\-g1995\:|\-g2001\:|\-g2005\:|\-g2005-sv\:|\-g2009\:|\-g2012\:|\-g] [\-Iincludedir] [\-mmodule] [\-M[mode=]file] [\-Nfile] [\-ooutputfilename] -[\-stopmodule] [\-ttype] [\-Tmin/typ/max] [\-Wclass] [\-ypath] sourcefile +[\-stopmodule] [\-ttype] [\-Tmin/typ/max] [\-Wclass] [\-ypath] [\-lfile] +sourcefile .SH DESCRIPTION .PP @@ -150,6 +151,12 @@ for Verilog include files. The \fB\-I\fP switch may be used many times to specify several directories to search, the directories are searched in the order they appear on the command line. .TP 8 +.B -l\fIfile\fP +Add the specified file to the list of source files to be compiled, +but mark it as a library file. All modules contained within that +file will be treated as library modules, and only elaborated if +they are instantiated by other modules in the design. +.TP 8 .B -M\fIpath\fP This is equivalent to \fB\-Mall=path\fP. Preserved for backwards compatibility. @@ -413,6 +420,15 @@ A \fB\-c\fP or \fB\-f\fP token prefixes a command file, exactly like it does on the command line. The cmdfile may be on the same line or the next non-comment line. +.TP 8 +.B -l\ \fIfile\fP -v\ \fIfile\fP +A \fB\-l\fP token prefixes a library file in the command file, +exactly like it does on the command line. The parameter to the \fB\-l\fP +flag may be on the same line or the next non-comment line. \fB\-v\fP is +an alias for \fB\-l\fP, provided for compatibility with other simulators. + +Variables in the \fIfile\fP are substituted. + .TP 8 .B -y\ \fIlibdir\fP A \fB\-y\fP token prefixes a library directory in the command file, diff --git a/driver/main.c b/driver/main.c index c370ac844..93de379c1 100644 --- a/driver/main.c +++ b/driver/main.c @@ -44,7 +44,7 @@ const char HELP[] = " [-M [mode=]depfile] [-m module]\n" " [-N file] [-o filename] [-p flag=value]\n" " [-s topmodule] [-t target] [-T min|typ|max]\n" -" [-W class] [-y dir] [-Y suf] source_file(s)\n" +" [-W class] [-y dir] [-Y suf] [-l file] source_file(s)\n" "\n" "See the man page for details."; @@ -928,7 +928,7 @@ int main(int argc, char **argv) } } - while ((opt = getopt(argc, argv, "B:c:D:d:Ef:g:hI:M:m:N:o:P:p:Ss:T:t:vVW:y:Y:")) != EOF) { + while ((opt = getopt(argc, argv, "B:c:D:d:Ef:g:hl:I:M:m:N:o:P:p:Ss:T:t:vVW:y:Y:")) != EOF) { switch (opt) { case 'B': @@ -983,6 +983,10 @@ int main(int argc, char **argv) process_include_dir(optarg); break; + case 'l': + process_file_name(optarg, 1); + break; + case 'M': if (process_depfile(optarg) != 0) return -1;