From afb8e285db7019e21d7cb363ca63c8f61160ec00 Mon Sep 17 00:00:00 2001 From: steve Date: Tue, 27 Mar 2001 03:31:06 +0000 Subject: [PATCH] Support error code from target_t::end_design method. --- emit.cc | 9 +++++-- t-dll.cc | 10 +++++--- t-dll.h | 7 +++-- t-vvm.cc | 10 +++++--- t-xnf.cc | 10 +++++--- target.cc | 8 ++++-- target.h | 10 +++++--- tgt-vvp/vvp.c | 7 ++--- tgt-vvp/vvp_priv.h | 8 ++++-- tgt-vvp/vvp_process.c | 59 ++++++++++++++++++++++++++++--------------- 10 files changed, 94 insertions(+), 44 deletions(-) diff --git a/emit.cc b/emit.cc index cd2257ff0..e85fa3c0b 100644 --- a/emit.cc +++ b/emit.cc @@ -17,7 +17,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ #if !defined(WINNT) && !defined(macintosh) -#ident "$Id: emit.cc,v 1.55 2000/11/04 01:54:01 steve Exp $" +#ident "$Id: emit.cc,v 1.56 2001/03/27 03:31:06 steve Exp $" #endif /* @@ -398,7 +398,9 @@ bool Design::emit(struct target_t*tgt) const for (const NetProcTop*idx = procs_ ; idx ; idx = idx->next_) rc = rc && idx->emit(tgt); - tgt->end_design(this); + if (tgt->end_design(this) != 0) + rc = false; + return rc; } @@ -476,6 +478,9 @@ bool emit(const Design*des, const char*type) /* * $Log: emit.cc,v $ + * Revision 1.56 2001/03/27 03:31:06 steve + * Support error code from target_t::end_design method. + * * Revision 1.55 2000/11/04 01:54:01 steve * Modifications in support of gcc 2.96 * diff --git a/t-dll.cc b/t-dll.cc index 87f5d5039..e65e86e38 100644 --- a/t-dll.cc +++ b/t-dll.cc @@ -17,7 +17,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ #if !defined(WINNT) && !defined(macintosh) -#ident "$Id: t-dll.cc,v 1.28 2001/03/20 01:44:14 steve Exp $" +#ident "$Id: t-dll.cc,v 1.29 2001/03/27 03:31:06 steve Exp $" #endif # include "compiler.h" @@ -218,10 +218,11 @@ bool dll_target::start_design(const Design*des) * Here ivl is telling us that the design is scanned completely, and * here is where we call the API to process the constructed design. */ -void dll_target::end_design(const Design*) +int dll_target::end_design(const Design*) { - (target_)(&des_); + int rc = (target_)(&des_); ivl_dlclose(dll_); + return rc; } /* @@ -690,6 +691,9 @@ extern const struct target tgt_dll = { "dll", &dll_target_obj }; /* * $Log: t-dll.cc,v $ + * Revision 1.29 2001/03/27 03:31:06 steve + * Support error code from target_t::end_design method. + * * Revision 1.28 2001/03/20 01:44:14 steve * Put processes in the proper scope. * diff --git a/t-dll.h b/t-dll.h index 3e979c2d5..9bf6ba98f 100644 --- a/t-dll.h +++ b/t-dll.h @@ -19,7 +19,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ #if !defined(WINNT) && !defined(macintosh) -#ident "$Id: t-dll.h,v 1.22 2001/03/20 01:44:14 steve Exp $" +#ident "$Id: t-dll.h,v 1.23 2001/03/27 03:31:06 steve Exp $" #endif # include "target.h" @@ -52,7 +52,7 @@ struct ivl_design_s { struct dll_target : public target_t, public expr_scan_t { bool start_design(const Design*); - void end_design(const Design*); + int end_design(const Design*); bool bufz(const NetBUFZ*); void event(const NetEvent*); @@ -369,6 +369,9 @@ struct ivl_statement_s { /* * $Log: t-dll.h,v $ + * Revision 1.23 2001/03/27 03:31:06 steve + * Support error code from target_t::end_design method. + * * Revision 1.22 2001/03/20 01:44:14 steve * Put processes in the proper scope. * diff --git a/t-vvm.cc b/t-vvm.cc index cf5f2c0de..ed0092911 100644 --- a/t-vvm.cc +++ b/t-vvm.cc @@ -17,7 +17,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ #if !defined(WINNT) && !defined(macintosh) -#ident "$Id: t-vvm.cc,v 1.202 2001/02/13 04:11:24 steve Exp $" +#ident "$Id: t-vvm.cc,v 1.203 2001/03/27 03:31:06 steve Exp $" #endif # include @@ -203,7 +203,7 @@ class target_vvm : public target_t { virtual void proc_utask( const NetUTask*); virtual bool proc_wait( const NetEvWait*); virtual void proc_while(const NetWhile*); - virtual void end_design(const Design*); + virtual int end_design(const Design*); void start_process(ostream&os, const NetProcTop*); void end_process(ostream&os, const NetProcTop*); @@ -1047,7 +1047,7 @@ void target_vvm::event(const NetEvent*event) << event->get_line() << ": event " << event->full_name() << endl; } -void target_vvm::end_design(const Design*mod) +int target_vvm::end_design(const Design*mod) { if (string_counter > 0) out << "static struct __vpiStringConst string_table[" << @@ -1157,6 +1157,7 @@ void target_vvm::end_design(const Design*mod) out << "}" << endl; out.close(); + return 0; } bool target_vvm::process(const NetProcTop*top) @@ -3635,6 +3636,9 @@ extern const struct target tgt_vvm = { }; /* * $Log: t-vvm.cc,v $ + * Revision 1.203 2001/03/27 03:31:06 steve + * Support error code from target_t::end_design method. + * * Revision 1.202 2001/02/13 04:11:24 steve * Generate proper code for wide condition expressions. * diff --git a/t-xnf.cc b/t-xnf.cc index 583afc225..6d1a8abd0 100644 --- a/t-xnf.cc +++ b/t-xnf.cc @@ -17,7 +17,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ #if !defined(WINNT) && !defined(macintosh) -#ident "$Id: t-xnf.cc,v 1.40 2001/02/10 03:22:49 steve Exp $" +#ident "$Id: t-xnf.cc,v 1.41 2001/03/27 03:31:06 steve Exp $" #endif /* XNF BACKEND @@ -95,7 +95,7 @@ class target_xnf : public target_t { public: bool start_design(const Design*); - void end_design(const Design*); + int end_design(const Design*); void memory(const NetMemory*); void signal(const NetNet*); @@ -238,10 +238,11 @@ bool target_xnf::start_design(const Design*des) return true; } -void target_xnf::end_design(const Design*) +int target_xnf::end_design(const Design*) { out_ << "EOF" << endl; ncf_.close(); + return 0; } void scrape_pad_info(string str, char&dir, unsigned&num) @@ -922,6 +923,9 @@ extern const struct target tgt_xnf = { "xnf", &target_xnf_obj }; /* * $Log: t-xnf.cc,v $ + * Revision 1.41 2001/03/27 03:31:06 steve + * Support error code from target_t::end_design method. + * * Revision 1.40 2001/02/10 03:22:49 steve * Report errors when XNF code has constant X values. (PR#128) * diff --git a/target.cc b/target.cc index 3e24bf8a7..ae67b189f 100644 --- a/target.cc +++ b/target.cc @@ -17,7 +17,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ #if !defined(WINNT) && !defined(macintosh) -#ident "$Id: target.cc,v 1.49 2000/09/26 01:35:42 steve Exp $" +#ident "$Id: target.cc,v 1.50 2001/03/27 03:31:06 steve Exp $" #endif # include "target.h" @@ -312,8 +312,9 @@ void target_t::proc_while(const NetWhile*net) net->dump(cerr, 6); } -void target_t::end_design(const Design*) +int target_t::end_design(const Design*) { + return 0; } expr_scan_t::~expr_scan_t() @@ -388,6 +389,9 @@ void expr_scan_t::expr_binary(const NetEBinary*ex) /* * $Log: target.cc,v $ + * Revision 1.50 2001/03/27 03:31:06 steve + * Support error code from target_t::end_design method. + * * Revision 1.49 2000/09/26 01:35:42 steve * Remove the obsolete NetEIdent class. * diff --git a/target.h b/target.h index 1243a0424..e66074e91 100644 --- a/target.h +++ b/target.h @@ -19,7 +19,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ #if !defined(WINNT) && !defined(macintosh) -#ident "$Id: target.h,v 1.48 2000/11/04 01:54:01 steve Exp $" +#ident "$Id: target.h,v 1.49 2001/03/27 03:31:06 steve Exp $" #endif # include "netlist.h" @@ -121,8 +121,9 @@ struct target_t { virtual bool proc_wait(const NetEvWait*); virtual void proc_while(const NetWhile*); - /* Done with the design. */ - virtual void end_design(const Design*); + /* Done with the design. The target returns !0 if there is + some error in the code generation. */ + virtual int end_design(const Design*); }; /* This class is used by the NetExpr class to help with the scanning @@ -159,6 +160,9 @@ extern const struct target *target_table[]; /* * $Log: target.h,v $ + * Revision 1.49 2001/03/27 03:31:06 steve + * Support error code from target_t::end_design method. + * * Revision 1.48 2000/11/04 01:54:01 steve * Modifications in support of gcc 2.96 * diff --git a/tgt-vvp/vvp.c b/tgt-vvp/vvp.c index 2604f4f36..1205240b1 100644 --- a/tgt-vvp/vvp.c +++ b/tgt-vvp/vvp.c @@ -17,7 +17,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ #if !defined(WINNT) && !defined(macintosh) -#ident "$Id: vvp.c,v 1.3 2001/03/23 02:41:04 steve Exp $" +#ident "$Id: vvp.c,v 1.4 2001/03/27 03:31:07 steve Exp $" #endif /* @@ -50,6 +50,7 @@ static void draw_module_declarations(ivl_design_t des) int target_design(ivl_design_t des) { + int rc; ivl_scope_t root; const char*path = ivl_design_flag(des, "-o"); assert(path); @@ -65,11 +66,11 @@ int target_design(ivl_design_t des) root = ivl_design_root(des); draw_scope(root, 0); - ivl_design_process(des, draw_process, 0); + rc = ivl_design_process(des, draw_process, 0); fclose(vvp_out); - return 0; + return rc; } #ifdef __CYGWIN32__ diff --git a/tgt-vvp/vvp_priv.h b/tgt-vvp/vvp_priv.h index 09960d065..74cde5704 100644 --- a/tgt-vvp/vvp_priv.h +++ b/tgt-vvp/vvp_priv.h @@ -19,7 +19,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ #if !defined(WINNT) -#ident "$Id: vvp_priv.h,v 1.3 2001/03/22 05:06:21 steve Exp $" +#ident "$Id: vvp_priv.h,v 1.4 2001/03/27 03:31:07 steve Exp $" #endif # include "ivl_target.h" @@ -33,7 +33,8 @@ extern FILE* vvp_out; /* * This function draws a process (initial or always) into the output - * file. + * file. It normally returns 0, but returns !0 of there is some sort + * of error. */ extern int draw_process(ivl_process_t net, void*x); @@ -53,6 +54,9 @@ extern struct vector_info draw_eval_expr(ivl_expr_t exp); /* * $Log: vvp_priv.h,v $ + * Revision 1.4 2001/03/27 03:31:07 steve + * Support error code from target_t::end_design method. + * * Revision 1.3 2001/03/22 05:06:21 steve * Geneate code for conditional statements. * diff --git a/tgt-vvp/vvp_process.c b/tgt-vvp/vvp_process.c index ca7dbb3c2..d499d3368 100644 --- a/tgt-vvp/vvp_process.c +++ b/tgt-vvp/vvp_process.c @@ -17,13 +17,13 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ #if !defined(WINNT) -#ident "$Id: vvp_process.c,v 1.7 2001/03/25 03:53:24 steve Exp $" +#ident "$Id: vvp_process.c,v 1.8 2001/03/27 03:31:07 steve Exp $" #endif # include "vvp_priv.h" # include -static void show_statement(ivl_statement_t net); +static int show_statement(ivl_statement_t net); static unsigned local_count = 0; static unsigned thread_count = 0; @@ -81,7 +81,7 @@ static void set_to_nexus(ivl_nexus_t nex, unsigned bit) } } -static void show_stmt_assign(ivl_statement_t net) +static int show_stmt_assign(ivl_statement_t net) { ivl_lval_t lval; ivl_expr_t rval = ivl_stmt_rval(net); @@ -106,7 +106,7 @@ static void show_stmt_assign(ivl_statement_t net) set_to_nexus(ivl_lval_pin(lval, idx), bitchar_to_idx(bits[idx])); - return; + return 0; } { struct vector_info res = draw_eval_expr(rval); @@ -130,10 +130,12 @@ static void show_stmt_assign(ivl_statement_t net) set_to_nexus(ivl_lval_pin(lval, idx), 0); } + return 0; } -static void show_stmt_condit(ivl_statement_t net) +static int show_stmt_condit(ivl_statement_t net) { + int rc = 0; unsigned lab_false, lab_out; ivl_expr_t exp = ivl_stmt_cond_expr(net); struct vector_info cond = draw_eval_expr(exp); @@ -146,19 +148,21 @@ static void show_stmt_condit(ivl_statement_t net) fprintf(vvp_out, " %%jmp/0xz T_%05d.%d, %u;\n", thread_count, lab_false, cond.base); - show_statement(ivl_stmt_cond_true(net)); + rc += show_statement(ivl_stmt_cond_true(net)); if (ivl_stmt_cond_false(net)) { fprintf(vvp_out, " %%jmp T_%05d.%d;\n", thread_count, lab_out); fprintf(vvp_out, "T_%05d.%u\n", thread_count, lab_false); - show_statement(ivl_stmt_cond_false(net)); + rc += show_statement(ivl_stmt_cond_false(net)); fprintf(vvp_out, "T_%05d.%u\n", thread_count, lab_out); } else { fprintf(vvp_out, "T_%05d.%u\n", thread_count, lab_false); } + + return rc; } /* @@ -169,30 +173,34 @@ static void show_stmt_condit(ivl_statement_t net) * ... * # ; */ -static void show_stmt_delay(ivl_statement_t net) +static int show_stmt_delay(ivl_statement_t net) { + int rc = 0; unsigned long delay = ivl_stmt_delay_val(net); ivl_statement_t stmt = ivl_stmt_sub_stmt(net); fprintf(vvp_out, " %%delay %lu;\n", delay); - show_statement(stmt); + rc += show_statement(stmt); + + return rc; } /* * noop statements are implemented by doing nothing. */ -static void show_stmt_noop(ivl_statement_t net) +static int show_stmt_noop(ivl_statement_t net) { + return 0; } -static void show_system_task_call(ivl_statement_t net) +static int show_system_task_call(ivl_statement_t net) { unsigned idx; unsigned parm_count = ivl_stmt_parm_count(net); if (parm_count == 0) { fprintf(vvp_out, " %%vpi_call \"%s\";\n", ivl_stmt_name(net)); - return; + return 0; } fprintf(vvp_out, " %%vpi_call \"%s\"", ivl_stmt_name(net)); @@ -216,6 +224,7 @@ static void show_system_task_call(ivl_statement_t net) } fprintf(vvp_out, ";\n"); + return 0; } /* @@ -223,14 +232,15 @@ static void show_system_task_call(ivl_statement_t net) * switches on the statement type and draws code based on the type and * further specifics. */ -static void show_statement(ivl_statement_t net) +static int show_statement(ivl_statement_t net) { const ivl_statement_type_t code = ivl_statement_type(net); + int rc = 0; switch (code) { case IVL_ST_ASSIGN: - show_stmt_assign(net); + rc += show_stmt_assign(net); break; /* Begin-end blocks simply draw their contents. */ @@ -238,32 +248,35 @@ static void show_statement(ivl_statement_t net) unsigned idx; unsigned cnt = ivl_stmt_block_count(net); for (idx = 0 ; idx < cnt ; idx += 1) { - show_statement(ivl_stmt_block_stmt(net, idx)); + rc += show_statement(ivl_stmt_block_stmt(net, idx)); } break; } case IVL_ST_CONDIT: - show_stmt_condit(net); + rc += show_stmt_condit(net); break; case IVL_ST_DELAY: - show_stmt_delay(net); + rc += show_stmt_delay(net); break; case IVL_ST_NOOP: - show_stmt_noop(net); + rc += show_stmt_noop(net); break; case IVL_ST_STASK: - show_system_task_call(net); + rc += show_system_task_call(net); break; default: fprintf(stderr, "vvp.tgt: Unable to draw statement type %u\n", code); + rc += 1; break; } + + return rc; } /* @@ -274,6 +287,7 @@ static void show_statement(ivl_statement_t net) int draw_process(ivl_process_t net, void*x) { + int rc = 0; ivl_scope_t scope = ivl_process_scope(net); local_count = 0; @@ -284,7 +298,7 @@ int draw_process(ivl_process_t net, void*x) fprintf(vvp_out, "T_%05d\n", thread_count); /* Draw the contents of the thread. */ - show_statement(ivl_process_stmt(net)); + rc += show_statement(ivl_process_stmt(net)); /* Terminate the thread with either an %end instruction (initial @@ -307,11 +321,14 @@ int draw_process(ivl_process_t net, void*x) thread_count += 1; - return 0; + return rc; } /* * $Log: vvp_process.c,v $ + * Revision 1.8 2001/03/27 03:31:07 steve + * Support error code from target_t::end_design method. + * * Revision 1.7 2001/03/25 03:53:24 steve * Skip true clause if condition ix 0, x or z *