diff --git a/tgt-vvp/vvp.c b/tgt-vvp/vvp.c index 3fe0bf0ef..70815794f 100644 --- a/tgt-vvp/vvp.c +++ b/tgt-vvp/vvp.c @@ -53,7 +53,15 @@ __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 "\""); + /* I am assuming that a base release will have a blank tag. */ + if (strcmp(VERSION_TAG, "") != 0) { + fprintf(vvp_out, " \"(" VERSION_TAG ")\""); + } + fprintf(vvp_out, ";\n"); } __inline__ static void draw_module_declarations(ivl_design_t des) diff --git a/vvp/lexor.lex b/vvp/lexor.lex index 362773f4f..813681569 100644 --- a/vvp/lexor.lex +++ b/vvp/lexor.lex @@ -32,6 +32,7 @@ %% /* These are some special header/footer keywords. */ +^":ivl_version" { return K_ivl_version; } ^":vpi_module" { return K_vpi_module; } ^":vpi_time_precision" { return K_vpi_time_precision; } ^":file_names" { return K_file_names; } diff --git a/vvp/main.cc b/vvp/main.cc index ddf7aacd4..a2879ada3 100644 --- a/vvp/main.cc +++ b/vvp/main.cc @@ -133,6 +133,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]; @@ -289,6 +345,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 3a99ce994..74e631c35 100644 --- a/vvp/parse.y +++ b/vvp/parse.y @@ -86,7 +86,7 @@ static struct __vpiModPath*modpath_dst = 0; %token K_UDP K_UDP_C K_UDP_S %token K_VAR K_VAR_S K_VAR_I K_VAR_R K_vpi_call K_vpi_func K_vpi_func_r %token K_disable K_fork -%token K_vpi_module K_vpi_time_precision K_file_names +%token K_ivl_version K_vpi_module K_vpi_time_precision K_file_names %token T_INSTR %token T_LABEL @@ -121,7 +121,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 441e42ab3..859ff8787 100644 --- a/vvp/parse_misc.h +++ b/vvp/parse_misc.h @@ -1,7 +1,7 @@ #ifndef __parse_misc_H #define __parse_misc_H /* - * Copyright (c) 2001 Stephen Williams (steve@icarus.com) + * Copyright (c) 2001-2008 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 @@ -18,10 +18,6 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ -#ifdef HAVE_CVS_IDENT -#ident "$Id: parse_misc.h,v 1.8 2006/09/23 04:57:20 steve Exp $" -#endif - # include "vpi_priv.h" @@ -31,6 +27,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. */ @@ -76,35 +78,4 @@ extern void argv_add(struct argv_s*obj, vpiHandle); extern void argv_sym_add(struct argv_s*obj, char *); extern void argv_sym_lookup(struct argv_s*obj); -/* - * $Log: parse_misc.h,v $ - * Revision 1.8 2006/09/23 04:57:20 steve - * Basic support for specify timing. - * - * Revision 1.7 2002/08/12 01:35:08 steve - * conditional ident string using autoconfig. - * - * Revision 1.6 2001/07/11 04:43:57 steve - * support postpone of $systask parameters. (Stephan Boettcher) - * - * Revision 1.5 2001/05/02 23:16:50 steve - * Document memory related opcodes, - * parser uses numbv_s structures instead of the - * symbv_s and a mess of unions, - * Add the %is/sub instruction. - * (Stephan Boettcher) - * - * Revision 1.4 2001/05/01 01:09:39 steve - * Add support for memory objects. (Stephan Boettcher) - * - * Revision 1.3 2001/03/20 06:16:24 steve - * Add support for variable vectors. - * - * Revision 1.2 2001/03/18 04:35:18 steve - * Add support for string constants to VPI. - * - * Revision 1.1 2001/03/11 00:29:39 steve - * Add the vvp engine to cvs. - * - */ #endif