diff --git a/parse.y b/parse.y index 474b5bb74..46018766c 100644 --- a/parse.y +++ b/parse.y @@ -19,7 +19,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ #if !defined(WINNT) && !defined(macintosh) -#ident "$Id: parse.y,v 1.130 2001/10/14 02:03:51 steve Exp $" +#ident "$Id: parse.y,v 1.131 2001/10/21 01:55:24 steve Exp $" #endif # include "config.h" @@ -2567,7 +2567,8 @@ udp_primitive udp_init_opt udp_body K_endprimitive - { pform_make_udp($2, $4, $7, $9, $8); + { pform_make_udp($2, $4, $7, $9, $8, + @2.text, @2.first_line); delete[]$2; } ; diff --git a/pform.cc b/pform.cc index 620c81ace..073a62aec 100644 --- a/pform.cc +++ b/pform.cc @@ -17,7 +17,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ #if !defined(WINNT) && !defined(macintosh) -#ident "$Id: pform.cc,v 1.81 2001/10/21 00:42:48 steve Exp $" +#ident "$Id: pform.cc,v 1.82 2001/10/21 01:55:24 steve Exp $" #endif # include "config.h" @@ -188,8 +188,10 @@ PExpr* pform_select_mtm_expr(PExpr*min, PExpr*typ, PExpr*max) void pform_make_udp(const char*name, list*parms, svector*decl, list*table, - Statement*init_expr) + Statement*init_expr, + const char*file, unsigned lineno) { + unsigned local_errors = 0; assert(parms->size() > 0); /* Put the declarations into a map, so that I can check them @@ -220,28 +222,92 @@ void pform_make_udp(const char*name, list*parms, /* Put the parameters into a vector of wire descriptions. Look - in the map for the definitions of the name. */ + in the map for the definitions of the name. In this loop, + the parms list in the list of ports in the port list of the + UDP declaration, and the defs map maps that name to a + PWire* created by an input or output declaration. */ svector pins (parms->size()); + svector pin_names (parms->size()); { list::iterator cur; unsigned idx; for (cur = parms->begin(), idx = 0 ; cur != parms->end() ; idx++, cur++) { pins[idx] = defs[*cur]; + pin_names[idx] = *cur; } } /* Check that the output is an output and the inputs are inputs. I can also make sure that only the single output is - declared a register, if anything. */ + declared a register, if anything. The possible errors are: + + -- an input port (not the first) is missing an input + declaration. + + -- An input port is declared output. + + */ assert(pins.count() > 0); - assert(pins[0]); - assert(pins[0]->get_port_type() == NetNet::POUTPUT); + do { + if (pins[0] == 0) { + cerr << file<<":"<get_port_type() != NetNet::POUTPUT) { + cerr << file<<":"<get_port_type() == NetNet::PINPUT); + if (pins[idx] == 0) { + cerr << file<<":"<get_port_type() != NetNet::PINPUT) { + cerr << file<<":"<get_wire_type() != NetNet::REG); } + if (local_errors > 0) { + delete parms; + delete decl; + delete table; + delete init_expr; + return; + } /* Interpret and check the table entry strings, to make sure they correspond to the inputs, output and output type. Make @@ -319,6 +385,7 @@ void pform_make_udp(const char*name, list*parms, pform_primitives[name] = udp; } + /* Delete the excess tables and lists from the parser. */ delete parms; delete decl; @@ -1030,6 +1097,9 @@ int pform_parse(const char*path, FILE*file) /* * $Log: pform.cc,v $ + * Revision 1.82 2001/10/21 01:55:24 steve + * Error messages for missing UDP port declarations. + * * Revision 1.81 2001/10/21 00:42:48 steve * Module types in pform are char* instead of string. * diff --git a/pform.h b/pform.h index 17fc38b78..a4ab2d74d 100644 --- a/pform.h +++ b/pform.h @@ -19,7 +19,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ #if !defined(WINNT) && !defined(macintosh) -#ident "$Id: pform.h,v 1.48 2001/10/21 00:42:48 steve Exp $" +#ident "$Id: pform.h,v 1.49 2001/10/21 01:55:25 steve Exp $" #endif # include "netlist.h" @@ -115,7 +115,8 @@ extern void pform_endmodule(const char*); extern void pform_make_udp(const char*name, list*parms, svector*decl, list*table, - Statement*init); + Statement*init, + const char*file, unsigned lineno); /* * Enter/exit name scopes. @@ -200,6 +201,9 @@ extern void pform_dump(ostream&out, Module*mod); /* * $Log: pform.h,v $ + * Revision 1.49 2001/10/21 01:55:25 steve + * Error messages for missing UDP port declarations. + * * Revision 1.48 2001/10/21 00:42:48 steve * Module types in pform are char* instead of string. *