detect module ports not declared within the module.

This commit is contained in:
steve 2001-10-31 03:11:15 +00:00
parent 438605fad5
commit faa3a62259
5 changed files with 51 additions and 10 deletions

View File

@ -19,13 +19,14 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/ */
#if !defined(WINNT) && !defined(macintosh) #if !defined(WINNT) && !defined(macintosh)
#ident "$Id: Module.h,v 1.22 2001/10/20 05:21:51 steve Exp $" #ident "$Id: Module.h,v 1.23 2001/10/31 03:11:15 steve Exp $"
#endif #endif
# include <list> # include <list>
# include <map> # include <map>
# include "svector.h" # include "svector.h"
# include "named.h" # include "named.h"
# include "LineInfo.h"
# include <string> # include <string>
class PEvent; class PEvent;
class PExpr; class PExpr;
@ -44,7 +45,7 @@ class NetScope;
* therefore the handle for grasping the described circuit. * therefore the handle for grasping the described circuit.
*/ */
class Module { class Module : public LineInfo {
/* The module ports are in general a vector of port_t /* The module ports are in general a vector of port_t
objects. Each port has a name and an ordered list of objects. Each port has a name and an ordered list of
@ -143,6 +144,9 @@ class Module {
/* /*
* $Log: Module.h,v $ * $Log: Module.h,v $
* Revision 1.23 2001/10/31 03:11:15 steve
* detect module ports not declared within the module.
*
* Revision 1.22 2001/10/20 05:21:51 steve * Revision 1.22 2001/10/20 05:21:51 steve
* Scope/module names are char* instead of string. * Scope/module names are char* instead of string.
* *

View File

@ -17,7 +17,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/ */
#if !defined(WINNT) && !defined(macintosh) #if !defined(WINNT) && !defined(macintosh)
#ident "$Id: elab_sig.cc,v 1.14 2001/07/25 03:10:49 steve Exp $" #ident "$Id: elab_sig.cc,v 1.15 2001/10/31 03:11:15 steve Exp $"
#endif #endif
# include "config.h" # include "config.h"
@ -69,6 +69,27 @@ bool Module::elaborate_sig(Design*des, NetScope*scope) const
// start the signals list with them. // start the signals list with them.
const map<string,PWire*>&wl = get_wires(); const map<string,PWire*>&wl = get_wires();
// Scan all the ports of the module, and make sure that each
// is connected to wires that have port declarations.
for (unsigned idx = 0 ; idx < ports_.count() ; idx += 1) {
Module::port_t*pp = ports_[idx];
if (pp == 0)
continue;
map<string,PWire*>::const_iterator wt;
for (unsigned cc = 0 ; cc < pp->expr.count() ; cc += 1) {
wt = wl.find(pp->expr[cc]->name());
if (wt == wl.end()) {
cerr << get_line() << ": error: "
<< "Port " << pp->expr[cc]->name() << " ("
<< (idx+1) << ") of module " << name_
<< " is not declared within module." << endl;
des->errors += 1;
}
}
}
for (map<string,PWire*>::const_iterator wt = wl.begin() for (map<string,PWire*>::const_iterator wt = wl.begin()
; wt != wl.end() ; wt != wl.end()
; wt ++ ) { ; wt ++ ) {
@ -93,6 +114,7 @@ bool Module::elaborate_sig(Design*des, NetScope*scope) const
} }
} }
/* If the signal is an input and is also declared as a /* If the signal is an input and is also declared as a
reg, then report an error. */ reg, then report an error. */
@ -444,6 +466,9 @@ void PWire::elaborate_sig(Design*des, NetScope*scope) const
/* /*
* $Log: elab_sig.cc,v $ * $Log: elab_sig.cc,v $
* Revision 1.15 2001/10/31 03:11:15 steve
* detect module ports not declared within the module.
*
* Revision 1.14 2001/07/25 03:10:49 steve * Revision 1.14 2001/07/25 03:10:49 steve
* Create a config.h.in file to hold all the config * Create a config.h.in file to hold all the config
* junk, and support gcc 3.0. (Stephan Boettcher) * junk, and support gcc 3.0. (Stephan Boettcher)

View File

@ -19,7 +19,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/ */
#if !defined(WINNT) && !defined(macintosh) #if !defined(WINNT) && !defined(macintosh)
#ident "$Id: parse.y,v 1.132 2001/10/26 03:22:56 steve Exp $" #ident "$Id: parse.y,v 1.133 2001/10/31 03:11:15 steve Exp $"
#endif #endif
# include "config.h" # include "config.h"
@ -1154,7 +1154,7 @@ assign_list
module module
: module_start IDENTIFIER list_of_ports_opt ';' : module_start IDENTIFIER list_of_ports_opt ';'
{ pform_startmodule($2, $3); { pform_startmodule($2, $3, @1.text, @1.first_line);
} }
module_item_list module_item_list
K_endmodule K_endmodule
@ -1162,7 +1162,7 @@ module
delete $2; delete $2;
} }
| module_start IDENTIFIER list_of_ports_opt ';' | module_start IDENTIFIER list_of_ports_opt ';'
{ pform_startmodule($2, $3); { pform_startmodule($2, $3, @1.text, @1.first_line);
} }
K_endmodule K_endmodule
{ pform_endmodule($2); { pform_endmodule($2);

View File

@ -17,7 +17,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/ */
#if !defined(WINNT) && !defined(macintosh) #if !defined(WINNT) && !defined(macintosh)
#ident "$Id: pform.cc,v 1.82 2001/10/21 01:55:24 steve Exp $" #ident "$Id: pform.cc,v 1.83 2001/10/31 03:11:15 steve Exp $"
#endif #endif
# include "config.h" # include "config.h"
@ -109,7 +109,8 @@ static unsigned long evaluate_delay(PExpr*delay)
return pp->value().as_ulong(); return pp->value().as_ulong();
} }
void pform_startmodule(const char*name, svector<Module::port_t*>*ports) void pform_startmodule(const char*name, svector<Module::port_t*>*ports,
const char*file, unsigned lineno)
{ {
assert( pform_cur_module == 0 ); assert( pform_cur_module == 0 );
@ -124,6 +125,10 @@ void pform_startmodule(const char*name, svector<Module::port_t*>*ports)
pform_cur_module = new Module(name, ports); pform_cur_module = new Module(name, ports);
pform_cur_module->time_unit = pform_time_unit; pform_cur_module->time_unit = pform_time_unit;
pform_cur_module->time_precision = pform_time_prec; pform_cur_module->time_precision = pform_time_prec;
pform_cur_module->set_file(file);
pform_cur_module->set_lineno(lineno);
delete ports; delete ports;
} }
@ -1097,6 +1102,9 @@ int pform_parse(const char*path, FILE*file)
/* /*
* $Log: pform.cc,v $ * $Log: pform.cc,v $
* Revision 1.83 2001/10/31 03:11:15 steve
* detect module ports not declared within the module.
*
* Revision 1.82 2001/10/21 01:55:24 steve * Revision 1.82 2001/10/21 01:55:24 steve
* Error messages for missing UDP port declarations. * Error messages for missing UDP port declarations.
* *

View File

@ -19,7 +19,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/ */
#if !defined(WINNT) && !defined(macintosh) #if !defined(WINNT) && !defined(macintosh)
#ident "$Id: pform.h,v 1.49 2001/10/21 01:55:25 steve Exp $" #ident "$Id: pform.h,v 1.50 2001/10/31 03:11:15 steve Exp $"
#endif #endif
# include "netlist.h" # include "netlist.h"
@ -110,7 +110,8 @@ struct lgate {
* are to apply to the scope of that module. The endmodule causes the * are to apply to the scope of that module. The endmodule causes the
* pform to close up and finish the named module. * pform to close up and finish the named module.
*/ */
extern void pform_startmodule(const char*, svector<Module::port_t*>*); extern void pform_startmodule(const char*, svector<Module::port_t*>*,
const char*file, unsigned lineno);
extern void pform_endmodule(const char*); extern void pform_endmodule(const char*);
extern void pform_make_udp(const char*name, list<string>*parms, extern void pform_make_udp(const char*name, list<string>*parms,
@ -201,6 +202,9 @@ extern void pform_dump(ostream&out, Module*mod);
/* /*
* $Log: pform.h,v $ * $Log: pform.h,v $
* Revision 1.50 2001/10/31 03:11:15 steve
* detect module ports not declared within the module.
*
* Revision 1.49 2001/10/21 01:55:25 steve * Revision 1.49 2001/10/21 01:55:25 steve
* Error messages for missing UDP port declarations. * Error messages for missing UDP port declarations.
* *