diff --git a/Makefile.in b/Makefile.in index f13213efb..1566afec3 100644 --- a/Makefile.in +++ b/Makefile.in @@ -21,12 +21,6 @@ # SHELL = /bin/sh -# This version string is only used in the version message printed -# by the compiler. It reflects the assigned version number for the -# product as a whole. Most components also print the CVS Name: token -# in order to get a more automatic version stamp as well. -VERSION = 0.8.6 - # This string is used as an installation suffix. It modifies certain # key install paths/files such that a build and install of Icarus Verilog # with the same $(prefix) but a different $(suffix) will not interfere. @@ -80,7 +74,7 @@ all: dep ivl@EXEEXT@ for tgt in $(TARGETS); do (cd $$tgt ; $(MAKE) $@); done for dir in ivlpp tgt-verilog tgt-stub; \ do (cd $$dir ; $(MAKE) $@); done - cd driver ; $(MAKE) VERSION=$(VERSION) $@ + cd driver ; $(MAKE) $@ # In the windows world, the installer will need a dosify program to # dosify text files. diff --git a/cadpli/Makefile.in b/cadpli/Makefile.in index f56c09673..0ec77c82a 100644 --- a/cadpli/Makefile.in +++ b/cadpli/Makefile.in @@ -21,8 +21,6 @@ # SHELL = /bin/sh -VERSION = 0.0 - suffix = @install_suffix@ prefix = @prefix@ diff --git a/driver-vpi/Makefile.in b/driver-vpi/Makefile.in index 6fd989eec..7d92d16c6 100644 --- a/driver-vpi/Makefile.in +++ b/driver-vpi/Makefile.in @@ -21,8 +21,6 @@ # SHELL = /bin/sh -VERSION = 0.8.3 - suffix = @install_suffix@ prefix = @prefix@ @@ -45,7 +43,7 @@ INSTALL = @INSTALL@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_DATA = @INSTALL_DATA@ -CPPFLAGS = @ident_support@ -I. -I$(srcdir)/.. -DVERSION='"$(VERSION)"' @CPPFLAGS@ @DEFS@ +CPPFLAGS = @ident_support@ -I. -I$(srcdir)/.. @CPPFLAGS@ @DEFS@ CFLAGS = -Wall @CFLAGS@ LDFLAGS = @LDFLAGS@ diff --git a/driver/Makefile.in b/driver/Makefile.in index 4fa3b9c8f..6b5c1e190 100644 --- a/driver/Makefile.in +++ b/driver/Makefile.in @@ -21,8 +21,6 @@ # SHELL = /bin/sh -VERSION = 0.8 - suffix = @install_suffix@ prefix = @prefix@ @@ -45,7 +43,7 @@ INSTALL_DATA = @INSTALL_DATA@ MAN = @MAN@ PS2PDF = @PS2PDF@ -CPPFLAGS = @ident_support@ -I. -I.. -I$(srcdir)/.. -I$(srcdir) -DVERSION='"$(VERSION)"' @CPPFLAGS@ @DEFS@ +CPPFLAGS = @ident_support@ -I. -I.. -I$(srcdir)/.. -I$(srcdir) @CPPFLAGS@ @DEFS@ CFLAGS = -Wall @CFLAGS@ LDFLAGS = @LDFLAGS@ diff --git a/driver/main.c b/driver/main.c index 931b62639..467a535dd 100644 --- a/driver/main.c +++ b/driver/main.c @@ -21,6 +21,7 @@ #endif # include "config.h" +# include "version.h" const char NOTICE[] = " This program is free software; you can redistribute it and/or modify\n" @@ -704,7 +705,7 @@ int main(int argc, char **argv) pbase = base; if (version_flag || verbose_flag) { - printf("Icarus Verilog version " VERSION " ($Name: $)\n"); + printf("Icarus Verilog version " VERSION "\n\n"); printf("Copyright 1998-2003 Stephen Williams\n"); puts(NOTICE); diff --git a/ivlpp/Makefile.in b/ivlpp/Makefile.in index b47055b58..b5220a8ba 100644 --- a/ivlpp/Makefile.in +++ b/ivlpp/Makefile.in @@ -23,8 +23,6 @@ # SHELL = /bin/sh -VERSION = 0.0 - suffix = @install_suffix@ prefix = @prefix@ diff --git a/ivlpp/main.c b/ivlpp/main.c index 5bdedf13c..cd7e141c3 100644 --- a/ivlpp/main.c +++ b/ivlpp/main.c @@ -21,6 +21,7 @@ const char COPYRIGHT[] = #endif # include "config.h" +# include "version.h" const char NOTICE[] = " This program is free software; you can redistribute it and/or modify\n" @@ -38,8 +39,6 @@ const char NOTICE[] = " Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA\n" ; -const char VERSION[] = "$Name: $ $State: Exp $"; - # include # include #ifdef HAVE_MALLOC_H @@ -213,7 +212,7 @@ int main(int argc, char*argv[]) break; case 'v': - fprintf(stderr, "Icarus Verilog Preprocessor version %s\n", + fprintf(stderr, "Icarus Verilog Preprocessor version %s\n\n", VERSION); fprintf(stderr, "%s\n", COPYRIGHT); fputs(NOTICE, stderr); diff --git a/main.cc b/main.cc index 1a678b6a2..0f85817d4 100644 --- a/main.cc +++ b/main.cc @@ -59,6 +59,7 @@ const char NOTICE[] = # include "netlist.h" # include "target.h" # include "compiler.h" +# include "version.h" #if defined(__MINGW32__) && !defined(HAVE_GETOPT_H) extern "C" int getopt(int argc, char*argv[], const char*fmt); @@ -75,8 +76,6 @@ extern "C" const char*optarg; /* Count errors detected in flag processing. */ unsigned flag_errors = 0; -const char VERSION[] = "$Name: $"; - const char*basedir = "."; const char*target = "null"; @@ -504,7 +503,7 @@ int main(int argc, char*argv[]) # endif break; case 'V': - cout << "Icarus Verilog version " << VERSION << endl; + cout << "Icarus Verilog version " << VERSION << endl << endl; cout << COPYRIGHT << endl; cout << endl << NOTICE << endl; return 0; @@ -517,8 +516,8 @@ int main(int argc, char*argv[]) return flag_errors; if (help_flag) { - cout << "Icarus Verilog version " << VERSION << endl << -"usage: ivl \n" + cout << "Icarus Verilog version " << VERSION << endl << endl << +"Usage: ivl \n" "options:\n" "\t-C Config file from driver.\n" "\t-h Print usage information, and exit.\n" diff --git a/tgt-edif/Makefile.in b/tgt-edif/Makefile.in index 78a3b6d52..299b8f4f8 100644 --- a/tgt-edif/Makefile.in +++ b/tgt-edif/Makefile.in @@ -29,8 +29,6 @@ # SHELL = /bin/sh -VERSION = 0.0 - suffix = @install_suffix@ prefix = @prefix@ diff --git a/tgt-fpga/Makefile.in b/tgt-fpga/Makefile.in index ed0d3c78c..c7b461d5e 100644 --- a/tgt-fpga/Makefile.in +++ b/tgt-fpga/Makefile.in @@ -22,8 +22,6 @@ # SHELL = /bin/sh -VERSION = 0.0 - suffix = @install_suffix@ prefix = @prefix@ diff --git a/tgt-null/Makefile.in b/tgt-null/Makefile.in index a4aeb467d..c107f7b67 100644 --- a/tgt-null/Makefile.in +++ b/tgt-null/Makefile.in @@ -21,8 +21,6 @@ # SHELL = /bin/sh -VERSION = 0.0 - suffix = @install_suffix@ prefix = @prefix@ diff --git a/tgt-pal/Makefile.in b/tgt-pal/Makefile.in index ac6ea9cdd..f64b43a9f 100644 --- a/tgt-pal/Makefile.in +++ b/tgt-pal/Makefile.in @@ -21,8 +21,6 @@ # SHELL = /bin/sh -VERSION = 0.0 - prefix = @prefix@ exec_prefix = @exec_prefix@ srcdir = @srcdir@ diff --git a/tgt-stub/Makefile.in b/tgt-stub/Makefile.in index 5f3c7c9aa..80c1a8bd0 100644 --- a/tgt-stub/Makefile.in +++ b/tgt-stub/Makefile.in @@ -21,8 +21,6 @@ # SHELL = /bin/sh -VERSION = 0.0 - suffix = @install_suffix@ prefix = @prefix@ diff --git a/tgt-verilog/Makefile.in b/tgt-verilog/Makefile.in index eac3269e7..5d7dd1e19 100644 --- a/tgt-verilog/Makefile.in +++ b/tgt-verilog/Makefile.in @@ -21,8 +21,6 @@ # SHELL = /bin/sh -VERSION = 0.0 - prefix = @prefix@ exec_prefix = @exec_prefix@ srcdir = @srcdir@ diff --git a/tgt-vvp/Makefile.in b/tgt-vvp/Makefile.in index 6715d5a0b..7aa3e5f57 100644 --- a/tgt-vvp/Makefile.in +++ b/tgt-vvp/Makefile.in @@ -21,8 +21,6 @@ # SHELL = /bin/sh -VERSION = 0.0 - suffix = @install_suffix@ prefix = @prefix@ diff --git a/tgt-vvp/vvp.c b/tgt-vvp/vvp.c index ef714e2fb..95503fc71 100644 --- a/tgt-vvp/vvp.c +++ b/tgt-vvp/vvp.c @@ -24,6 +24,7 @@ */ # include "vvp_priv.h" +# include "version.h" # include # include # include @@ -39,7 +40,10 @@ inline static void draw_execute_header(ivl_design_t des) fprintf(vvp_out, "#! %s\n", cp); fchmod(fileno(vvp_out), 0755); } +#else + fprintf(vvp_out, "# MinGW does not support an executable header.\n"); #endif + fprintf(vvp_out, ":ivl_version \"" VERSION "\";\n"); } inline static void draw_module_declarations(ivl_design_t des) diff --git a/version.h b/version.h new file mode 100644 index 000000000..59cfe602a --- /dev/null +++ b/version.h @@ -0,0 +1,4 @@ +/* + * Set the version information here. + */ +#define VERSION "0.8.6" diff --git a/vpi/Makefile.in b/vpi/Makefile.in index 8920871ea..8a7060b57 100644 --- a/vpi/Makefile.in +++ b/vpi/Makefile.in @@ -21,8 +21,6 @@ # SHELL = /bin/sh -VERSION = 0.0 - suffix = @install_suffix@ prefix = @prefix@ diff --git a/vvp/lexor.lex b/vvp/lexor.lex index f612febca..b70dfd46f 100644 --- a/vvp/lexor.lex +++ b/vvp/lexor.lex @@ -32,6 +32,7 @@ %% /* These are some special header keywords. */ +^":ivl_version" { return K_ivl_version; } ^":vpi_module" { return K_vpi_module; } ^":vpi_time_precision" { return K_vpi_time_precision; } diff --git a/vvp/main.cc b/vvp/main.cc index de9064c67..248df5f3b 100644 --- a/vvp/main.cc +++ b/vvp/main.cc @@ -21,6 +21,7 @@ #endif # include "config.h" +# include "version.h" # include "parse_misc.h" # include "compile.h" # include "schedule.h" @@ -51,6 +52,7 @@ extern "C" const char*optarg; #endif bool verbose_flag = false; +bool version_flag = false; static char log_buffer[4096]; @@ -110,6 +112,62 @@ inline static void print_rusage(struct rusage *, struct rusage *){}; #endif // ! defined(HAVE_SYS_RESOURCE_H) +static bool have_ivl_version = false; +/* + * Verify that the input file has a compatible version. + */ +void verify_version(char*ivl_ver, char*commit) +{ + have_ivl_version = true; + + if (verbose_flag) { + vpi_mcd_printf(1, " ... VVP file version %s", ivl_ver); + if (commit) vpi_mcd_printf(1, " %s", commit); + vpi_mcd_printf(1, "\n"); + } + free(commit); + + char*vvp_ver = strdup(VERSION); + char *vp, *ip; + + /* Check the major/minor version. */ + ip = strrchr(ivl_ver, '.'); + *ip = '\0'; + vp = strrchr(vvp_ver, '.'); + *vp = '\0'; + if (strcmp(ivl_ver, vvp_ver) != 0) { + vpi_mcd_printf(1, "Error: VVP input file version %s can not " + "be run with run time version %s!\n", + ivl_ver, vvp_ver); + exit(1); + } + + /* Check that the sub-version is compatible. */ + ip += 1; + vp += 1; + int ivl_sv, vvp_sv; + if (strcmp(ip, "devel") == 0) { + ivl_sv = -1; + } else { + int res = sscanf(ip, "%d", &ivl_sv); + assert(res == 1); + } + if (strcmp(vp, "devel") == 0) { + vvp_sv = -1; + } else { + int res = sscanf(vp, "%d", &vvp_sv); + assert(res == 1); + } + if (ivl_sv > vvp_sv) { + if (verbose_flag) vpi_mcd_printf(1, " ... "); + vpi_mcd_printf(1, "Warning: VVP input file sub-version %s is " + "greater than the run time sub-version %s!\n", + ip, vp); + } + + free(ivl_ver); + free(vvp_ver); +} unsigned module_cnt = 0; const char*module_tab[64]; @@ -145,7 +203,7 @@ int main(int argc, char*argv[]) /* For non-interactive runs we do not want to run the interactive * debugger, so make $stop just execute a $finish. */ stop_is_finish = false; - while ((opt = getopt(argc, argv, "+dhl:M:m:nv")) != EOF) switch (opt) { + while ((opt = getopt(argc, argv, "+dhl:M:m:nvV")) != EOF) switch (opt) { case 'h': fprintf(stderr, "Usage: vvp [options] input-file [+plusargs...]\n" @@ -156,7 +214,8 @@ int main(int argc, char*argv[]) " -M - Clear VPI module path\n" " -m module Load vpi module.\n" " -n Non-interactive ($stop = $finish).\n" - " -v Verbose progress messages.\n" ); + " -v Verbose progress messages.\n" + " -V Print the version information.\n" ); exit(0); case 'l': logfile_name = optarg; @@ -178,6 +237,9 @@ int main(int argc, char*argv[]) case 'v': verbose_flag = true; break; + case 'V': + version_flag = true; + break; default: flag_errors += 1; } @@ -185,6 +247,27 @@ int main(int argc, char*argv[]) if (flag_errors) return flag_errors; + if (version_flag) { + fprintf(stderr, "Icarus Verilog runtime version " VERSION "\n\n"); + fprintf(stderr, "Copyright 2001-2006 Stephen Williams\n\n"); + fprintf(stderr, +" This program is free software; you can redistribute it and/or modify\n" +" it under the terms of the GNU General Public License as published by\n" +" the Free Software Foundation; either version 2 of the License, or\n" +" (at your option) any later version.\n" +"\n" +" This program is distributed in the hope that it will be useful,\n" +" but WITHOUT ANY WARRANTY; without even the implied warranty of\n" +" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n" +" GNU General Public License for more details.\n" +"\n" +" You should have received a copy of the GNU General Public License along\n" +" with this program; if not, write to the Free Software Foundation, Inc.,\n" +" 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.\n\n" +); + return 0; + } + if (optind == argc) { fprintf(stderr, "%s: no input file.\n", argv[0]); return -1; @@ -229,6 +312,12 @@ int main(int argc, char*argv[]) if (int rc = compile_design(design_path)) return rc; + if (!have_ivl_version) { + if (verbose_flag) vpi_mcd_printf(1, "... "); + vpi_mcd_printf(1, "Warning: vvp input file may not be correct " + "version!\n"); + } + if (verbose_flag) { vpi_mcd_printf(1, "Compile cleanup...\n"); } diff --git a/vvp/parse.y b/vvp/parse.y index a819cda09..66728bd88 100644 --- a/vvp/parse.y +++ b/vvp/parse.y @@ -68,7 +68,7 @@ extern FILE*yyin; %token K_FORCE K_WORD %token K_VAR K_VAR_S K_VAR_I K_vpi_call K_vpi_func K_vpi_func_r %token K_disable K_fork -%token K_vpi_module K_vpi_time_precision +%token K_ivl_version K_vpi_module K_vpi_time_precision %token T_INSTR %token T_LABEL @@ -101,7 +101,11 @@ header_lines ; header_line - : K_vpi_module T_STRING ';' + : K_ivl_version T_STRING ';' + { verify_version($2, NULL); } + | K_ivl_version T_STRING T_STRING';' + { verify_version($2, $3); } + | K_vpi_module T_STRING ';' { compile_load_vpi_module($2); } | K_vpi_time_precision '+' T_NUMBER ';' { compile_vpi_time_precision($3); } diff --git a/vvp/parse_misc.h b/vvp/parse_misc.h index d2843c8f5..5ac98e7bb 100644 --- a/vvp/parse_misc.h +++ b/vvp/parse_misc.h @@ -31,6 +31,12 @@ */ extern int compile_design(const char*path); +/* + * This routine is called to check that the input file has a compatible + * version. + */ +extern void verify_version(char *ivl_ver, char* commit); + /* * various functions shared by the lexor and the parser. */