Locate scopes in statements.

This commit is contained in:
steve 2000-03-11 03:25:51 +00:00
parent 61822d48aa
commit 78ab1a7bba
5 changed files with 184 additions and 21 deletions

View File

@ -19,7 +19,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#if !defined(WINNT) && !defined(macintosh)
#ident "$Id: Statement.h,v 1.21 2000/02/23 02:56:54 steve Exp $"
#ident "$Id: Statement.h,v 1.22 2000/03/11 03:25:51 steve Exp $"
#endif
# include <string>
@ -30,6 +30,8 @@
class PExpr;
class Statement;
class PEventStatement;
class Design;
class NetScope;
/*
* The PProcess is the root of a behavioral process. Each process gets
@ -70,6 +72,7 @@ class Statement : public LineInfo {
virtual void dump(ostream&out, unsigned ind) const;
virtual NetProc* elaborate(Design*des, const string&path) const;
virtual void elaborate_scope(Design*des, NetScope*scope) const;
};
/*
@ -155,6 +158,7 @@ class PBlock : public Statement {
virtual void dump(ostream&out, unsigned ind) const;
virtual NetProc* elaborate(Design*des, const string&path) const;
virtual void elaborate_scope(Design*des, NetScope*scope) const;
private:
string name_;
@ -204,6 +208,7 @@ class PCase : public Statement {
~PCase();
virtual NetProc* elaborate(Design*des, const string&path) const;
virtual void elaborate_scope(Design*des, NetScope*scope) const;
virtual void dump(ostream&out, unsigned ind) const;
private:
@ -225,6 +230,7 @@ class PCondit : public Statement {
~PCondit();
virtual NetProc* elaborate(Design*des, const string&path) const;
virtual void elaborate_scope(Design*des, NetScope*scope) const;
virtual void dump(ostream&out, unsigned ind) const;
private:
@ -245,6 +251,7 @@ class PDelayStatement : public Statement {
virtual void dump(ostream&out, unsigned ind) const;
virtual NetProc* elaborate(Design*des, const string&path) const;
virtual void elaborate_scope(Design*des, NetScope*scope) const;
private:
PExpr*delay_;
@ -265,6 +272,7 @@ class PEventStatement : public Statement {
virtual void dump(ostream&out, unsigned ind) const;
virtual NetProc* elaborate(Design*des, const string&path) const;
virtual void elaborate_scope(Design*des, NetScope*scope) const;
// This method is used to elaborate, but attach a previously
// elaborated statement to the event.
@ -281,6 +289,7 @@ class PForever : public Statement {
~PForever();
virtual NetProc* elaborate(Design*des, const string&path) const;
virtual void elaborate_scope(Design*des, NetScope*scope) const;
virtual void dump(ostream&out, unsigned ind) const;
private:
@ -297,6 +306,7 @@ class PForStatement : public Statement {
{ }
virtual NetProc* elaborate(Design*des, const string&path) const;
virtual void elaborate_scope(Design*des, NetScope*scope) const;
virtual void dump(ostream&out, unsigned ind) const;
private:
@ -323,6 +333,7 @@ class PRepeat : public Statement {
~PRepeat();
virtual NetProc* elaborate(Design*des, const string&path) const;
virtual void elaborate_scope(Design*des, NetScope*scope) const;
virtual void dump(ostream&out, unsigned ind) const;
private:
@ -338,6 +349,7 @@ class PWhile : public Statement {
~PWhile();
virtual NetProc* elaborate(Design*des, const string&path) const;
virtual void elaborate_scope(Design*des, NetScope*scope) const;
virtual void dump(ostream&out, unsigned ind) const;
private:
@ -347,6 +359,9 @@ class PWhile : public Statement {
/*
* $Log: Statement.h,v $
* Revision 1.22 2000/03/11 03:25:51 steve
* Locate scopes in statements.
*
* Revision 1.21 2000/02/23 02:56:54 steve
* Macintosh compilers do not support ident.
*

View File

@ -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.1 2000/03/08 04:36:53 steve Exp $"
#ident "$Id: elab_scope.cc,v 1.2 2000/03/11 03:25:52 steve Exp $"
#endif
/*
@ -31,7 +31,9 @@
# include "PExpr.h"
# include "PGate.h"
# include "PTask.h"
# include "Statement.h"
# include "netlist.h"
# include <typeinfo>
bool Module::elaborate_scope(Design*des, NetScope*scope) const
{
@ -136,10 +138,22 @@ bool Module::elaborate_scope(Design*des, NetScope*scope) const
for (gates_it_t cur = gates_.begin()
; cur != gates_.end() ; cur ++ ) {
(*cur)->elaborate_scope(des, scope);
(*cur) -> elaborate_scope(des, scope);
}
// initial and always blocks may contain begin-end and
// fork-join blocks that can introduce scopes. Therefore, I
// get to scan processes here.
typedef list<PProcess*>::const_iterator proc_it_t;
for (proc_it_t cur = behaviors_.begin()
; cur != behaviors_.end() ; cur ++ ) {
(*cur) -> statement() -> elaborate_scope(des, scope);
}
return des->errors == 0;
}
@ -163,7 +177,8 @@ void PGModule::elaborate_scope_mod_(Design*des, Module*mod, NetScope*sc) const
}
// Create the new scope as a MODULE with my name.
NetScope*my_scope = des->make_scope(path, NetScope::MODULE, get_name());
NetScope*my_scope = new NetScope(sc, get_name(), NetScope::MODULE);
// This call actually arranges for the description of the
// module type to process this instance and handle parameters
@ -229,8 +244,137 @@ void PTask::elaborate_scope(Design*des, NetScope*scope) const
}
/*
* The base statement does not have sub-statements and does not
* introduce any scope, so this is a no-op.
*/
void Statement::elaborate_scope(Design*, NetScope*) const
{
}
/*
* When I get a behavioral block, check to see if it has a name. If it
* does, then create a new scope for the statements within it,
* otherwise use the current scope. Use the selected scope to scan the
* statements that I contain.
*/
void PBlock::elaborate_scope(Design*des, NetScope*scope) const
{
NetScope*my_scope = scope;
if (name_ != "") {
my_scope = new NetScope(scope, name_, bl_type_==BL_PAR
? NetScope::FORK_JOIN
: NetScope::BEGIN_END);
}
for (unsigned idx = 0 ; idx < list_.count() ; idx += 1)
list_[idx] -> elaborate_scope(des, my_scope);
}
/*
* The case statement itseof does not introduce scope, but contains
* other statements that may be named blocks. So scan the case items
* with the elaborate_scope method.
*/
void PCase::elaborate_scope(Design*des, NetScope*scope) const
{
assert(items_);
for (unsigned idx = 0 ; idx < (*items_).count() ; idx += 1) {
assert( (*items_)[idx] );
if (Statement*sp = (*items_)[idx]->stat)
sp -> elaborate_scope(des, scope);
}
}
/*
* The conditional statement (if-else) does not introduce scope, but
* the statements of the clauses may, so elaborate_scope the contained
* statements.
*/
void PCondit::elaborate_scope(Design*des, NetScope*scope) const
{
if (if_)
if_ -> elaborate_scope(des, scope);
if (else_)
else_ -> elaborate_scope(des, scope);
}
/*
* Statements that contain a further statement but do not
* intrinsically add a scope need to elaborate_scope the contained
* statement.
*/
void PDelayStatement::elaborate_scope(Design*des, NetScope*scope) const
{
if (statement_)
statement_ -> elaborate_scope(des, scope);
}
/*
* Statements that contain a further statement but do not
* intrinsically add a scope need to elaborate_scope the contained
* statement.
*/
void PEventStatement::elaborate_scope(Design*des, NetScope*scope) const
{
if (statement_)
statement_ -> elaborate_scope(des, scope);
}
/*
* Statements that contain a further statement but do not
* intrinsically add a scope need to elaborate_scope the contained
* statement.
*/
void PForever::elaborate_scope(Design*des, NetScope*scope) const
{
if (statement_)
statement_ -> elaborate_scope(des, scope);
}
/*
* Statements that contain a further statement but do not
* intrinsically add a scope need to elaborate_scope the contained
* statement.
*/
void PForStatement::elaborate_scope(Design*des, NetScope*scope) const
{
if (statement_)
statement_ -> elaborate_scope(des, scope);
}
/*
* Statements that contain a further statement but do not
* intrinsically add a scope need to elaborate_scope the contained
* statement.
*/
void PRepeat::elaborate_scope(Design*des, NetScope*scope) const
{
if (statement_)
statement_ -> elaborate_scope(des, scope);
}
/*
* Statements that contain a further statement but do not
* intrinsically add a scope need to elaborate_scope the contained
* statement.
*/
void PWhile::elaborate_scope(Design*des, NetScope*scope) const
{
if (statement_)
statement_ -> elaborate_scope(des, scope);
}
/*
* $Log: elab_scope.cc,v $
* Revision 1.2 2000/03/11 03:25:52 steve
* Locate scopes in statements.
*
* Revision 1.1 2000/03/08 04:36:53 steve
* Redesign the implementation of scopes and parameters.
* I now generate the scopes and notice the parameters

View File

@ -17,7 +17,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#if !defined(WINNT) && !defined(macintosh)
#ident "$Id: elaborate.cc,v 1.147 2000/03/10 06:20:48 steve Exp $"
#ident "$Id: elaborate.cc,v 1.148 2000/03/11 03:25:52 steve Exp $"
#endif
/*
@ -1132,6 +1132,15 @@ NetProc* PBlock::elaborate(Design*des, const string&path) const
NetScope*nscope;
if (name_.length()) {
nscope = scope->child(name_);
if (nscope == 0) {
cerr << get_line() << ": internal error: "
"unable to find block scope " << scope->name()
<< "<" << name_ << ">" << endl;
des->errors += 1;
delete cur;
return 0;
}
assert(nscope);
npath = nscope->name();
@ -1953,6 +1962,9 @@ Design* elaborate(const map<string,Module*>&modules,
/*
* $Log: elaborate.cc,v $
* Revision 1.148 2000/03/11 03:25:52 steve
* Locate scopes in statements.
*
* Revision 1.147 2000/03/10 06:20:48 steve
* Handle defparam to partial hierarchical names.
*

View File

@ -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.2 2000/03/10 06:20:48 steve Exp $"
#ident "$Id: net_design.cc,v 1.3 2000/03/11 03:25:52 steve Exp $"
#endif
/*
@ -71,18 +71,6 @@ NetScope* Design::make_root_scope(const string&root)
return root_scope_;
}
NetScope* Design::make_scope(const string&path,
NetScope::TYPE t,
const string&name)
{
NetScope*up = find_scope(path);
assert(up);
NetScope*scope = new NetScope(up, name, t);
return scope;
}
/*
* This method locates a scope in the design, given its rooted
@ -551,6 +539,9 @@ NetNet* Design::find_signal(bool (*func)(const NetNet*))
/*
* $Log: net_design.cc,v $
* Revision 1.3 2000/03/11 03:25:52 steve
* Locate scopes in statements.
*
* Revision 1.2 2000/03/10 06:20:48 steve
* Handle defparam to partial hierarchical names.
*

View File

@ -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.112 2000/03/10 06:20:48 steve Exp $"
#ident "$Id: netlist.h,v 1.113 2000/03/11 03:25:52 steve Exp $"
#endif
/*
@ -2053,8 +2053,6 @@ class Design {
string get_flag(const string&key) const;
NetScope* make_root_scope(const string&name);
NetScope* make_scope(const string&path, NetScope::TYPE t,
const string&name);
/* look up a scope. If no starting scope is passed, then the
path name string is taken as an absolute scope
@ -2195,6 +2193,9 @@ extern ostream& operator << (ostream&, NetNet::Type);
/*
* $Log: netlist.h,v $
* Revision 1.113 2000/03/11 03:25:52 steve
* Locate scopes in statements.
*
* Revision 1.112 2000/03/10 06:20:48 steve
* Handle defparam to partial hierarchical names.
*