From 548ff4f89a8ea4624a7a22ecdee1e7c8897b2ae1 Mon Sep 17 00:00:00 2001 From: steve Date: Thu, 22 Mar 2001 22:38:13 +0000 Subject: [PATCH] Detect undefined system tasks at compile time. --- vvp/compile.cc | 8 +++++++- vvp/compile.h | 11 ++++++++++- vvp/main.cc | 11 ++++++++++- vvp/mkinstalldirs | 40 ++++++++++++++++++++++++++++++++++++++++ vvp/vpi_tasks.cc | 12 +++++++++++- 5 files changed, 78 insertions(+), 4 deletions(-) create mode 100755 vvp/mkinstalldirs diff --git a/vvp/compile.cc b/vvp/compile.cc index 7e3a8a441..3cb624eac 100644 --- a/vvp/compile.cc +++ b/vvp/compile.cc @@ -17,7 +17,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ #if !defined(WINNT) -#ident "$Id: compile.cc,v 1.10 2001/03/22 05:28:41 steve Exp $" +#ident "$Id: compile.cc,v 1.11 2001/03/22 22:38:13 steve Exp $" #endif # include "compile.h" @@ -32,6 +32,7 @@ # include # include +unsigned compile_errors = 0; /* * The opcode table lists all the code mnemonics, along with their @@ -367,6 +368,8 @@ void compile_vpi_call(char*label, char*name, unsigned argc, vpiHandle*argv) /* Create a vpiHandle that bundles the call information, and store that handle in the instruction. */ code->handle = vpip_build_vpi_call(name, argc, argv); + if (code->handle == 0) + compile_errors += 1; /* Done with the lexor-allocated name string. */ free(name); @@ -515,6 +518,9 @@ void compile_dump(FILE*fd) /* * $Log: compile.cc,v $ + * Revision 1.11 2001/03/22 22:38:13 steve + * Detect undefined system tasks at compile time. + * * Revision 1.10 2001/03/22 05:28:41 steve * Add code label forward references. * diff --git a/vvp/compile.h b/vvp/compile.h index 6b96caf4c..046ba3adb 100644 --- a/vvp/compile.h +++ b/vvp/compile.h @@ -19,7 +19,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ #if !defined(WINNT) -#ident "$Id: compile.h,v 1.7 2001/03/21 05:13:03 steve Exp $" +#ident "$Id: compile.h,v 1.8 2001/03/22 22:38:14 steve Exp $" #endif # include @@ -39,6 +39,12 @@ extern void compile_init(void); extern void compile_cleanup(void); +/* + * This is a count of errors encountered during compilation. If this + * is non-zero, then simulation is not recommended. + */ +extern unsigned compile_errors; + /* * This function is called by the parser to compile a functor * statement. The strings passed in are allocated by the lexor, but @@ -111,6 +117,9 @@ extern void compile_dump(FILE*fd); /* * $Log: compile.h,v $ + * Revision 1.8 2001/03/22 22:38:14 steve + * Detect undefined system tasks at compile time. + * * Revision 1.7 2001/03/21 05:13:03 steve * Allow var objects as vpiHandle arguments to %vpi_call. * diff --git a/vvp/main.cc b/vvp/main.cc index edc5ea846..4756b5f6d 100644 --- a/vvp/main.cc +++ b/vvp/main.cc @@ -17,7 +17,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ #if !defined(WINNT) -#ident "$Id: main.cc,v 1.5 2001/03/22 21:26:54 steve Exp $" +#ident "$Id: main.cc,v 1.6 2001/03/22 22:38:14 steve Exp $" #endif # include "config.h" @@ -83,6 +83,12 @@ int main(int argc, char*argv[]) fclose(fd); } + if (compile_errors > 0) { + fprintf(stderr, "%s: Program not runnable, %u errors.\n", + design_path, compile_errors); + return compile_errors; + } + schedule_simulate(); return 0; @@ -90,6 +96,9 @@ int main(int argc, char*argv[]) /* * $Log: main.cc,v $ + * Revision 1.6 2001/03/22 22:38:14 steve + * Detect undefined system tasks at compile time. + * * Revision 1.5 2001/03/22 21:26:54 steve * Compile in a default VPI module dir. * diff --git a/vvp/mkinstalldirs b/vvp/mkinstalldirs new file mode 100755 index 000000000..024301e8e --- /dev/null +++ b/vvp/mkinstalldirs @@ -0,0 +1,40 @@ +#! /bin/sh +# mkinstalldirs --- make directory hierarchy +# Author: Noah Friedman +# Created: 1993-05-16 +# Public domain + +# $Id: mkinstalldirs,v 1.1 2001/03/22 22:38:14 steve Exp $ + +errstatus=0 + +for file +do + set fnord `echo ":$file" | sed -ne 's/^:\//#/;s/^://;s/\// /g;s/^#/\//;p'` + shift + + pathcomp= + for d + do + pathcomp="$pathcomp$d" + case "$pathcomp" in + -* ) pathcomp=./$pathcomp ;; + esac + + if test ! -d "$pathcomp"; then + echo "mkdir $pathcomp" 1>&2 + + mkdir "$pathcomp" || lasterr=$? + + if test ! -d "$pathcomp"; then + errstatus=$lasterr + fi + fi + + pathcomp="$pathcomp/" + done +done + +exit $errstatus + +# mkinstalldirs ends here diff --git a/vvp/vpi_tasks.cc b/vvp/vpi_tasks.cc index b1c9e28c5..6b8d1634e 100644 --- a/vvp/vpi_tasks.cc +++ b/vvp/vpi_tasks.cc @@ -17,7 +17,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ #if !defined(WINNT) -#ident "$Id: vpi_tasks.cc,v 1.3 2001/03/18 04:35:18 steve Exp $" +#ident "$Id: vpi_tasks.cc,v 1.4 2001/03/22 22:38:14 steve Exp $" #endif /* @@ -152,6 +152,13 @@ vpiHandle vpip_build_vpi_call(const char*name, obj->nargs = argc; obj->args = argv; + if (obj->defn == 0) { + fprintf(stderr, "%s: This task not defined " + "by any modules. I cannot compile it.\n", name); + free(obj); + return 0; + } + /* If there is a compiletf function, call it here. */ if (obj->defn->info.compiletf) obj->defn->info.compiletf (obj->defn->info.user_data); @@ -190,6 +197,9 @@ void vpi_register_systf(const struct t_vpi_systf_data*ss) /* * $Log: vpi_tasks.cc,v $ + * Revision 1.4 2001/03/22 22:38:14 steve + * Detect undefined system tasks at compile time. + * * Revision 1.3 2001/03/18 04:35:18 steve * Add support for string constants to VPI. *