Add the ivl -C flag for bulk configuration

from the driver, and use that to run library
 modules through the preprocessor.
This commit is contained in:
steve 2002-05-28 00:50:39 +00:00
parent 597ed1681a
commit 9a4ee873e1
7 changed files with 153 additions and 21 deletions

View File

@ -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.10 2002/05/24 01:13:00 steve Exp $"
#ident "$Id: compiler.h,v 1.11 2002/05/28 00:50:39 steve Exp $"
#endif
# include <list>
@ -90,8 +90,16 @@ enum generation_t {
extern generation_t generation_flag;
/* This is the string to use to invoke the preprocessor. */
extern char*ivlpp_string;
/*
* $Log: compiler.h,v $
* Revision 1.11 2002/05/28 00:50:39 steve
* Add the ivl -C flag for bulk configuration
* from the driver, and use that to run library
* modules through the preprocessor.
*
* Revision 1.10 2002/05/24 01:13:00 steve
* Support language generation flag -g.
*

View File

@ -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.8 2002/05/24 01:13:00 steve Exp $"
#ident "$Id: build_string.c,v 1.9 2002/05/28 00:50:39 steve Exp $"
#endif
# include "config.h"
@ -72,6 +72,12 @@ int build_string(char*output, size_t olen, const char*pattern)
olen -= strlen(base);
break;
case 'C':
strcpy(output, iconfig_path);
output += strlen(iconfig_path);
olen -= strlen(iconfig_path);
break;
case 'g':
strcpy(output, generation);
output += strlen(generation);
@ -175,6 +181,11 @@ int build_string(char*output, size_t olen, const char*pattern)
/*
* $Log: build_string.c,v $
* Revision 1.9 2002/05/28 00:50:39 steve
* Add the ivl -C flag for bulk configuration
* from the driver, and use that to run library
* modules through the preprocessor.
*
* Revision 1.8 2002/05/24 01:13:00 steve
* Support language generation flag -g.
*

View File

@ -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.12 2002/05/24 01:13:00 steve Exp $"
#ident "$Id: globals.h,v 1.13 2002/05/28 00:50:40 steve Exp $"
#endif
# include <stddef.h>
@ -27,6 +27,9 @@
/* This is the base (i.e. -B<value>) of the Icarus Verilog files. */
extern const char*base;
/* This is the path to the iconfig file sent to ivl. */
extern char* iconfig_path;
/* This is a list of all the -f<key>=<value> options from the
command line, concatenated together. */
extern char*f_list;
@ -85,6 +88,11 @@ extern int build_string(char*out, size_t olen, const char*pattern);
/*
* $Log: globals.h,v $
* Revision 1.13 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.12 2002/05/24 01:13:00 steve
* Support language generation flag -g.
*

View File

@ -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.38 2002/05/27 23:14:06 steve Exp $"
#ident "$Id: main.c,v 1.39 2002/05/28 00:50:40 steve Exp $"
# include "config.h"
@ -110,6 +110,9 @@ char*source_path = 0;
FILE*source_file = 0;
unsigned source_count = 0;
char*iconfig_path = 0;
FILE*iconfig_file = 0;
int synth_flag = 0;
int verbose_flag = 0;
int command_file = 0;
@ -161,6 +164,7 @@ static int t_default(char*cmd, unsigned ncmd)
rc = system(cmd);
remove(source_path);
remove(iconfig_path);
if (rc != 0) {
if (rc == 127) {
fprintf(stderr, "Failed to execute: %s\n", cmd);
@ -431,6 +435,8 @@ int main(int argc, char **argv)
base = ivl_root;
#endif
/* Create a temporary file for communicating input parameters
to the preprocessor. */
source_path = strdup(tempnam(NULL, "ivrlg"));
assert(source_path);
source_file = fopen(source_path, "w");
@ -689,6 +695,31 @@ int main(int argc, char **argv)
return 0;
}
/* Create another temporary file for passing configuration
information to ivl. */
iconfig_path = strdup(tempnam(NULL, "ivrlh"));
assert(iconfig_path);
iconfig_file = fopen(iconfig_path, "w");
if (NULL == iconfig_file) {
fprintf(stderr, "%s: Error opening temporary file %s\n",
argv[0], iconfig_path);
fprintf(stderr, "%s: Please check TMP or TMPDIR.\n", argv[0]);
fclose(source_file);
remove(source_path);
return 1;
}
/* Write the preprocessor command needed to preprocess a
single file. This may be used to preprocess library
files. */
fprintf(iconfig_file, "ivlpp:%s%civlpp -D__ICARUS__ -L %s %s\n",
base, sep,
inc_list? inc_list : "",
def_list? def_list : "");
/* Done writing to the iconfig file. Close it now. */
fclose(iconfig_file);
if (strcmp(targ,"vvm") == 0)
return t_vvm(cmd, ncmd);
else {
@ -700,6 +731,11 @@ int main(int argc, char **argv)
/*
* $Log: main.c,v $
* 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__
*

View File

@ -63,20 +63,20 @@
# be useful and interesting if the -N flag is included.
[-tnull -S]
<ivl>%B/ivl %[v-v] %g %y %Y %W %s %[M-M%M] %[N-N%N] %[T-T%T] -tdll -fDLL=%B/null.tgt -Fsynth -Fsyn-rules -- -
<ivl>%B/ivl %[v-v] -C%C %g %y %Y %W %s %[M-M%M] %[N-N%N] %[T-T%T] -tdll -fDLL=%B/null.tgt -Fsynth -Fsyn-rules -- -
[-tnull]
<ivl>%B/ivl %[v-v] %g %y %Y %W %s %[M-M%M] %[N-N%N] %[T-T%T] -tdll -fDLL=%B/null.tgt -- -
<ivl>%B/ivl %[v-v] -C%C %g %y %Y %W %s %[M-M%M] %[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]
<ivl>%B/ivl %[v-v] %g %y %Y %W %s %[M-M%M] %[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 -- -
<ivl>%B/ivl %[v-v] -C%C %g %y %Y %W %s %[M-M%M] %[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]
<ivl>%B/ivl %[v-v] %g %y %Y %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 -- -
<ivl>%B/ivl %[v-v] -C%C %g %y %Y %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 -- -
# --
# The vvm target uses the <ivl> string to take the preprocessed code from
@ -85,20 +85,20 @@
# on the result.
[-tvvm]
<ivl>%B/ivl %[v-v] %g %y %Y %W %s %[N-N%N] %[T-T%T] -tvvm -Fcprop -Fnodangle -fVPI_MODULE_PATH=%B %f %m -o%o.cc -- -
<ivl>%B/ivl %[v-v] -C%C %g %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]
<ivl>%B/ivl %y %Y %[v-v] %g %s %[M-M%M] %[N-N%N] %[T-T%T] -txnf -Fsynth -Fsyn-rules -Fxnfio -Fcprop -Fnodangle -o%o -- -
<ivl>%B/ivl -C%C %y %Y %[v-v] %g %s %[M-M%M] %[N-N%N] %[T-T%T] -txnf -Fsynth -Fsyn-rules -Fxnfio -Fcprop -Fnodangle -o%o -- -
# And this is another XNF code generator, under development.
[-tfpga]
<ivl>%B/ivl %y %Y %[v-v] %g %s %[M-M%M] %[N-N%N] %[T-T%T] %f -tdll -fDLL=%B/fpga.tgt -Fsynth -Fsyn-rules -Fcprop -Fnodangle -o%o -- -
<ivl>%B/ivl -C%C %y %Y %[v-v] %g %s %[M-M%M] %[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=<type>
# flag to specify the part type.
[-tpal]
<ivl>%B/ivl %y %Y %[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 -- -
<ivl>%B/ivl -C%C %y %Y %[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 -- -

View File

@ -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.5 2002/04/04 05:26:13 steve Exp $"
#ident "$Id: load_module.cc,v 1.6 2002/05/28 00:50:39 steve Exp $"
#endif
# include "config.h"
@ -49,14 +49,32 @@ bool load_module(const char*type)
if(depend_file) {
fprintf(depend_file, "%s\n", path);
}
if (verbose_flag) {
cerr << "Loading library file " << path << "." << endl;
if (ivlpp_string) {
fclose(file);
char*cmdline = (char*)malloc(strlen(ivlpp_string) +
strlen(path) + 2);
strcpy(cmdline, ivlpp_string);
strcat(cmdline, " ");
strcat(cmdline, path);
file = popen(cmdline, "r");
if (verbose_flag)
cerr << "Executing: " << cmdline << endl;
pform_parse(path, file);
fclose(file);
} else {
if (verbose_flag)
cerr << "Loading library file "
<< path << "." << endl;
pform_parse(path, file);
fclose(file);
}
pform_parse(path, file);
fclose(file);
return true;
}
}
@ -66,6 +84,11 @@ bool load_module(const char*type)
/*
* $Log: load_module.cc,v $
* Revision 1.6 2002/05/28 00:50:39 steve
* Add the ivl -C flag for bulk configuration
* from the driver, and use that to run library
* modules through the preprocessor.
*
* Revision 1.5 2002/04/04 05:26:13 steve
* Add dependency generation.
*

50
main.cc
View File

@ -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.55 2002/05/24 01:13:00 steve Exp $"
#ident "$Id: main.cc,v 1.56 2002/05/28 00:50:39 steve Exp $"
#endif
# include "config.h"
@ -83,6 +83,8 @@ map<string,string> flags;
list<const char*> library_dirs;
list<const char*> library_suff;
char*ivlpp_string = 0;
FILE *depend_file = NULL;
/*
* These are the warning enable flags.
@ -97,6 +99,40 @@ bool error_implicit = false;
*/
bool verbose_flag = false;
static void read_iconfig_file(const char*ipath)
{
char buf[8*1024];
FILE*ifile = fopen(ipath, "r");
if (ifile == 0)
return;
while (fgets(buf, sizeof buf, ifile) != 0) {
char*cp = strchr(buf, ':');
if (cp == 0)
continue;
*cp++ = 0;
char*ep = cp + strlen(cp);
while (ep > cp) {
ep -= 1;
switch (*ep) {
case '\r':
case '\n':
case ' ':
case '\t':
*ep = 0;
break;
default:
ep = cp;
}
}
if (strcmp(buf, "ivlpp") == 0) {
ivlpp_string = strdup(cp);
}
}
}
static void parm_to_flagmap(const string&flag)
{
@ -211,7 +247,12 @@ int main(int argc, char*argv[])
min_typ_max_flag = TYP;
min_typ_max_warn = 10;
while ((opt = getopt(argc, argv, "F:f:g:hm:M:N:o:P:p:s:T:t:VvW:Y:y:")) != EOF) switch (opt) {
while ((opt = getopt(argc, argv, "C:F:f:g:hm:M:N:o:P:p:s:T:t:VvW:Y:y:")) != EOF) switch (opt) {
case 'C':
read_iconfig_file(optarg);
break;
case 'F': {
net_func tmp = name_to_net_func(optarg);
if (tmp == 0) {
@ -529,6 +570,11 @@ int main(int argc, char*argv[])
/*
* $Log: main.cc,v $
* Revision 1.56 2002/05/28 00:50:39 steve
* Add the ivl -C flag for bulk configuration
* from the driver, and use that to run library
* modules through the preprocessor.
*
* Revision 1.55 2002/05/24 01:13:00 steve
* Support language generation flag -g.
*