From 0be48388c274c2573346f06fae72693114e32a10 Mon Sep 17 00:00:00 2001 From: steve Date: Fri, 16 Nov 2001 05:07:19 +0000 Subject: [PATCH] Add support for +libext+ in command files. --- compiler.h | 6 +++++- driver/build_string.c | 14 +++++++++++++- driver/cflexor.lex | 5 ++++- driver/cfparse.y | 21 +++++++++++++++++++-- driver/globals.h | 9 +++++++-- driver/iverilog.man | 9 ++++++++- driver/main.c | 24 ++++++++++++++++++++++-- iverilog.conf | 17 +++++++++-------- load_module.cc | 28 ++++++++++++++++++---------- main.cc | 18 ++++++++++++++++-- 10 files changed, 121 insertions(+), 30 deletions(-) diff --git a/compiler.h b/compiler.h index f1b64990e..5bdd63eb3 100644 --- a/compiler.h +++ b/compiler.h @@ -19,7 +19,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ #if !defined(WINNT) && !defined(macintosh) -#ident "$Id: compiler.h,v 1.6 2001/10/20 23:02:40 steve Exp $" +#ident "$Id: compiler.h,v 1.7 2001/11/16 05:07:19 steve Exp $" #endif # include @@ -73,9 +73,13 @@ extern bool verbose_flag; /* This is an ordered list of libraries to search. */ extern listlibrary_dirs; +extern listlibrary_suff; /* * $Log: compiler.h,v $ + * Revision 1.7 2001/11/16 05:07:19 steve + * Add support for +libext+ in command files. + * * Revision 1.6 2001/10/20 23:02:40 steve * Add automatic module libraries. * diff --git a/driver/build_string.c b/driver/build_string.c index 3dca20a43..b27cc67cc 100644 --- a/driver/build_string.c +++ b/driver/build_string.c @@ -17,7 +17,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ #if !defined(WINNT) && !defined(macintosh) -#ident "$Id: build_string.c,v 1.5 2001/10/20 23:02:40 steve Exp $" +#ident "$Id: build_string.c,v 1.6 2001/11/16 05:07:19 steve Exp $" #endif # include "config.h" @@ -136,6 +136,15 @@ int build_string(char*output, size_t olen, const char*pattern) olen -= strlen(library_flags); } break; + + case 'Y': + if (library_flags2) { + strcpy(output, library_flags2); + output += strlen(library_flags2); + olen -= strlen(library_flags2); + } + break; + } pattern += 1; @@ -151,6 +160,9 @@ int build_string(char*output, size_t olen, const char*pattern) /* * $Log: build_string.c,v $ + * Revision 1.6 2001/11/16 05:07:19 steve + * Add support for +libext+ in command files. + * * Revision 1.5 2001/10/20 23:02:40 steve * Add automatic module libraries. * diff --git a/driver/cflexor.lex b/driver/cflexor.lex index 5aa2a10f8..eaedba9d0 100644 --- a/driver/cflexor.lex +++ b/driver/cflexor.lex @@ -19,7 +19,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ #if !defined(WINNT) && !defined(macintosh) -#ident "$Id: cflexor.lex,v 1.3 2001/11/13 03:30:26 steve Exp $" +#ident "$Id: cflexor.lex,v 1.4 2001/11/16 05:07:19 steve Exp $" #endif # include "cfparse.h" @@ -70,6 +70,9 @@ static int comment_enter; "+incdir+" { BEGIN(PLUS_ARGS); return TOK_INCDIR; } +"+libext+" { BEGIN(PLUS_ARGS); return TOK_LIBEXT; } + + /* If it is not any known plus-flag, return the generic form. */ "+"[^\n \t\b\f\r+]* { cflval.text = strdup(yytext); diff --git a/driver/cfparse.y b/driver/cfparse.y index a3851040d..b27df5974 100644 --- a/driver/cfparse.y +++ b/driver/cfparse.y @@ -18,7 +18,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ #if !defined(WINNT) && !defined(macintosh) -#ident "$Id: cfparse.y,v 1.3 2001/11/13 03:30:26 steve Exp $" +#ident "$Id: cfparse.y,v 1.4 2001/11/16 05:07:19 steve Exp $" #endif @@ -31,7 +31,7 @@ }; %token TOK_Da TOK_Dv TOK_Dy -%token TOK_DEFINE TOK_INCDIR +%token TOK_DEFINE TOK_INCDIR TOK_LIBEXT %token TOK_PLUSARG TOK_PLUSWORD TOK_STRING %% @@ -88,6 +88,11 @@ item | TOK_INCDIR inc_args + /* The +libext token introduces a list of + arguments that + become individual -Y flags to ivl. */ + + | TOK_LIBEXT libext_args + /* The + tokens that are not otherwise matched, are ignored. The skip_args rule arranges for all the argument words to be consumed. */ @@ -116,6 +121,18 @@ inc_arg : TOK_PLUSARG } ; + /* inc_args are +incdir+ arguments in order. */ +libext_args + : libext_args libext_arg + | libext_arg + ; + +libext_arg : TOK_PLUSARG + { process_library2_switch($1); + free($1); + } + ; + /* skip_args are arguments to a +word flag that is not otherwise parsed. This rule matches them and releases the strings, so that they can be safely ignored. */ diff --git a/driver/globals.h b/driver/globals.h index be967ff46..5e0180e1c 100644 --- a/driver/globals.h +++ b/driver/globals.h @@ -19,7 +19,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ #if !defined(WINNT) && !defined(macintosh) -#ident "$Id: globals.h,v 1.9 2001/11/13 03:30:26 steve Exp $" +#ident "$Id: globals.h,v 1.10 2001/11/16 05:07:19 steve Exp $" #endif # include @@ -56,6 +56,7 @@ extern void process_file_name(const char*name); /* Add the name to the list of library directories. */ extern void process_library_switch(const char*name); +extern void process_library2_switch(const char*name); /* Add a new include file search directory */ extern void process_include_dir(const char*name); @@ -68,8 +69,9 @@ extern int verbose_flag; extern char warning_flags[]; - /* -y flags from the command line. */ + /* -y and -Y flags from the command line. */ extern char* library_flags; +extern char* library_flags2; extern const char*lookup_pattern(const char*key); @@ -77,6 +79,9 @@ extern int build_string(char*out, size_t olen, const char*pattern); /* * $Log: globals.h,v $ + * Revision 1.10 2001/11/16 05:07:19 steve + * Add support for +libext+ in command files. + * * Revision 1.9 2001/11/13 03:30:26 steve * The +incdir+ plusarg can take multiple directores, * and add initial support for +define+ in the command file. diff --git a/driver/iverilog.man b/driver/iverilog.man index 3ae8fe6fc..fdc3378db 100644 --- a/driver/iverilog.man +++ b/driver/iverilog.man @@ -1,4 +1,4 @@ -.TH iverilog 1 "$Date: 2001/11/14 03:28:15 $" Version "$Date: 2001/11/14 03:28:15 $" +.TH iverilog 1 "$Date: 2001/11/16 05:07:19 $" Version "$Date: 2001/11/16 05:07:19 $" .SH NAME iverilog - Icarus Verilog compiler @@ -210,6 +210,13 @@ command line. The difference is that multiple \fI+includedir\fP directories are valid parameters to a single \fB+incdir+\fP token, although you may also have multiple \fB+incdir+\fP lines. +.TP 8 +.B +libext+\fIext\fP +The \fB+libext\fP token in command files fives file extensions to try +when looking for a library file. This is useful in conjunction with +\fB-y\fP flags to list suffixes to try in each directory before moving +on to the next library directory. + .TP 8 .B +define+\fINAME\fP=\fIvalue\fP The \fB+define+\fP token is the same as the \fB-D\fP option on the diff --git a/driver/main.c b/driver/main.c index 366ef6e6d..3ade98d13 100644 --- a/driver/main.c +++ b/driver/main.c @@ -16,7 +16,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ -#ident "$Id: main.c,v 1.29 2001/11/13 03:30:26 steve Exp $" +#ident "$Id: main.c,v 1.30 2001/11/16 05:07:19 steve Exp $" # include "config.h" @@ -25,7 +25,7 @@ const char HELP[] = " [-D macro[=defn]] [-I includedir] [-m module]\n" " [-N file] [-o filename] [-p flag=value]\n" " [-s topmodule] [-t target] [-T min|typ|max]\n" -" [-W class] [-y dur] source_file(s)\n" +" [-W class] [-y dir] [-Y suf] source_file(s)\n" "See man page for details."; #define MAXSIZE 4096 @@ -89,6 +89,7 @@ const char*targ = "vvp"; char warning_flags[16] = ""; char *library_flags = 0; +char *library_flags2 = 0; char*inc_list = 0; char*def_list = 0; @@ -284,6 +285,19 @@ void process_library_switch(const char *name) strcat(library_flags, name); } +void process_library2_switch(const char *name) +{ + if (library_flags2) { + library_flags2 = realloc(library_flags2, + strlen(library_flags2) + strlen(name) + 5); + strcat(library_flags2, " -Y "); + } else { + library_flags2 = malloc(strlen(name) + 4); + strcpy(library_flags2, "-Y "); + } + strcat(library_flags2, name); +} + void process_include_dir(const char *name) { if (inc_list == 0) { @@ -480,6 +494,9 @@ int main(int argc, char **argv) case 'y': process_library_switch(optarg); break; + case 'Y': + process_library2_switch(optarg); + break; case '?': default: return 1; @@ -605,6 +622,9 @@ int main(int argc, char **argv) /* * $Log: main.c,v $ + * Revision 1.30 2001/11/16 05:07:19 steve + * Add support for +libext+ in command files. + * * Revision 1.29 2001/11/13 03:30:26 steve * The +incdir+ plusarg can take multiple directores, * and add initial support for +define+ in the command file. diff --git a/iverilog.conf b/iverilog.conf index 0beec239d..7b97bac4e 100644 --- a/iverilog.conf +++ b/iverilog.conf @@ -44,6 +44,7 @@ # %W Substitute the ivl warning flags. # # %y Substitute all the -y flags here. +# %Y Substitute all the -Y flags here. # # %[] # This substitution pattern is magical, and is the only @@ -58,20 +59,20 @@ # be useful and interesting if the -N flag is included. [-tnull -S] -%B/ivl %[v-v] %y %W %s %[N-N%N] %[T-T%T] -tdll -fDLL=%B/null.tgt -- - +%B/ivl %[v-v] %y %Y %W %s %[N-N%N] %[T-T%T] -tdll -fDLL=%B/null.tgt -- - [-tnull] -%B/ivl %[v-v] %y %W %s %[N-N%N] %[T-T%T] -tdll -fDLL=%B/null.tgt -- - +%B/ivl %[v-v] %y %Y %W %s %[N-N%N] %[T-T%T] -tdll -fDLL=%B/null.tgt -- - # -- # The vvp target generates code that the vvp simulation engine can execute. # These rules support synthesized and non-synthesized variants. [-tvvp -S] -%B/ivl %[v-v] %y %W %s %[N-N%N] %[T-T%T] -tdll -fDLL=%B/vvp.tgt -fVVP_EXECUTABLE=%B/../../bin/vvp -Fsynth -Fsyn-rules -Fcprop -Fnodangle %f %m -o%o -- - +%B/ivl %[v-v] %y %Y %W %s %[N-N%N] %[T-T%T] -tdll -fDLL=%B/vvp.tgt -fVVP_EXECUTABLE=%B/../../bin/vvp -Fsynth -Fsyn-rules -Fcprop -Fnodangle %f %m -o%o -- - [-tvvp] -%B/ivl %[v-v] %y %W %s %[N-N%N] %[T-T%T] -tdll -fDLL=%B/vvp.tgt -fVVP_EXECUTABLE=%B/../../bin/vvp -Fcprop -Fnodangle %f %m -o%o -- - +%B/ivl %[v-v] %y %Y %W %s %[N-N%N] %[T-T%T] -tdll -fDLL=%B/vvp.tgt -fVVP_EXECUTABLE=%B/../../bin/vvp -Fcprop -Fnodangle %f %m -o%o -- - # -- # The vvm target uses the string to take the preprocessed code from @@ -80,20 +81,20 @@ # on the result. [-tvvm] -%B/ivl %[v-v] %y %W %s %[N-N%N] %[T-T%T] -tvvm -Fcprop -Fnodangle -fVPI_MODULE_PATH=%B %f %m -o%o.cc -- - +%B/ivl %[v-v] %y %Y %W %s %[N-N%N] %[T-T%T] -tvvm -Fcprop -Fnodangle -fVPI_MODULE_PATH=%B %f %m -o%o.cc -- - # This is the XNF code generator. [-txnf] -%B/ivl %y %[v-v] %s %[N-N%N] %[T-T%T] -txnf -Fsynth -Fsyn-rules -Fcprop -Fnodangle -o%o -- - +%B/ivl %y %Y %[v-v] %s %[N-N%N] %[T-T%T] -txnf -Fsynth -Fsyn-rules -Fcprop -Fnodangle -o%o -- - # And this is another XNF code generator, under development. [-tfpga] -%B/ivl %y %[v-v] %s %[N-N%N] %[T-T%T] %f -tdll -fDLL=%B/fpga.tgt -Fsynth -Fsyn-rules -Fcprop -Fnodangle -o%o -- - +%B/ivl %y %Y %[v-v] %s %[N-N%N] %[T-T%T] %f -tdll -fDLL=%B/fpga.tgt -Fsynth -Fsyn-rules -Fcprop -Fnodangle -o%o -- - # -- # This is the pal code generator. The target module requires the -fpart= # flag to specify the part type. [-tpal] -%B/ivl %y %[v-v] %s %[N-N%N] %[T-T%T] -tdll -fDLL=%B/pal.tgt -Fsynth -Fsyn-rules -Fcprop -Fnodangle -o%o -- - +%B/ivl %y %Y %[v-v] %s %[N-N%N] %[T-T%T] -tdll -fDLL=%B/pal.tgt -Fsynth -Fsyn-rules -Fcprop -Fnodangle -o%o -- - diff --git a/load_module.cc b/load_module.cc index 522dda604..cd58feac4 100644 --- a/load_module.cc +++ b/load_module.cc @@ -17,7 +17,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ #if !defined(WINNT) -#ident "$Id: load_module.cc,v 1.2 2001/10/22 02:05:21 steve Exp $" +#ident "$Id: load_module.cc,v 1.3 2001/11/16 05:07:19 steve Exp $" #endif # include "config.h" @@ -36,18 +36,23 @@ bool load_module(const char*type) for (list::iterator cur = library_dirs.begin() ; cur != library_dirs.end() ; cur ++ ) { - sprintf(path, "%s%c%s.v", *cur, dir_character, type); + for (list::iterator suf = library_suff.begin() + ; suf != library_suff.end() + ; suf ++ ) { - FILE*file = fopen(path, "r"); - if (file == 0) - continue; + sprintf(path, "%s%c%s%s", *cur, dir_character, type, *suf); - if (verbose_flag) { - cerr << "Loading library file " << path << "." << endl; + FILE*file = fopen(path, "r"); + if (file == 0) + continue; + + if (verbose_flag) { + cerr << "Loading library file " << path << "." << endl; + } + + pform_parse(path, file); + return true; } - - pform_parse(path, file); - return true; } return false; @@ -55,6 +60,9 @@ bool load_module(const char*type) /* * $Log: load_module.cc,v $ + * Revision 1.3 2001/11/16 05:07:19 steve + * Add support for +libext+ in command files. + * * Revision 1.2 2001/10/22 02:05:21 steve * Handle activating tasks in another root. * diff --git a/main.cc b/main.cc index fb2fffbfc..4464aa477 100644 --- a/main.cc +++ b/main.cc @@ -19,7 +19,7 @@ const char COPYRIGHT[] = * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ #if !defined(WINNT) && !defined(macintosh) -#ident "$Id: main.cc,v 1.50 2001/10/20 23:02:40 steve Exp $" +#ident "$Id: main.cc,v 1.51 2001/11/16 05:07:19 steve Exp $" #endif # include "config.h" @@ -79,6 +79,7 @@ const char*target = "null"; map flags; list library_dirs; +list library_suff; /* * These are the warning enable flags. @@ -189,7 +190,7 @@ int main(int argc, char*argv[]) min_typ_max_flag = TYP; min_typ_max_warn = 10; - while ((opt = getopt(argc, argv, "F:f:hm:N:o:P:p:s:T:t:VvW:y:")) != EOF) switch (opt) { + while ((opt = getopt(argc, argv, "F:f:hm:N:o:P:p:s:T:t:VvW:Y:y:")) != EOF) switch (opt) { case 'F': { net_func tmp = name_to_net_func(optarg); if (tmp == 0) { @@ -261,6 +262,9 @@ int main(int argc, char*argv[]) case 'y': library_dirs.push_back(optarg); break; + case 'Y': + library_suff.push_back(optarg); + break; default: flag_errors += 1; break; @@ -290,6 +294,7 @@ int main(int argc, char*argv[]) ".\n" "\t-V Print version and copyright information, and exit.\n" "\t-y Add directory to library search path.\n" +"\t-Y Add suffix string library search path.\n" ; cout << "Netlist functions:" << endl; @@ -306,6 +311,12 @@ int main(int argc, char*argv[]) return 1; } + /* If there were no -Y flags, then create a minimal library + suffix search list. */ + if (library_suff.empty()) { + library_suff.push_back(".v"); + } + /* Scan the warnings enable string for warning flags. */ for (const char*cp = warn_en ; *cp ; cp += 1) switch (*cp) { case 'i': @@ -466,6 +477,9 @@ int main(int argc, char*argv[]) /* * $Log: main.cc,v $ + * Revision 1.51 2001/11/16 05:07:19 steve + * Add support for +libext+ in command files. + * * Revision 1.50 2001/10/20 23:02:40 steve * Add automatic module libraries. *