From 5ce28c193ac6e42b6b6c31dfbdf39001682a159d Mon Sep 17 00:00:00 2001 From: steve Date: Sun, 8 Oct 2000 22:36:55 +0000 Subject: [PATCH] iverilog with an iverilog.conf configuration file. --- Makefile.in | 31 +++--- configure.in | 2 +- driver/.cvsignore | 6 ++ driver/Makefile.in | 90 ++++++++++++++++ driver/build_string.c | 119 ++++++++++++++++++++ driver/globals.h | 52 +++++++++ iverilog.man => driver/iverilog.man | 2 +- driver/lexor.lex | 73 +++++++++++++ iverilog.c => driver/main.c | 161 ++++++++-------------------- driver/parse.y | 158 +++++++++++++++++++++++++++ iverilog.conf | 55 ++++++++++ verilog.spec | 1 + 12 files changed, 615 insertions(+), 135 deletions(-) create mode 100644 driver/.cvsignore create mode 100644 driver/Makefile.in create mode 100644 driver/build_string.c create mode 100644 driver/globals.h rename iverilog.man => driver/iverilog.man (98%) create mode 100644 driver/lexor.lex rename iverilog.c => driver/main.c (75%) create mode 100644 driver/parse.y create mode 100644 iverilog.conf diff --git a/Makefile.in b/Makefile.in index 12e2faec3..afe52c4b7 100644 --- a/Makefile.in +++ b/Makefile.in @@ -18,7 +18,7 @@ # 59 Temple Place - Suite 330 # Boston, MA 02111-1307, USA # -#ident "$Id: Makefile.in,v 1.72 2000/10/05 05:03:01 steve Exp $" +#ident "$Id: Makefile.in,v 1.73 2000/10/08 22:36:55 steve Exp $" # # SHELL = /bin/sh @@ -33,7 +33,6 @@ VPATH = $(srcdir) bindir = $(exec_prefix)/bin libdir = $(exec_prefix)/lib -mandir = @mandir@ includedir = $(prefix)/include dllib=@DLLIB@ @@ -51,10 +50,11 @@ CPPFLAGS = @CPPFLAGS@ @DEFS@ CXXFLAGS = @CXXFLAGS@ -I$(srcdir) LDFLAGS = @LDFLAGS@ -all: ivl@EXEEXT@ iverilog@EXEEXT@ +all: ivl@EXEEXT@ cd vvm ; $(MAKE) all cd vpi ; $(MAKE) all cd ivlpp ; $(MAKE) all + cd driver ; $(MAKE) all cd tgt-verilog ; $(MAKE) all cd tgt-stub ; $(MAKE) all @@ -62,6 +62,7 @@ clean: rm -f *.o parse.cc parse.cc.output parse.h dep/*.d lexor.cc lexor_keyword.cc verilog iverilog@EXEEXT@ cd vvm ; $(MAKE) clean cd vpi ; $(MAKE) clean + cd driver ; $(MAKE) clean cd ivlpp ; $(MAKE) clean cd tgt-verilog ; $(MAKE) clean cd tgt-stub ; $(MAKE) clean @@ -70,6 +71,7 @@ distclean: clean rm -f vvm/Makefile rm -f vpi/Makefile rm -f ivlpp/Makefile + rm -f driver/Makefile rm -f config.status config.cache config.log rm -f Makefile @@ -111,8 +113,6 @@ verilog: $(srcdir)/verilog.sh ivl@EXEEXT@: $O $(CXX) $(CXXFLAGS) $(rdynamic) -o ivl@EXEEXT@ $O $(dllib) -iverilog@EXEEXT@: iverilog.c - $(CC) $(CPPFLAGS) -o iverilog@EXEEXT@ -DCXX='"@CXX@"' -DIVL_ROOT='"@libdir@/ivl"' -DIVL_INC='"@includedir@"' -DIVL_LIB='"@libdir@"' -DRDYNAMIC=\"$(rdynamic)\" -DDLLIB='"@DLLIB@"' iverilog.c %.o: %.cc @[ -d dep ] || mkdir dep @@ -140,36 +140,31 @@ lexor_keyword.cc: lexor_keyword.gperf gperf -o -i 7 -C -k 1-3,$$ -L ANSI-C -H keyword_hash -N check_identifier -t lexor_keyword.gperf > lexor_keyword.cc || (rm -f lexor_keyword.cc ; false) -install: all installdirs $(bindir)/iverilog@EXEEXT@ $(libdir)/ivl/ivl@EXEEXT@ $(includedir)/ivl_target.h $(mandir)/man1/iverilog.1 +install: all installdirs $(libdir)/ivl/ivl@EXEEXT@ $(libdir)/ivl/iverilog.conf $(includedir)/ivl_target.h cd vvm ; $(MAKE) install cd vpi ; $(MAKE) install cd ivlpp ; $(MAKE) install - -$(bindir)/iverilog@EXEEXT@: ./iverilog@EXEEXT@ - $(INSTALL_PROGRAM) ./iverilog@EXEEXT@ $(bindir)/iverilog@EXEEXT@ - $(STRIP) $(bindir)/iverilog@EXEEXT@ + cd driver ; $(MAKE) install $(libdir)/ivl/ivl@EXEEXT@: ./ivl@EXEEXT@ $(INSTALL_PROGRAM) ./ivl@EXEEXT@ $(libdir)/ivl/ivl@EXEEXT@ $(STRIP) $(libdir)/ivl/ivl@EXEEXT@ +$(libdir)/ivl/iverilog.conf: $(srcdir)/iverilog.conf + $(INSTALL_DATA) $(srcdir)/iverilog.conf $(libdir)/ivl/iverilog.conf + $(includedir)/ivl_target.h: $(srcdir)/ivl_target.h $(INSTALL_DATA) $(srcdir)/ivl_target.h $(includedir)/ivl_target.h -$(mandir)/man1/iverilog.1: $(srcdir)/iverilog.man - $(INSTALL_DATA) $(srcdir)/iverilog.man $(mandir)/man1/iverilog.1 - installdirs: mkinstalldirs - $(srcdir)/mkinstalldirs $(bindir) $(includedir) $(libdir)/ivl $(mandir)/man1 + $(srcdir)/mkinstalldirs $(bindir) $(includedir) $(libdir)/ivl uninstall: rm -f $(libdir)/ivl/ivl@EXEEXT@ rm -f $(bindir)/verilog@EXEEXT@ rm -f $(bindir)/gverilog@EXEEXT@ - rm -f $(bindir)/iverilog@EXEEXT@ - rm -r $(includedir)/ivl_target.h - rm -f $(mandir)/man1/verilog.1 - rm -f $(mandir)/man1/iverilog.1 + rm -f $(includedir)/ivl_target.h + cd driver ; $(MAKE) uninstall cd vpi ; $(MAKE) uninstall cd vvm ; $(MAKE) uninstall cd ivlpp ; $(MAKE) uninstall diff --git a/configure.in b/configure.in index 4708bc9e4..86528205b 100644 --- a/configure.in +++ b/configure.in @@ -93,4 +93,4 @@ AC_SUBST(rdynamic) AC_MSG_RESULT($rdynamic) -AC_OUTPUT(Makefile vpi/Makefile ivlpp/Makefile vvm/Makefile tgt-stub/Makefile tgt-verilog/Makefile) +AC_OUTPUT(Makefile vpi/Makefile ivlpp/Makefile vvm/Makefile driver/Makefile tgt-stub/Makefile tgt-verilog/Makefile) diff --git a/driver/.cvsignore b/driver/.cvsignore new file mode 100644 index 000000000..e0975e360 --- /dev/null +++ b/driver/.cvsignore @@ -0,0 +1,6 @@ +Makefile +parse.c +parse.h +parse.output +lexor.c +iverilog diff --git a/driver/Makefile.in b/driver/Makefile.in new file mode 100644 index 000000000..c880a7e6a --- /dev/null +++ b/driver/Makefile.in @@ -0,0 +1,90 @@ +# +# This source code is free software; you can redistribute it +# and/or modify it in source code form under the terms of the GNU +# Library General Public License as published by the Free Software +# Foundation; either version 2 of the License, or (at your option) +# any later version. In order to redistribute the software in +# binary form, you will need a Picture Elements Binary Software +# License. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Library General Public License for more details. +# +# You should have received a copy of the GNU Library General Public +# License 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: Makefile.in,v 1.1 2000/10/08 22:36:56 steve Exp $" +# +# +SHELL = /bin/sh + +VERSION = 0.0 + +prefix = @prefix@ +exec_prefix = @exec_prefix@ +srcdir = @srcdir@ + +VPATH = $(srcdir) + +bindir = $(exec_prefix)/bin +libdir = $(exec_prefix)/lib +includedir = $(prefix)/include +mandir = @mandir@ + +dllib=@DLLIB@ +rdynamic=@rdynamic@ + +CC = @CC@ +CXX = @CXX@ +INSTALL = @INSTALL@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_DATA = @INSTALL_DATA@ + +CPPFLAGS = @CPPFLAGS@ @DEFS@ +CFLAGS = @CFLAGS@ +LDFLAGS = @LDFLAGS@ + +all: iverilog@EXEEXT@ + +clean: + rm -f *.o lexor.c parse.c parse.h parse.output + +O = main.o build_string.o lexor.o parse.o + +iverilog@EXEEXT@: $O + $(CC) $(LDFLAGS) $O -o iverilog@EXEEXT@ + +lexor.c: lexor.lex + flex -s -olexor.c lexor.lex + +parse.h parse.c: parse.y + bison --verbose -t -d parse.y -o parse.c + + +main.o: main.c globals.h + $(CC) $(CPPFLAGS) -c -DCXX='"@CXX@"' -DIVL_ROOT='"@libdir@/ivl"' -DIVL_INC='"@includedir@"' -DIVL_LIB='"@libdir@"' -DRDYNAMIC=\"$(rdynamic)\" -DDLLIB='"@DLLIB@"' main.c + +build_string.o: build_string.c globals.h +lexor.o: lexor.c parse.h globals.h +parse.o: parse.c + + +install: all installdirs $(bindir)/iverilog@EXEEXT@ $(mandir)/man1/iverilog.1 + +$(bindir)/iverilog@EXEEXT@: ./iverilog@EXEEXT@ + $(INSTALL_PROGRAM) ./iverilog@EXEEXT@ $(bindir)/iverilog@EXEEXT@ + +$(mandir)/man1/iverilog.1: $(srcdir)/iverilog.man + $(INSTALL_DATA) $(srcdir)/iverilog.man $(mandir)/man1/iverilog.1 + +installdirs: ../mkinstalldirs + $(srcdir)/../mkinstalldirs $(bindir) $(mandir)/man1 + +uninstall: + rm -f $(bindir)/iverilog@EXEEXT@ + rm -f $(mandir)/man1/iverilog.1 diff --git a/driver/build_string.c b/driver/build_string.c new file mode 100644 index 000000000..02ffca615 --- /dev/null +++ b/driver/build_string.c @@ -0,0 +1,119 @@ +/* + * Copyright (c) 2000 Stephen Williams (steve@picturel.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 + * General Public License as published by the Free Software + * Foundation; either version 2 of the License, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA + */ +#if !defined(WINNT) && !defined(macintosh) +#ident "$Id: build_string.c,v 1.1 2000/10/08 22:36:56 steve Exp $" +#endif + +# include "globals.h" +# include +# include + +int build_string(char*output, size_t olen, const char*pattern) +{ + char tmp_buf[1024]; + + char*output_save = output; + while (*pattern) { + + if (*pattern == '%') { + pattern += 1; + switch (*pattern) { + case 0: + break; + + case '%': + *output++ = '%'; + break; + + case '?': { + const char*tail; + pattern += 1; + assert(*pattern); + tail = strchr(pattern+1, ';'); + assert(tail); + strncpy(tmp_buf, pattern+1, tail-pattern-1); + tmp_buf[tail-pattern-1] = 0; + + if (((*pattern == 's') && start) + || ((*pattern == 'N') && npath) + || ((*pattern == 'T') && mtm)) { + int rc = build_string(output, olen, + tmp_buf); + output += rc; + olen -= rc; + } + pattern = tail; + break; + } + + case 'B': + strcpy(output, base); + output += strlen(base); + olen -= strlen(base); + break; + + case 'N': + if (npath) { + strcpy(output, npath); + output += strlen(npath); + olen -= strlen(npath); + } + 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; + } + pattern += 1; + + } else { + *output++ = *pattern++; + olen -= 1; + } + } + + *output = 0; + return output-output_save; +} + +/* + * $Log: build_string.c,v $ + * Revision 1.1 2000/10/08 22:36:56 steve + * iverilog with an iverilog.conf configuration file. + * + */ + diff --git a/driver/globals.h b/driver/globals.h new file mode 100644 index 000000000..83b2a13d0 --- /dev/null +++ b/driver/globals.h @@ -0,0 +1,52 @@ +#ifndef __globals_H +#define __globals_H +/* + * Copyright (c) 2000 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 + * General Public License as published by the Free Software + * Foundation; either version 2 of the License, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA + */ +#if !defined(WINNT) && !defined(macintosh) +#ident "$Id: globals.h,v 1.1 2000/10/08 22:36:56 steve Exp $" +#endif + +# include + + /* This is the base (i.e. -B) of the Icarus Verilog files. */ +extern const char*base; + + /* This is the optional -Tmin|typ|max setting. */ +extern const char*mtm; + + /* Ths is the optional -N value, if one was supplied. */ +extern const char*npath; + + /* This pointer is set if there was a -s parameter. */ +extern const char*start; + + /* This is the name of the selected target. */ +extern const char*targ; + +extern const char*lookup_pattern(const char*key); + +extern int build_string(char*out, size_t olen, const char*pattern); + +/* + * $Log: globals.h,v $ + * Revision 1.1 2000/10/08 22:36:56 steve + * iverilog with an iverilog.conf configuration file. + * + */ +#endif diff --git a/iverilog.man b/driver/iverilog.man similarity index 98% rename from iverilog.man rename to driver/iverilog.man index dc619d6e5..0c9433658 100644 --- a/iverilog.man +++ b/driver/iverilog.man @@ -1,4 +1,4 @@ -.TH iverilog 1 "$Date: 2000/08/09 01:34:00 $" Version "$Date: 2000/08/09 01:34:00 $" +.TH iverilog 1 "$Date: 2000/10/08 22:36:56 $" Version "$Date: 2000/10/08 22:36:56 $" .SH NAME iverilog - Icarus Verilog compiler diff --git a/driver/lexor.lex b/driver/lexor.lex new file mode 100644 index 000000000..fd4777505 --- /dev/null +++ b/driver/lexor.lex @@ -0,0 +1,73 @@ + +%{ +/* + * Copyright (c) 2000 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 + * General Public License as published by the Free Software + * Foundation; either version 2 of the License, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA + */ +#if !defined(WINNT) && !defined(macintosh) +#ident "$Id: lexor.lex,v 1.1 2000/10/08 22:36:56 steve Exp $" +#endif + +# include +# include "parse.h" + +%} + +%x CTOKENS +%x PATTERN + +%% + +"#".* { /* eat comments */; } + +"\n" { /* eat line-ends */; } + +"[" { BEGIN(CTOKENS); return '['; } + +"]" { BEGIN(0); return ']'; } + +[ \t\b]+ { /* skip white space */; } + +"-S" { return CT_S; } + +"-t"[a-zA-Z0-9]+ { + yylval.text = strdup(yytext+2); + return CT_t; } + +"<"[^>]*">" { + BEGIN(PATTERN); + yylval.text = strdup(yytext); + return PATTERN_NAME; } + +.* { + BEGIN(0); + yylval.text = strdup(yytext); + return PATTERN_TEXT; } + +. { fprintf(stderr, "driver lexor: Unmatched character: %c\n", yytext[0]); } + +%% + +void reset_lexor(FILE*fd) +{ + yyrestart(fd); +} + +int yywrap() +{ + return 1; +} diff --git a/iverilog.c b/driver/main.c similarity index 75% rename from iverilog.c rename to driver/main.c index 47024393c..56c80220c 100644 --- a/iverilog.c +++ b/driver/main.c @@ -17,13 +17,14 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ #if !defined(WINNT) -#ident "$Id: iverilog.c,v 1.22 2000/09/30 03:20:47 steve Exp $" +#ident "$Id: main.c,v 1.1 2000/10/08 22:36:56 steve Exp $" #endif #include #include #include #include +#include #include #include @@ -46,6 +47,8 @@ # define LIBVPIP "" #endif +# include "globals.h" + const char*base = IVL_ROOT; const char*mtm = 0; const char*opath = "a.out"; @@ -66,53 +69,29 @@ int verbose_flag = 0; char tmp[4096]; -static int t_null(char*cmd, unsigned ncmd) +/* + * This is the default target type. It looks up the bits that are + * needed to run the command from the configuration file (which is + * already parsed for us) so we can handle must of the generic cases. + */ +static int t_default(char*cmd, unsigned ncmd) { int rc; + const char*pattern; - sprintf(tmp, " | %s/ivl %s", base, warning_flags); - rc = strlen(tmp); - cmd = realloc(cmd, ncmd+rc+1); + pattern = lookup_pattern(""); + if (pattern == 0) { + fprintf(stderr, "No such target: %s\n", targ); + return -1; + } + + tmp[0] = ' '; + tmp[1] = '|'; + tmp[2] = ' '; + rc = build_string(tmp+3, sizeof tmp - 3, pattern); + cmd = realloc(cmd, ncmd+3+rc+1); strcpy(cmd+ncmd, tmp); - ncmd += rc; - if (start) { - sprintf(tmp, " -s%s", start); - rc = strlen(tmp); - cmd = realloc(cmd, ncmd+rc+1); - strcpy(cmd+ncmd, tmp); - ncmd += rc; - } - - if (npath) { - sprintf(tmp, " -N%s", npath); - rc = strlen(tmp); - cmd = realloc(cmd, ncmd+rc+1); - strcpy(cmd+ncmd, tmp); - ncmd += rc; - } - - if (mtm) { - sprintf(tmp, " -T%s", mtm); - rc = strlen(tmp); - cmd = realloc(cmd, ncmd+rc+1); - strcpy(cmd+ncmd, tmp); - ncmd += rc; - } - - if (verbose_flag) { - sprintf(tmp, " -v"); - rc = strlen(tmp); - cmd = realloc(cmd, ncmd+rc+1); - strcpy(cmd+ncmd, tmp); - ncmd += rc; - } - - sprintf(tmp, " -- -"); - rc = strlen(tmp); - cmd = realloc(cmd, ncmd+rc+1); - strcpy(cmd+ncmd, tmp); - ncmd += rc; if (verbose_flag) printf("translate: %s\n", cmd); @@ -309,18 +288,22 @@ static void process_warning_switch(const char*name) int main(int argc, char **argv) { + const char*config_path = 0; char*cmd; unsigned ncmd; int e_flag = 0; int opt, idx; char*cp; - while ((opt = getopt(argc, argv, "B:D:Ef:I:m:N::o:Ss:T:t:vW:")) != EOF) { + while ((opt = getopt(argc, argv, "B:C:D:Ef:I:m:N::o:Ss:T:t:vW:")) != EOF) { switch (opt) { case 'B': base = optarg; break; + case 'C': + config_path = optarg; + break; case 'D': if (def_list == 0) { def_list = malloc(strlen(" -D")+strlen(optarg)+1); @@ -424,6 +407,20 @@ int main(int argc, char **argv) return 1; } + /* Load the iverilog.conf file to get our substitution + strings. */ + { char path[1024]; + FILE*fd; + if (config_path) { + strcpy(path, config_path); + } else { + sprintf(path, "%s/iverilog.conf", base); + } + fd = fopen(path, "r"); + reset_lexor(fd); + yyparse(); + } + /* Start building the preprocess command line. */ sprintf(tmp, "%s/ivlpp %s%s", base, @@ -485,87 +482,21 @@ int main(int argc, char **argv) return 0; } - if (strcmp(targ,"null") == 0) - return t_null(cmd, ncmd); - else if (strcmp(targ,"vvm") == 0) + if (strcmp(targ,"vvm") == 0) return t_vvm(cmd, ncmd); else if (strcmp(targ,"xnf") == 0) return t_xnf(cmd, ncmd); else { - fprintf(stderr, "Unknown target: %s\n", targ); - return 1; + return t_default(cmd, ncmd); } return 0; } /* - * $Log: iverilog.c,v $ - * Revision 1.22 2000/09/30 03:20:47 steve - * Cygwin port changes from Venkat - * - * Revision 1.21 2000/09/12 01:17:19 steve - * Oops, the -m flag takes a parameter and needs the : - * - * Revision 1.20 2000/08/09 01:34:00 steve - * Add the -N switch to the iverilog command. - * - * Revision 1.19 2000/07/29 17:58:20 steve - * Introduce min:typ:max support. - * - * Revision 1.18 2000/07/11 23:30:03 steve - * More detailed handling of exit status from commands. - * - * Revision 1.17 2000/06/30 04:42:23 steve - * Catch errors from compile that leave the low 8 bits empty. - * - * Revision 1.16 2000/06/16 19:00:06 steve - * Detect some hosts that do not support -rdynamic. - * - * Revision 1.15 2000/05/17 03:53:29 steve - * Add the module option to iverilog. - * - * Revision 1.14 2000/05/14 19:41:52 steve - * Fix -f flag handling. - * - * Revision 1.13 2000/05/13 20:55:47 steve - * Use yacc based synthesizer. - * - * Revision 1.12 2000/05/09 00:02:13 steve - * Parameterize LD lib in C++ command line. - * - * Revision 1.11 2000/05/05 01:07:42 steve - * Add the -I and -D switches to iverilog. - * - * Revision 1.10 2000/05/04 20:08:20 steve - * Tell ivlpp to generate line number directives. - * - * Revision 1.9 2000/05/03 22:14:31 steve - * More features of ivl available through iverilog. - * - * Revision 1.8 2000/05/01 23:55:22 steve - * Better inc and lib paths for iverilog. - * - * Revision 1.7 2000/04/29 01:20:14 steve - * The -f flag is now in place. - * - * Revision 1.6 2000/04/26 21:11:41 steve - * Mussed up command string mashing. - * - * Revision 1.5 2000/04/26 03:33:32 steve - * Do not set width too small to hold significant bits. - * - * Revision 1.4 2000/04/23 21:14:32 steve - * The -s flag. - * - * Revision 1.3 2000/04/21 22:54:47 steve - * module path in vvm target. - * - * Revision 1.2 2000/04/21 22:51:38 steve - * Support the -tnull target type. - * - * Revision 1.1 2000/04/21 06:41:03 steve - * Add the iverilog driver program. + * $Log: main.c,v $ + * Revision 1.1 2000/10/08 22:36:56 steve + * iverilog with an iverilog.conf configuration file. * */ diff --git a/driver/parse.y b/driver/parse.y new file mode 100644 index 000000000..7a8b9e9a6 --- /dev/null +++ b/driver/parse.y @@ -0,0 +1,158 @@ +%{ +/* + * Copyright (c) 2000 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 + * General Public License as published by the Free Software + * Foundation; either version 2 of the License, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA + */ +#if !defined(WINNT) && !defined(macintosh) +#ident "$Id: parse.y,v 1.1 2000/10/08 22:36:56 steve Exp $" +#endif + +# include +# include +# include "globals.h" + + +void yyerror(const char*); + +enum drive_code_t { + CODE_S, + CODE_t, +}; + +struct drive_cond { + struct drive_cond*next; + enum drive_code_t code; + char* text; +}; + +static struct drive_cond *cur_cond = 0; + +static void add_cond(enum drive_code_t code, char*text) +{ + struct drive_cond*tmp; + tmp = calloc(1, sizeof(struct drive_cond)); + tmp->code = code; + tmp->text = text; + + tmp->next = cur_cond; + cur_cond = tmp; +} + +struct drive_pattern { + struct drive_pattern*next; + char*name; + char*text; + struct drive_cond*cond; +}; + +static struct drive_pattern *patterns = 0; +static struct drive_pattern *plast = 0; + +static void add_pattern(char*name, char*text) +{ + struct drive_pattern*tmp; + tmp = calloc(1, sizeof(struct drive_pattern)); + tmp->name = name; + tmp->text = text; + tmp->cond = cur_cond; + tmp->next = 0; + + + if (plast) { + plast->next = tmp; + plast = tmp; + } else { + patterns = tmp; + plast = tmp; + } +} + +const char*lookup_pattern(const char*key) +{ + struct drive_pattern*cur; + struct drive_cond*cc; + + for (cur = patterns ; cur ; cur = cur->next) { + + if (strcmp(key, cur->name) != 0) + continue; + + for (cc = cur->cond ; cc ; cc = cc->next) { + + switch (cc->code) { + case CODE_t: + if (strcmp(targ, cc->text) == 0) + continue; + break; + } + + break; + } + + if (cc) continue; + + return cur->text; + } + + return 0; +} + +%} + +%union { + char*text; +}; + +%token PATTERN_NAME PATTERN_TEXT +%token CT_t +%token CT_S + +%% + +start: section_list + +section_list + : section + | section_list section + ; + +section : '[' ctoken_list ']' pattern_list { cur_cond = 0; } ; + +ctoken_list + : ctoken + | ctoken_list ctoken + ; + +ctoken : CT_S { add_cond(CODE_S, 0); } + | CT_t { add_cond(CODE_t, $1); } + ; + +pattern_list + : pattern + | pattern_list pattern + ; + +pattern : PATTERN_NAME PATTERN_TEXT + { add_pattern($1, $2); } + ; + +%% + +void yyerror(const char*msg) +{ + fprintf(stderr, "%s\n", msg); +} diff --git a/iverilog.conf b/iverilog.conf new file mode 100644 index 000000000..b262ca536 --- /dev/null +++ b/iverilog.conf @@ -0,0 +1,55 @@ + +# The iverilog.conf configuration file provides to the iverilog driver +# strings based on switches that are passed by the user on the command +# line. +# +# Comments start from the hash (#) character and run to the end of the +# line. +# +# Conditions are a list of requirements between [] characters. For the +# set of patterns following a string to b activated, all the +# conditions must be true. Valid conditions are: +# +# -S -- The -S flag is passed to iverilog +# -t -- The -t parameters is passed to iverilog +# +# +# Patterns have a name and text. The name has the for, where the +# key is some key value that is required by iverilog. The commonly +# used keys are: +# +# +# The string here is the command line that is used to take the +# preprocessor output (ivlpp) and compile it with the +# target. All target types use this key. +# +# The pattern text includes % substitutions. iverilog +# substitutes values for the % sequences within the text. +# +# %B Substitute the base libdir, -B flag of iverilog. +# +# %s Substitute the start module (-s flag) from the user. +# +# %N Substitute the value of the -N flag. +# +# %T Substitute min, typ or max depending on the -T flag from the +# command line. +# +# %?; +# This substitution pattern is magical, and is the only +# multicharacter pattern. This tests the code , and +# substitutes into the output only if is true. +# The may include further substitution strings, and is +# terminated by a semi-colon (;) character. + + +# This is the null (no op) target. Thre is a synthesis version and a +# non-synthesis version. Normally, this does not matter, but this can +# be useful and interesting if the -N flag is included. + +[-tnull -S] +%B/ivl %?s-s%s; %?N-N%N; %?T-T%T; -tnull -- - + +[-tnull] +%B/ivl %?s-s%s; %?N-N%N; %?T-T%T; -tnull -- - + diff --git a/verilog.spec b/verilog.spec index 48a200760..dda49d01f 100644 --- a/verilog.spec +++ b/verilog.spec @@ -38,6 +38,7 @@ make prefix=$RPM_BUILD_ROOT/usr install %attr(-,root,root) /usr/lib/ivl/ivl %attr(-,root,root) /usr/lib/ivl/ivlpp %attr(-,root,root) /usr/lib/ivl/system.vpi +%attr(-,root,root) /usr/lib/ivl/iverilog.conf %attr(-,root,root) /usr/lib/libvvm.a %attr(-,root,root) /usr/include/ivl_target.h %attr(-,root,root) /usr/include/vpi_priv.h