diff --git a/driver/cflexor.lex b/driver/cflexor.lex index 770faa742..4d2ab39a0 100644 --- a/driver/cflexor.lex +++ b/driver/cflexor.lex @@ -88,6 +88,8 @@ int cmdfile_stack_ptr = 0; "+timescale+" { BEGIN(PLUS_ARGS); return TOK_TIMESCALE; } +"+vhdl-work+" { BEGIN(PLUS_ARGS); return TOK_VHDL_WORK; } + /* 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 c768b9e37..36044d0a0 100644 --- a/driver/cfparse.y +++ b/driver/cfparse.y @@ -59,7 +59,7 @@ static void translate_file_name(char*text) %token TOK_Da TOK_Dc TOK_Dv TOK_Dy %token TOK_DEFINE TOK_INCDIR TOK_INTEGER_WIDTH TOK_LIBDIR TOK_LIBDIR_NOCASE -%token TOK_LIBEXT TOK_PARAMETER TOK_TIMESCALE +%token TOK_LIBEXT TOK_PARAMETER TOK_TIMESCALE TOK_VHDL_WORK %token TOK_PLUSARG TOK_PLUSWORD TOK_STRING %% @@ -157,6 +157,12 @@ item free($2); } + | TOK_VHDL_WORK TOK_PLUSARG + { char*tmp = substitutions($2); + vhdlpp_work = tmp; + free($2); + } + /* The +incdir token introduces a list of + arguments that are the include directories to search. */ diff --git a/driver/globals.h b/driver/globals.h index 810787f93..36968fc1e 100644 --- a/driver/globals.h +++ b/driver/globals.h @@ -24,6 +24,8 @@ /* This is the integer-width argument that will be passed to ivl. */ extern unsigned integer_width; +extern const char*vhdlpp_work; + /* Perform variable substitutions on the string. */ extern char* substitutions(const char*str); diff --git a/driver/main.c b/driver/main.c index 93af52ac0..5b0d25ecd 100644 --- a/driver/main.c +++ b/driver/main.c @@ -108,6 +108,7 @@ extern void cfreset(FILE*fd, const char*path); const char*base = 0; const char*ivlpp_dir = 0; const char*vhdlpp_dir= 0; +const char*vhdlpp_work = 0; const char*mtm = 0; const char*opath = "a.out"; const char*npath = 0; @@ -1026,8 +1027,6 @@ int main(int argc, char **argv) snprintf(iconfig_common_path, sizeof iconfig_common_path, "%s%c%s%s.conf", base, sep, targ, synth_flag? "-s" : ""); - fprintf(defines_file, "vhdlpp:%s%cvhdlpp\n", vhdlpp_dir, sep); - /* Write values to the iconfig file. */ fprintf(iconfig_file, "basedir:%s\n", base); @@ -1102,6 +1101,11 @@ int main(int argc, char **argv) fprintf(defines_file, "M%c:%s\n", depmode, depfile); } + if (vhdlpp_work == 0) + vhdlpp_work = "ivl_vhdl_work"; + fprintf(defines_file, "vhdlpp:%s%cvhdlpp\n", vhdlpp_dir, sep); + fprintf(defines_file, "vhdlpp-work:%s\n", vhdlpp_work); + /* Process parameter definition from command line. The last defined would override previous ones. */ int pitr; diff --git a/ivlpp/globals.h b/ivlpp/globals.h index 236659684..3d1455b22 100644 --- a/ivlpp/globals.h +++ b/ivlpp/globals.h @@ -35,6 +35,8 @@ extern char**include_dir; extern unsigned include_cnt; /* Program to use for VHDL processing. */ extern char*vhdlpp_path; +/* vhdlpp work directory */ +extern char*vhdlpp_work; extern int relative_include; diff --git a/ivlpp/lexor.lex b/ivlpp/lexor.lex index ecb67d4f4..09ec6aa48 100644 --- a/ivlpp/lexor.lex +++ b/ivlpp/lexor.lex @@ -1790,7 +1790,7 @@ static void open_input_file(struct include_stack_t*isp) cmdlen += 32; char*cmd = malloc(cmdlen); - snprintf(cmd, cmdlen, "%s %s", vhdlpp_path, isp->path); + snprintf(cmd, cmdlen, "%s -w'%s' %s", vhdlpp_path, vhdlpp_work, isp->path); isp->file = popen(cmd, "r"); isp->file_close = pclose; diff --git a/ivlpp/main.c b/ivlpp/main.c index 8a92da3e1..a467e6a7a 100644 --- a/ivlpp/main.c +++ b/ivlpp/main.c @@ -59,6 +59,8 @@ char *dep_path = NULL; char dep_mode = 'a'; /* Path to vhdlpp */ char *vhdlpp_path = 0; +/* vhdlpp work directory */ +char *vhdlpp_work = 0; /* * Keep in source_list an array of pointers to file names. The array @@ -174,6 +176,13 @@ static int flist_read_flags(const char*path) vhdlpp_path = strdup(arg); } + } else if (strcmp(cp,"vhdlpp-work") == 0) { + if (vhdlpp_work) { + fprintf(stderr, "Ignore duplicate vhdlpp-work flags\n"); + } else { + vhdlpp_work = strdup(arg); + } + } else { fprintf(stderr, "%s: Invalid keyword %s\n", path, cp); } @@ -403,6 +412,10 @@ int main(int argc, char*argv[]) return 1; } + if (vhdlpp_work == 0) { + vhdlpp_work = strdup("ivl_vhdl_work"); + } + /* Pass to the lexical analyzer the list of input file, and start scanning. */ reset_lexor(out, source_list); diff --git a/vhdlpp/main.cc b/vhdlpp/main.cc index 1a3d2f3f2..8fac8e40a 100644 --- a/vhdlpp/main.cc +++ b/vhdlpp/main.cc @@ -1,7 +1,6 @@ const char COPYRIGHT[] = "Copyright (c) 2011 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 @@ -22,6 +21,38 @@ const char COPYRIGHT[] = # include "version_base.h" # include "version_tag.h" +/* + * Usage: vhdlpp [flags] sourcefile... + * Flags: + * + ** -D + * This activates various sorts of debugging aids. The + * specifies which debugging aid to activate. Valid tokens are: + * + * yydebug | no-yydebug + * Enable (disable) debug prints from the bison parser + * + * libraries= + * Enable debugging of library support by dumping library + * information to the file named . + * + * entities= + * Enable debugging of elaborated entities by writing the + * elaboration results to the file named . + * + ** -v + * Verbose operation. Display verbose non-debug information. + * + ** -V + * Version. Print the version of this binary. + * + ** -w + * Work path. This sets the path to the working library + * directory. I write into that directory files for packages that + * I declare, and I read from that directory packages that are + * already declared. The default path is "ivl_vhdl_work". + */ + const char NOTICE[] = " 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"