Detect recursive instantiations (PR#2)
This commit is contained in:
parent
44131d4b16
commit
8ae4e25720
|
|
@ -17,7 +17,7 @@
|
|||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
*/
|
||||
#if !defined(WINNT) && !defined(macintosh)
|
||||
#ident "$Id: design_dump.cc,v 1.107 2000/12/11 00:31:43 steve Exp $"
|
||||
#ident "$Id: design_dump.cc,v 1.108 2000/12/16 01:45:47 steve Exp $"
|
||||
#endif
|
||||
|
||||
/*
|
||||
|
|
@ -702,7 +702,7 @@ void NetScope::dump(ostream&o) const
|
|||
o << " function";
|
||||
break;
|
||||
case MODULE:
|
||||
o << " module";
|
||||
o << " module <" << (module_name_? module_name_ : "") << ">";
|
||||
break;
|
||||
case TASK:
|
||||
o << " task";
|
||||
|
|
@ -998,6 +998,9 @@ void Design::dump(ostream&o) const
|
|||
|
||||
/*
|
||||
* $Log: design_dump.cc,v $
|
||||
* Revision 1.108 2000/12/16 01:45:47 steve
|
||||
* Detect recursive instantiations (PR#2)
|
||||
*
|
||||
* Revision 1.107 2000/12/11 00:31:43 steve
|
||||
* Add support for signed reg variables,
|
||||
* simulate in t-vvm signed comparisons.
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@
|
|||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
*/
|
||||
#if !defined(WINNT) && !defined(macintosh)
|
||||
#ident "$Id: elab_scope.cc,v 1.6 2000/07/30 18:25:43 steve Exp $"
|
||||
#ident "$Id: elab_scope.cc,v 1.7 2000/12/16 01:45:48 steve Exp $"
|
||||
#endif
|
||||
|
||||
/*
|
||||
|
|
@ -208,8 +208,32 @@ void PGModule::elaborate_scope_mod_(Design*des, Module*mod, NetScope*sc) const
|
|||
return;
|
||||
}
|
||||
|
||||
// check for recursive instantiation by scanning the current
|
||||
// scope and its parents. Look for a module instantiation of
|
||||
// the same module, but farther up in the scope.
|
||||
|
||||
for (NetScope*scn = sc ; scn ; scn = scn->parent()) {
|
||||
if (scn->type() != NetScope::MODULE)
|
||||
continue;
|
||||
|
||||
if (mod->get_name() != scn->module_name())
|
||||
continue;
|
||||
|
||||
cerr << get_line() << ": error: You cannot instantiate "
|
||||
<< "module " << mod->get_name() << " within itself." << endl;
|
||||
|
||||
cerr << get_line() << ": : The offending instance is "
|
||||
<< sc->name() << "." << get_name() << " within "
|
||||
<< scn->name() << "." << endl;
|
||||
|
||||
des->errors += 1;
|
||||
return;
|
||||
}
|
||||
|
||||
// Create the new scope as a MODULE with my name.
|
||||
NetScope*my_scope = new NetScope(sc, get_name(), NetScope::MODULE);
|
||||
my_scope->set_module_name(mod->get_name().c_str());
|
||||
|
||||
// Set time units and precision.
|
||||
my_scope->time_unit(mod->time_unit);
|
||||
my_scope->time_precision(mod->time_precision);
|
||||
|
|
@ -420,6 +444,9 @@ void PWhile::elaborate_scope(Design*des, NetScope*scope) const
|
|||
|
||||
/*
|
||||
* $Log: elab_scope.cc,v $
|
||||
* Revision 1.7 2000/12/16 01:45:48 steve
|
||||
* Detect recursive instantiations (PR#2)
|
||||
*
|
||||
* Revision 1.6 2000/07/30 18:25:43 steve
|
||||
* Rearrange task and function elaboration so that the
|
||||
* NetTaskDef and NetFuncDef functions are created during
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@
|
|||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
*/
|
||||
#if !defined(WINNT) && !defined(macintosh)
|
||||
#ident "$Id: net_design.cc,v 1.16 2000/09/24 17:41:13 steve Exp $"
|
||||
#ident "$Id: net_design.cc,v 1.17 2000/12/16 01:45:48 steve Exp $"
|
||||
#endif
|
||||
|
||||
/*
|
||||
|
|
@ -90,7 +90,8 @@ unsigned long Design::scale_to_precision(unsigned long val,
|
|||
NetScope* Design::make_root_scope(const string&root)
|
||||
{
|
||||
assert(root_scope_ == 0);
|
||||
root_scope_ = new NetScope(root);
|
||||
root_scope_ = new NetScope(0, root, NetScope::MODULE);
|
||||
root_scope_->set_module_name(root.c_str());
|
||||
return root_scope_;
|
||||
}
|
||||
|
||||
|
|
@ -486,6 +487,9 @@ void Design::delete_process(NetProcTop*top)
|
|||
|
||||
/*
|
||||
* $Log: net_design.cc,v $
|
||||
* Revision 1.17 2000/12/16 01:45:48 steve
|
||||
* Detect recursive instantiations (PR#2)
|
||||
*
|
||||
* Revision 1.16 2000/09/24 17:41:13 steve
|
||||
* fix null pointer when elaborating undefined task.
|
||||
*
|
||||
|
|
|
|||
47
net_scope.cc
47
net_scope.cc
|
|
@ -17,7 +17,7 @@
|
|||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
*/
|
||||
#if !defined(WINNT) && !defined(macintosh)
|
||||
#ident "$Id: net_scope.cc,v 1.10 2000/10/06 23:46:50 steve Exp $"
|
||||
#ident "$Id: net_scope.cc,v 1.11 2000/12/16 01:45:48 steve Exp $"
|
||||
#endif
|
||||
|
||||
# include "netlist.h"
|
||||
|
|
@ -31,16 +31,6 @@
|
|||
* formed by appending the path of scopes from the root to the scope
|
||||
* in question.
|
||||
*/
|
||||
NetScope::NetScope(const string&n)
|
||||
: type_(NetScope::MODULE), up_(0), sib_(0), sub_(0)
|
||||
{
|
||||
memories_ = 0;
|
||||
signals_ = 0;
|
||||
events_ = 0;
|
||||
lcounter_ = 0;
|
||||
name_ = new char[n.length()+1];
|
||||
strcpy(name_, n.c_str());
|
||||
}
|
||||
|
||||
NetScope::NetScope(NetScope*up, const string&n, NetScope::TYPE t)
|
||||
: type_(t), up_(up), sib_(0), sub_(0)
|
||||
|
|
@ -48,10 +38,17 @@ NetScope::NetScope(NetScope*up, const string&n, NetScope::TYPE t)
|
|||
memories_ = 0;
|
||||
signals_ = 0;
|
||||
events_ = 0;
|
||||
time_unit_ = up->time_unit();
|
||||
time_prec_ = up->time_precision();
|
||||
sib_ = up_->sub_;
|
||||
up_->sub_ = this;
|
||||
|
||||
if (up) {
|
||||
time_unit_ = up->time_unit();
|
||||
time_prec_ = up->time_precision();
|
||||
sib_ = up_->sub_;
|
||||
up_->sub_ = this;
|
||||
} else {
|
||||
time_unit_ = 0;
|
||||
time_prec_ = 0;
|
||||
assert(t == MODULE);
|
||||
}
|
||||
|
||||
switch (t) {
|
||||
case NetScope::TASK:
|
||||
|
|
@ -60,6 +57,9 @@ NetScope::NetScope(NetScope*up, const string&n, NetScope::TYPE t)
|
|||
case NetScope::FUNC:
|
||||
func_ = 0;
|
||||
break;
|
||||
case NetScope::MODULE:
|
||||
module_name_ = 0;
|
||||
break;
|
||||
}
|
||||
name_ = new char[n.length()+1];
|
||||
strcpy(name_, n.c_str());
|
||||
|
|
@ -71,6 +71,8 @@ NetScope::~NetScope()
|
|||
assert(sub_ == 0);
|
||||
lcounter_ = 0;
|
||||
delete[]name_;
|
||||
if ((type_ == MODULE) && module_name_)
|
||||
free(module_name_);
|
||||
}
|
||||
|
||||
NetExpr* NetScope::set_parameter(const string&key, NetExpr*expr)
|
||||
|
|
@ -147,6 +149,18 @@ const NetFuncDef* NetScope::func_def() const
|
|||
return func_;
|
||||
}
|
||||
|
||||
void NetScope::set_module_name(const char*n)
|
||||
{
|
||||
assert(type_ == MODULE);
|
||||
module_name_ = strdup(n);
|
||||
}
|
||||
|
||||
const char* NetScope::module_name() const
|
||||
{
|
||||
assert(type_ == MODULE);
|
||||
return module_name_;
|
||||
}
|
||||
|
||||
void NetScope::time_unit(int val)
|
||||
{
|
||||
time_unit_ = val;
|
||||
|
|
@ -355,6 +369,9 @@ string NetScope::local_symbol()
|
|||
|
||||
/*
|
||||
* $Log: net_scope.cc,v $
|
||||
* Revision 1.11 2000/12/16 01:45:48 steve
|
||||
* Detect recursive instantiations (PR#2)
|
||||
*
|
||||
* Revision 1.10 2000/10/06 23:46:50 steve
|
||||
* ivl_target updates, including more complete
|
||||
* handling of ivl_nexus_t objects. Much reduced
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@
|
|||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||
*/
|
||||
#if !defined(WINNT) && !defined(macintosh)
|
||||
#ident "$Id: netlist.h,v 1.186 2000/12/11 00:31:43 steve Exp $"
|
||||
#ident "$Id: netlist.h,v 1.187 2000/12/16 01:45:48 steve Exp $"
|
||||
#endif
|
||||
|
||||
/*
|
||||
|
|
@ -2545,7 +2545,6 @@ class NetScope {
|
|||
|
||||
public:
|
||||
enum TYPE { MODULE, TASK, FUNC, BEGIN_END, FORK_JOIN };
|
||||
NetScope(const string&root);
|
||||
NetScope(NetScope*up, const string&name, TYPE t);
|
||||
~NetScope();
|
||||
|
||||
|
|
@ -2598,12 +2597,14 @@ class NetScope {
|
|||
|
||||
void set_task_def(NetTaskDef*);
|
||||
void set_func_def(NetFuncDef*);
|
||||
void set_module_name(const char*);
|
||||
|
||||
NetTaskDef* task_def();
|
||||
NetFuncDef* func_def();
|
||||
|
||||
const NetTaskDef* task_def() const;
|
||||
const NetFuncDef* func_def() const;
|
||||
const char*module_name() const;
|
||||
|
||||
/* Scopes have their own time units and time precision. The
|
||||
unit and precision are given as power of 10, i.e. -3 is
|
||||
|
|
@ -2663,6 +2664,7 @@ class NetScope {
|
|||
union {
|
||||
NetTaskDef*task_;
|
||||
NetFuncDef*func_;
|
||||
char*module_name_;
|
||||
};
|
||||
|
||||
NetScope*up_;
|
||||
|
|
@ -2835,6 +2837,9 @@ extern ostream& operator << (ostream&, NetNet::Type);
|
|||
|
||||
/*
|
||||
* $Log: netlist.h,v $
|
||||
* Revision 1.187 2000/12/16 01:45:48 steve
|
||||
* Detect recursive instantiations (PR#2)
|
||||
*
|
||||
* Revision 1.186 2000/12/11 00:31:43 steve
|
||||
* Add support for signed reg variables,
|
||||
* simulate in t-vvm signed comparisons.
|
||||
|
|
|
|||
Loading…
Reference in New Issue