From 933f4483b166ceef09a66060039fae445f3711a3 Mon Sep 17 00:00:00 2001 From: steve Date: Mon, 22 Sep 2003 01:12:08 +0000 Subject: [PATCH] Pass more ivl arguments through the iconfig file. --- driver/build_string.c | 53 ++---------- driver/main.c | 172 ++++++++------------------------------ iverilog.conf | 29 ++----- main.cc | 187 ++++++++++++++++++++++++------------------ 4 files changed, 153 insertions(+), 288 deletions(-) diff --git a/driver/build_string.c b/driver/build_string.c index 8cee0841c..ffbc85856 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 */ #ifdef HAVE_CVS_IDENT -#ident "$Id: build_string.c,v 1.11 2002/08/12 01:35:01 steve Exp $" +#ident "$Id: build_string.c,v 1.12 2003/09/22 01:12:09 steve Exp $" #endif # include "config.h" @@ -52,11 +52,9 @@ int build_string(char*output, size_t olen, const char*pattern) strncpy(tmp_buf, pattern+1, tail-pattern-1); tmp_buf[tail-pattern-1] = 0; - if (((*pattern == 's') && start) - || ((*pattern == 'v') && verbose_flag) + if (((*pattern == 'v') && verbose_flag) || ((*pattern == 'M') && depfile) - || ((*pattern == 'N') && npath) - || ((*pattern == 'T') && mtm)) { + || ((*pattern == 'N') && npath)) { int rc = build_string(output, olen, tmp_buf); output += rc; @@ -78,12 +76,6 @@ int build_string(char*output, size_t olen, const char*pattern) olen -= strlen(iconfig_path); break; - case 'g': - strcpy(output, generation); - output += strlen(generation); - olen -= strlen(generation); - break; - case 'f': if (f_list) { strcpy(output, f_list); @@ -100,14 +92,6 @@ int build_string(char*output, size_t olen, const char*pattern) } break; - case 'M': - if (depfile) { - strcpy(output, depfile); - output += strlen(depfile); - olen -= strlen(depfile); - } - break; - case 'N': if (npath) { strcpy(output, npath); @@ -116,40 +100,12 @@ int build_string(char*output, size_t olen, const char*pattern) } break; - case 'o': - strcpy(output, opath); - output += strlen(opath); - olen -= strlen(opath); - break; - - case 's': - if (start) { - strcpy(output, start); - output += strlen(start); - olen -= strlen(start); - } - break; - - case 'T': - if (mtm) { - strcpy(output, mtm); - output += strlen(mtm); - olen -= strlen(mtm); - } - break; - case 't': strcpy(output, targ); output += strlen(targ); olen -= strlen(targ); break; - case 'W': - strcpy(output, warning_flags); - output += strlen(warning_flags); - olen -= strlen(warning_flags); - break; - } pattern += 1; @@ -165,6 +121,9 @@ int build_string(char*output, size_t olen, const char*pattern) /* * $Log: build_string.c,v $ + * Revision 1.12 2003/09/22 01:12:09 steve + * Pass more ivl arguments through the iconfig file. + * * Revision 1.11 2002/08/12 01:35:01 steve * conditional ident string using autoconfig. * diff --git a/driver/main.c b/driver/main.c index 983467c6b..5b679dba9 100644 --- a/driver/main.c +++ b/driver/main.c @@ -17,7 +17,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ #ifdef HAVE_CVS_IDENT -#ident "$Id: main.c,v 1.53 2003/08/26 16:26:02 steve Exp $" +#ident "$Id: main.c,v 1.54 2003/09/22 01:12:09 steve Exp $" #endif # include "config.h" @@ -90,7 +90,7 @@ const char*npath = 0; const char*targ = "vvp"; const char*depfile = 0; -const char*generation = "-g3.0"; +const char*generation = "3.0"; char warning_flags[16] = ""; @@ -98,7 +98,6 @@ char*inc_list = 0; char*def_list = 0; char*mod_list = 0; char*command_filename = 0; -char*start = 0; char*f_list = 0; @@ -229,7 +228,8 @@ static int t_default(char*cmd, unsigned ncmd) rc = system(cmd); remove(source_path); - remove(iconfig_path); + if ( ! getenv("IVERILOG_ICONFIG")) + remove(iconfig_path); if (rc != 0) { if (rc == 127) { fprintf(stderr, "Failed to execute: %s\n", cmd); @@ -249,9 +249,6 @@ static int t_default(char*cmd, unsigned ncmd) static void process_warning_switch(const char*name) { - if (warning_flags[0] == 0) - strcpy(warning_flags, "-W"); - if (strcmp(name,"all") == 0) { strcat(warning_flags, "ipt"); @@ -339,13 +336,13 @@ void process_file_name(const char*name) int process_generation(const char*name) { if (strcmp(name,"1") == 0) - generation = "-g1"; + generation = "1"; else if (strcmp(name,"2") == 0) - generation = "-g2"; + generation = "2"; else if (strcmp(name,"3.0") == 0) - generation = "-g3.0"; + generation = "3.0"; else { fprintf(stderr, "Unknown/Unsupported Language generation " @@ -420,7 +417,18 @@ int main(int argc, char **argv) /* Create another temporary file for passing configuration information to ivl. */ - iconfig_path = strdup(my_tempfile("ivrlh", &iconfig_file)); + + if ( (iconfig_path = getenv("IVERILOG_ICONFIG")) ) { + fprintf(stderr, "%s: IVERILOG_ICONFIG=%s\n", + argv[0], iconfig_path); + + iconfig_file = fopen(iconfig_path, "w"); + + } else { + + iconfig_path = strdup(my_tempfile("ivrlh", &iconfig_file)); + } + if (NULL == iconfig_file) { fprintf(stderr, "%s: Error opening temporary file %s\n", argv[0], iconfig_path); @@ -508,18 +516,7 @@ int main(int argc, char **argv) synth_flag = 1; break; case 's': - if (start) { - static const char *s = " -s "; - size_t l = strlen(start); - start = realloc(start, l + strlen(optarg) + strlen(s) + 1); - strcpy(start + l, s); - strcpy(start + l + strlen(s), optarg); - } else { - static const char *s = "-s "; - start = malloc(strlen(optarg) + strlen(s) + 1); - strcpy(start, s); - strcpy(start + strlen(s), optarg); - } + fprintf(iconfig_file, "root:%s\n", optarg); break; case 'T': if (strcmp(optarg,"min") == 0) { @@ -567,6 +564,13 @@ int main(int argc, char **argv) return 0; } + /* Write values to the iconfig file. */ + if (mtm != 0) fprintf(iconfig_file, "-T:%s\n", mtm); + fprintf(iconfig_file, "generation:%s\n", generation); + fprintf(iconfig_file, "warnings:%s\n", warning_flags); + fprintf(iconfig_file, "out:%s\n", opath); + if (depfile) fprintf(iconfig_file, "depfile:%s\n", depfile); + if (command_filename) { int rc; @@ -666,7 +670,8 @@ int main(int argc, char **argv) rc = system(cmd); remove(source_path); fclose(iconfig_file); - remove(iconfig_path); + if ( ! getenv("IVERILOG_ICONFIG")) + remove(iconfig_path); if (rc != 0) { if (WIFEXITED(rc)) { @@ -699,6 +704,9 @@ int main(int argc, char **argv) /* * $Log: main.c,v $ + * Revision 1.54 2003/09/22 01:12:09 steve + * Pass more ivl arguments through the iconfig file. + * * Revision 1.53 2003/08/26 16:26:02 steve * ifdef idents correctly. * @@ -731,121 +739,5 @@ int main(int argc, char **argv) * * Revision 1.43 2002/07/14 23:32:31 steve * No longer need the .exe on generated files. - * - * Revision 1.42 2002/07/14 23:11:35 steve - * Do temp file creation by hand. - * - * Revision 1.41 2002/05/28 20:40:37 steve - * ivl indexes the search path for libraries, and - * supports case insensitive module-to-file lookup. - * - * Revision 1.40 2002/05/28 02:25:03 steve - * Pass library paths through -Cfile instead of command line. - * - * Revision 1.39 2002/05/28 00:50:40 steve - * Add the ivl -C flag for bulk configuration - * from the driver, and use that to run library - * modules through the preprocessor. - * - * Revision 1.38 2002/05/27 23:14:06 steve - * Predefine __ICARUS__ - * - * Revision 1.37 2002/05/24 01:13:00 steve - * Support language generation flag -g. - * - * Revision 1.36 2002/04/24 02:02:31 steve - * add -Wno- arguments to the driver. - * - * Revision 1.35 2002/04/15 00:04:23 steve - * Timescale warnings. - * - * Revision 1.34 2002/04/04 05:26:13 steve - * Add dependency generation. - * - * Revision 1.33 2002/03/15 23:27:42 steve - * Patch to allow user to set place for temporary files. - * - * Revision 1.32 2002/02/03 07:05:37 steve - * Support print of version number. - * - * Revision 1.31 2001/11/21 02:20:34 steve - * Pass list of file to ivlpp via temporary file. - * - * 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. - * - * Revision 1.28 2001/11/12 18:47:32 steve - * Support +incdir in command files, and ignore other - * +args flags. Also ignore -a and -v flags. - * - * Revision 1.27 2001/11/12 01:26:36 steve - * More sophisticated command file parser. - * - * Revision 1.26 2001/11/11 00:10:05 steve - * Remov XNF dead wood. - * - * Revision 1.25 2001/10/23 00:37:30 steve - * The -s flag can now be repeated on the iverilog command. - * - * Revision 1.24 2001/10/20 23:02:40 steve - * Add automatic module libraries. - * - * Revision 1.23 2001/10/19 23:10:08 steve - * Fix memory fault with -c flag. - * - * Revision 1.22 2001/10/11 00:12:49 steve - * Detect execv failures. - * - * Revision 1.21 2001/07/25 03:10:50 steve - * Create a config.h.in file to hold all the config - * junk, and support gcc 3.0. (Stephan Boettcher) - * - * Revision 1.20 2001/06/30 21:53:42 steve - * Make the vvp target the default. - * - * Revision 1.19 2001/06/30 04:23:02 steve - * Get include and lib paths right for mingw and vvm. - * - * Revision 1.18 2001/06/30 00:59:24 steve - * Redo the ivl_root calculator for mingw. - * - * Revision 1.17 2001/06/27 02:22:26 steve - * Get include and lib paths from Makefile. - * - * Revision 1.16 2001/06/20 02:25:40 steve - * Edit ivl_install_dir only on mingw - * - * Revision 1.15 2001/06/15 05:14:21 steve - * Fix library path calculation on non Windows systems - * to include the install directories. (Brendan Simon) - * - * Revision 1.14 2001/06/12 03:53:10 steve - * Change the VPI call process so that loaded .vpi modules - * use a function table instead of implicit binding. - * - * Revision 1.13 2001/05/20 18:22:02 steve - * Fix WIFEXITED macro. - * - * Revision 1.12 2001/05/20 18:06:57 steve - * local declares if the header is missing. - * - * Revision 1.11 2001/05/20 15:09:40 steve - * Mingw32 support (Venkat Iyer) - * - * Revision 1.10 2001/05/17 03:14:26 steve - * Update help message. - * - * Revision 1.9 2001/04/26 16:04:39 steve - * Handle missing or uninstalled .conf files. - * - * Revision 1.8 2001/02/01 17:12:22 steve - * Forgot to actually allow the -p flag. - * - * Revision 1.7 2001/01/20 19:02:05 steve - * Switch hte -f flag to the -p flag. */ diff --git a/iverilog.conf b/iverilog.conf index 1772adba6..2c4bc15ae 100644 --- a/iverilog.conf +++ b/iverilog.conf @@ -32,23 +32,8 @@ # # %f Substitute the -f flags from the command line. # -# %g Substitute the -g flag -# -# %s Substitute the start module (-s flag) from the user. -# -# %M Substitute the value of the -M flag. -# # %N Substitute the value of the -N flag. # -# %o Substitute the value of the -o flag, or the default -# output path if there is no -o flag. -# -# %T Substitute min, typ or max depending on the -T flag from the -# command line. -# -# -# %W Substitute the ivl warning flags. -# # %[] # This substitution pattern is magical, and is the only # multicharacter pattern. This tests the code , and @@ -62,32 +47,32 @@ # be useful and interesting if the -N flag is included. [-tnull -S] -%B/ivl %[v-v] -C%C %g %W %s %[M-M%M] %[N-N%N] %[T-T%T] -tdll -fDLL=%B/null.tgt -Fsynth -Fsyn-rules -- - +%B/ivl %[v-v] -C%C %[N-N%N] -tdll -fDLL=%B/null.tgt -Fsynth -Fsyn-rules -- - [-tnull] -%B/ivl %[v-v] -C%C %g %W %s %[M-M%M] %[N-N%N] %[T-T%T] -tdll -fDLL=%B/null.tgt -- - +%B/ivl %[v-v] -C%C %[N-N%N] -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] -C%C %g %W %s %[M-M%M] %[N-N%N] %[T-T%T] -tdll -fDLL=%B/vvp.tgt -fVVP_EXECUTABLE=%B/../../bin/vvp -Fsynth2 -Fsynth -Fsyn-rules -Fcprop -Fnodangle %f %m -o%o -- - +%B/ivl %[v-v] -C%C %[N-N%N] -tdll -fDLL=%B/vvp.tgt -fVVP_EXECUTABLE=%B/../../bin/vvp -Fsynth2 -Fsynth -Fsyn-rules -Fcprop -Fnodangle %f %m -- - [-tvvp] -%B/ivl %[v-v] -C%C %g %W %s %[M-M%M] %[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] -C%C %[N-N%N] -tdll -fDLL=%B/vvp.tgt -fVVP_EXECUTABLE=%B/../../bin/vvp -Fcprop -Fnodangle %f %m -- - # This is the XNF code generator. [-txnf] -%B/ivl -C%C %[v-v] %g %s %[M-M%M] %[N-N%N] %[T-T%T] -txnf -Fsynth -Fsyn-rules -Fxnfio -Fcprop -Fnodangle -o%o -- - +%B/ivl -C%C %[v-v] %[N-N%N] -txnf -Fsynth -Fsyn-rules -Fxnfio -Fcprop -Fnodangle -- - # And this is another XNF code generator, under development. [-tfpga] -%B/ivl -C%C %[v-v] %g %s %[M-M%M] %[N-N%N] %[T-T%T] %f -tdll -fDLL=%B/fpga.tgt -Fsynth2 -Fsynth -Fsyn-rules -Fcprop -Fnodangle -o%o -- - +%B/ivl -C%C %[v-v] %[N-N%N] %f -tdll -fDLL=%B/fpga.tgt -Fsynth2 -Fsynth -Fsyn-rules -Fcprop -Fnodangle -- - # -- # This is the pal code generator. The target module requires the -fpart= # flag to specify the part type. [-tpal] -%B/ivl -C%C %[v-v] %g %s %[M-M%M] %[N-N%N] %[T-T%T] %f -tdll -fDLL=%B/pal.tgt -Fsynth -Fsyn-rules -Fcprop -Fnodangle -o%o -- - +%B/ivl -C%C %[v-v] %[N-N%N] %f -tdll -fDLL=%B/pal.tgt -Fsynth -Fsyn-rules -Fcprop -Fnodangle -- - diff --git a/main.cc b/main.cc index 306f0201a..398bc1d70 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 */ #ifdef HAVE_CVS_IDENT -#ident "$Id: main.cc,v 1.68 2003/06/20 00:53:19 steve Exp $" +#ident "$Id: main.cc,v 1.69 2003/09/22 01:12:08 steve Exp $" #endif # include "config.h" @@ -72,6 +72,9 @@ extern "C" int optind; extern "C" const char*optarg; #endif +/* Count errors detected in flag processing. */ +unsigned flag_errors = 0; + const char VERSION[] = "$Name: $ $State: Exp $"; const char*target = "null"; @@ -82,9 +85,13 @@ map flags; list library_suff; +list roots; + char*ivlpp_string = 0; +char* depfile_name = NULL; FILE *depend_file = NULL; + /* * These are the warning enable flags. */ @@ -114,11 +121,62 @@ const bool CASE_SENSITIVE = false; const bool CASE_SENSITIVE = true; #endif +static void process_generation_flag(const char*gen) +{ + if (strcmp(gen,"1") == 0) + generation_flag = GN_VER1995; + + else if (strcmp(gen,"2") == 0) + generation_flag = GN_VER2001; + + else if (strcmp(gen,"3.0") == 0) + generation_flag = GN_SYSVER30; + + else + generation_flag = GN_DEFAULT; +} + /* * Read the contents of a config file. This file is a temporary * configuration file made by the compiler driver to carry the bulky * flags generated from the user. This reduces the size of the command - * line needed to invoke ivl + * line needed to invoke ivl. + * + * Each line of the iconfig file has the format: + * + * : + * + * The is all the text after the ':' and up to but not + * including the end of the line. Thus, white spaces and ':' + * characters may appear here. + * + * The valid keys are: + * + * -y: + * -yl: + * -Y: + * + * -T: + * Select which expression to use. + * + * depfile: + * Give the path to an output dependency file. + * + * generation:<1|2|3.0> + * This is the generation flag + * + * ivlpp: + * This specifies the ivlpp command line used to process + * library modules as I read them in. + * + * out: + * Path to the output file. + * + * root: + * Specify a root module. There may be multiple of this. + * + * warnings: + * Warning flag letters. */ static void read_iconfig_file(const char*ipath) { @@ -149,9 +207,37 @@ static void read_iconfig_file(const char*ipath) } } - if (strcmp(buf, "ivlpp") == 0) { + if (strcmp(buf, "depfile") == 0) { + depfile_name = strdup(cp); + + } else if (strcmp(buf, "generation") == 0) { + process_generation_flag(cp); + + } else if (strcmp(buf, "ivlpp") == 0) { ivlpp_string = strdup(cp); + } else if (strcmp(buf, "out") == 0) { + flags["-o"] = cp; + + } else if (strcmp(buf, "root") == 0) { + roots.push_back(strdup(cp)); + + } else if (strcmp(buf,"warnings") == 0) { + /* Scan the warnings enable string for warning flags. */ + for ( ; *cp ; cp += 1) switch (*cp) { + case 'i': + warn_implicit = true; + break; + case 'p': + warn_portbinding = true; + break; + case 't': + warn_timescale = true; + break; + default: + break; + } + } else if (strcmp(buf, "-y") == 0) { build_library_index(cp, CASE_SENSITIVE); @@ -161,6 +247,22 @@ static void read_iconfig_file(const char*ipath) } else if (strcmp(buf, "-Y") == 0) { library_suff.push_back(strdup(cp)); + } else if (strcmp(buf,"-T") == 0) { + if (strcmp(cp,"min") == 0) { + min_typ_max_flag = MIN; + min_typ_max_warn = 0; + } else if (strcmp(cp,"typ") == 0) { + min_typ_max_flag = TYP; + min_typ_max_warn = 0; + } else if (strcmp(cp,"max") == 0) { + min_typ_max_flag = MAX; + min_typ_max_warn = 0; + } else { + cerr << "Invalid argument (" << optarg << ") to -T flag." + << endl; + flag_errors += 1; + } + } } } @@ -181,21 +283,6 @@ static void parm_to_flagmap(const string&flag) flags[key] = value; } -static void process_generation_flag(const char*gen) -{ - if (strcmp(gen,"1") == 0) - generation_flag = GN_VER1995; - - else if (strcmp(gen,"2") == 0) - generation_flag = GN_VER2001; - - else if (strcmp(gen,"3.0") == 0) - generation_flag = GN_SYSVER30; - - else - generation_flag = GN_DEFAULT; -} - extern Design* elaborate(list root); extern void cprop(Design*des); @@ -266,12 +353,8 @@ int main(int argc, char*argv[]) const char* net_path = 0; const char* pf_path = 0; - const char* warn_en = ""; int opt; - unsigned flag_errors = 0; queue net_func_queue; - list roots; - const char* depfile_name = NULL; struct tms cycles[5]; @@ -302,49 +385,21 @@ int main(int argc, char*argv[]) case 'f': parm_to_flagmap(optarg); break; - case 'g': - process_generation_flag(optarg); - break; case 'h': help_flag = true; break; case 'm': flags["VPI_MODULE_LIST"] = flags["VPI_MODULE_LIST"]+","+optarg; break; - case 'M': - depfile_name = optarg; - break; case 'N': net_path = optarg; break; - case 'o': - flags["-o"] = optarg; - break; case 'P': pf_path = optarg; break; case 'p': parm_to_flagmap(optarg); break; - case 's': - roots.push_back(optarg); - break; - case 'T': - if (strcmp(optarg,"min") == 0) { - min_typ_max_flag = MIN; - min_typ_max_warn = 0; - } else if (strcmp(optarg,"typ") == 0) { - min_typ_max_flag = TYP; - min_typ_max_warn = 0; - } else if (strcmp(optarg,"max") == 0) { - min_typ_max_flag = MAX; - min_typ_max_warn = 0; - } else { - cerr << "Invalid argument (" << optarg << ") to -T flag." - << endl; - flag_errors += 1; - } - break; case 't': target = optarg; break; @@ -359,15 +414,6 @@ int main(int argc, char*argv[]) cout << COPYRIGHT << endl; cout << endl << NOTICE << endl; return 0; - case 'W': - warn_en = optarg; - break; - case 'y': - build_library_index(optarg, CASE_SENSITIVE); - break; - case 'Y': - library_suff.push_back(optarg); - break; default: flag_errors += 1; break; @@ -385,11 +431,8 @@ int main(int argc, char*argv[]) "\t-h Print usage information, and exit.\n" "\t-m Load vpi module .\n" "\t-N Dump the elaborated netlist to .\n" -"\t-o Write output to .\n" "\t-P Write the parsed input to .\n" "\t-p Set a parameter value.\n" -"\t-s Select the top-level module.\n" -"\t-T [min|typ|max] Select timing corner.\n" "\t-t Select target .\n" "\t-v Print progress indications" #if defined(HAVE_TIMES) @@ -397,8 +440,6 @@ int main(int argc, char*argv[]) #endif ".\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; @@ -423,21 +464,6 @@ int main(int argc, char*argv[]) } - /* Scan the warnings enable string for warning flags. */ - for (const char*cp = warn_en ; *cp ; cp += 1) switch (*cp) { - case 'i': - warn_implicit = true; - break; - case 'p': - warn_portbinding = true; - break; - case 't': - warn_timescale = true; - break; - default: - break; - } - if (verbose_flag) { if (times_flag) times(cycles+0); @@ -632,6 +658,9 @@ int main(int argc, char*argv[]) /* * $Log: main.cc,v $ + * Revision 1.69 2003/09/22 01:12:08 steve + * Pass more ivl arguments through the iconfig file. + * * Revision 1.68 2003/06/20 00:53:19 steve * Module attributes from the parser * through to elaborated form.