Move memories to the NetScope object.

This commit is contained in:
steve 2000-05-02 03:13:30 +00:00
parent 8d8f1e2401
commit 69612ceb73
9 changed files with 170 additions and 110 deletions

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: design_dump.cc,v 1.80 2000/05/02 00:58:11 steve Exp $" #ident "$Id: design_dump.cc,v 1.81 2000/05/02 03:13:30 steve Exp $"
#endif #endif
/* /*
@ -677,6 +677,15 @@ void NetScope::dump(ostream&o) const
} while (cur != signals_->sig_next_); } while (cur != signals_->sig_next_);
} }
// Dump the memories,
if (memories_) {
NetMemory*cur = memories_->snext_;
do {
cur->dump(o, 4);
cur = cur->snext_;
} while (cur != memories_->snext_);
}
/* Dump any sub-scopes. */ /* Dump any sub-scopes. */
for (NetScope*cur = sub_ ; cur ; cur = cur->sib_) for (NetScope*cur = sub_ ; cur ; cur = cur->sib_)
cur->dump(o); cur->dump(o);
@ -876,15 +885,6 @@ void Design::dump(ostream&o) const
o << "SCOPES:" << endl; o << "SCOPES:" << endl;
root_scope_->dump(o); root_scope_->dump(o);
o << "ELABORATED MEMORIES:" << endl;
{
map<string,NetMemory*>::const_iterator pp;
for (pp = memories_.begin()
; pp != memories_.end() ; pp ++) {
(*pp).second->dump(o, 0);
}
}
o << "ELABORATED FUNCTION DEFINITIONS:" << endl; o << "ELABORATED FUNCTION DEFINITIONS:" << endl;
{ {
map<string,NetFuncDef*>::const_iterator pp; map<string,NetFuncDef*>::const_iterator pp;
@ -924,6 +924,9 @@ void Design::dump(ostream&o) const
/* /*
* $Log: design_dump.cc,v $ * $Log: design_dump.cc,v $
* Revision 1.81 2000/05/02 03:13:30 steve
* Move memories to the NetScope object.
*
* Revision 1.80 2000/05/02 00:58:11 steve * Revision 1.80 2000/05/02 00:58:11 steve
* Move signal tables to the NetScope class. * Move signal tables to the NetScope class.
* *

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_expr.cc,v 1.22 2000/05/02 00:58:11 steve Exp $" #ident "$Id: elab_expr.cc,v 1.23 2000/05/02 03:13:30 steve Exp $"
#endif #endif
@ -164,6 +164,8 @@ NetExpr* PECallFunction::elaborate_expr(Design*des, NetScope*scope) const
} }
assert(def); assert(def);
NetScope*dscope = des->find_scope(def->name());
assert(dscope);
svector<NetExpr*> parms (parms_.count()); svector<NetExpr*> parms (parms_.count());
@ -183,7 +185,7 @@ NetExpr* PECallFunction::elaborate_expr(Design*des, NetScope*scope) const
of the function, that has the name of the function. The of the function, that has the name of the function. The
function code assigns to this signal to return a value. */ function code assigns to this signal to return a value. */
NetNet*res = des->find_signal(def->name(), name_); NetNet*res = des->find_signal(dscope, name_);
if (res == 0) { if (res == 0) {
cerr << get_line() << ": internal error: Unable to locate " cerr << get_line() << ": internal error: Unable to locate "
"function return value for " << name_ << " in " << "function return value for " << name_ << " in " <<
@ -260,7 +262,7 @@ NetExpr* PEIdent::elaborate_expr(Design*des, NetScope*scope) const
// If the identifier names a signal (a register or wire) // If the identifier names a signal (a register or wire)
// then create a NetESignal node to handle it. // then create a NetESignal node to handle it.
if (NetNet*net = des->find_signal(scope->name(), text_)) { if (NetNet*net = des->find_signal(scope, text_)) {
// If this is a part select of a signal, then make a new // If this is a part select of a signal, then make a new
// temporary signal that is connected to just the // temporary signal that is connected to just the
@ -346,7 +348,7 @@ NetExpr* PEIdent::elaborate_expr(Design*des, NetScope*scope) const
// If the identifier names a memory, then this is a // If the identifier names a memory, then this is a
// memory reference and I must generate a NetEMemory // memory reference and I must generate a NetEMemory
// object to handle it. // object to handle it.
if (NetMemory*mem = des->find_memory(scope->name(), text_)) { if (NetMemory*mem = des->find_memory(scope, text_)) {
if (msb_ == 0) { if (msb_ == 0) {
NetEMemory*node = new NetEMemory(mem); NetEMemory*node = new NetEMemory(mem);
node->set_line(*this); node->set_line(*this);
@ -454,6 +456,9 @@ NetEUnary* PEUnary::elaborate_expr(Design*des, NetScope*scope) const
/* /*
* $Log: elab_expr.cc,v $ * $Log: elab_expr.cc,v $
* Revision 1.23 2000/05/02 03:13:30 steve
* Move memories to the NetScope object.
*
* Revision 1.22 2000/05/02 00:58:11 steve * Revision 1.22 2000/05/02 00:58:11 steve
* Move signal tables to the NetScope class. * Move signal tables to the NetScope class.
* *

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_net.cc,v 1.31 2000/05/02 00:58:11 steve Exp $" #ident "$Id: elab_net.cc,v 1.32 2000/05/02 03:13:31 steve Exp $"
#endif #endif
# include "PExpr.h" # include "PExpr.h"
@ -886,12 +886,12 @@ NetNet* PEIdent::elaborate_net(Design*des, const string&path,
unsigned long decay) const unsigned long decay) const
{ {
NetScope*scope = des->find_scope(path); NetScope*scope = des->find_scope(path);
NetNet*sig = des->find_signal(path, text_); NetNet*sig = des->find_signal(scope, text_);
if (sig == 0) { if (sig == 0) {
/* If the identifier is a memory instead of a signal, /* If the identifier is a memory instead of a signal,
then handle it elsewhere. Create a RAM. */ then handle it elsewhere. Create a RAM. */
if (NetMemory*mem = des->find_memory(path, text_)) if (NetMemory*mem = des->find_memory(scope, text_))
return elaborate_net_ram_(des, path, mem, lwidth, return elaborate_net_ram_(des, path, mem, lwidth,
rise, fall, decay); rise, fall, decay);
@ -1045,10 +1045,10 @@ NetNet* PEIdent::elaborate_lnet(Design*des, const string&path) const
NetScope*scope = des->find_scope(path); NetScope*scope = des->find_scope(path);
assert(scope); assert(scope);
NetNet*sig = des->find_signal(path, text_); NetNet*sig = des->find_signal(scope, text_);
if (sig == 0) { if (sig == 0) {
/* Don't allow memories here. Is it a memory? */ /* Don't allow memories here. Is it a memory? */
if (des->find_memory(path, text_)) { if (des->find_memory(scope, text_)) {
cerr << get_line() << ": error: memories (" << text_ cerr << get_line() << ": error: memories (" << text_
<< ") cannot be l-values in continuous " << ") cannot be l-values in continuous "
<< "assignments." << endl; << "assignments." << endl;
@ -1410,6 +1410,9 @@ NetNet* PEUnary::elaborate_net(Design*des, const string&path,
/* /*
* $Log: elab_net.cc,v $ * $Log: elab_net.cc,v $
* Revision 1.32 2000/05/02 03:13:31 steve
* Move memories to the NetScope object.
*
* Revision 1.31 2000/05/02 00:58:11 steve * Revision 1.31 2000/05/02 00:58:11 steve
* Move signal tables to the NetScope class. * Move signal tables to the NetScope class.
* *

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: elaborate.cc,v 1.166 2000/05/02 00:58:11 steve Exp $" #ident "$Id: elaborate.cc,v 1.167 2000/05/02 03:13:31 steve Exp $"
#endif #endif
/* /*
@ -146,9 +146,9 @@ void PWire::elaborate(Design*des, NetScope*scope) const
long rnum = rval->as_long(); long rnum = rval->as_long();
delete lval; delete lval;
delete rval; delete rval;
NetMemory*sig = new NetMemory(path+"."+basename, wid, lnum, rnum); NetMemory*sig = new NetMemory(scope, path+"."+basename,
wid, lnum, rnum);
sig->set_attributes(attributes); sig->set_attributes(attributes);
des->add_memory(sig);
} else { } else {
@ -409,7 +409,6 @@ void PGModule::elaborate_mod_(Design*des, Module*rmod, const string&path) const
// already, so just look it up as a child of the current scope. // already, so just look it up as a child of the current scope.
NetScope*my_scope = scope->child(get_name()); NetScope*my_scope = scope->child(get_name());
assert(my_scope); assert(my_scope);
const string my_name = my_scope -> name();
const svector<PExpr*>*pins; const svector<PExpr*>*pins;
@ -499,7 +498,7 @@ void PGModule::elaborate_mod_(Design*des, Module*rmod, const string&path) const
unsigned prts_pin_count = 0; unsigned prts_pin_count = 0;
for (unsigned ldx = 0 ; ldx < mport.count() ; ldx += 1) { for (unsigned ldx = 0 ; ldx < mport.count() ; ldx += 1) {
PWire*pport = mport[ldx]; PWire*pport = mport[ldx];
prts[ldx] = des->find_signal(my_name, pport->name()); prts[ldx] = des->find_signal(my_scope, pport->name());
assert(prts[ldx]); assert(prts[ldx]);
prts_pin_count += prts[ldx]->pin_count(); prts_pin_count += prts[ldx]->pin_count();
} }
@ -815,7 +814,7 @@ NetNet* PAssign_::elaborate_lval(Design*des, const string&path,
/* Get the signal referenced by the identifier, and make sure /* Get the signal referenced by the identifier, and make sure
it is a register. (Wires are not allows in this context. */ it is a register. (Wires are not allows in this context. */
NetNet*reg = des->find_signal(path, id->name()); NetNet*reg = des->find_signal(scope, id->name());
if (reg == 0) { if (reg == 0) {
cerr << get_line() << ": error: Could not match signal ``" << cerr << get_line() << ": error: Could not match signal ``" <<
@ -907,11 +906,11 @@ NetProc* PAssign::elaborate(Design*des, const string&path) const
const PEIdent*id = dynamic_cast<const PEIdent*>(lval()); const PEIdent*id = dynamic_cast<const PEIdent*>(lval());
if (id == 0) break; if (id == 0) break;
NetNet*net = des->find_signal(path, id->name()); NetNet*net = des->find_signal(scope, id->name());
if (net && (net->scope() == scope)) if (net && (net->scope() == scope))
break; break;
if (NetMemory*mem = des->find_memory(path, id->name())) if (NetMemory*mem = des->find_memory(scope, id->name()))
return assign_to_memory_(mem, id->msb_, des, path); return assign_to_memory_(mem, id->msb_, des, path);
} while(0); } while(0);
@ -1123,7 +1122,7 @@ NetProc* PAssignNB::elaborate(Design*des, const string&path) const
const PEIdent*id = dynamic_cast<const PEIdent*>(lval()); const PEIdent*id = dynamic_cast<const PEIdent*>(lval());
if (id == 0) break; if (id == 0) break;
if (NetMemory*mem = des->find_memory(path, id->name())) if (NetMemory*mem = des->find_memory(scope, id->name()))
return assign_to_memory_(mem, id->msb_, des, path); return assign_to_memory_(mem, id->msb_, des, path);
} while(0); } while(0);
@ -1933,7 +1932,7 @@ NetProc* PForStatement::elaborate(Design*des, const string&path) const
/* make the expression, and later the initial assignment to /* make the expression, and later the initial assignment to
the condition variable. The statement in the for loop is the condition variable. The statement in the for loop is
very specifically an assignment. */ very specifically an assignment. */
NetNet*sig = des->find_signal(path, id1->name()); NetNet*sig = des->find_signal(scope, id1->name());
if (sig == 0) { if (sig == 0) {
cerr << id1->get_line() << ": register ``" << id1->name() cerr << id1->get_line() << ": register ``" << id1->name()
<< "'' unknown in this context." << endl; << "'' unknown in this context." << endl;
@ -1962,7 +1961,7 @@ NetProc* PForStatement::elaborate(Design*des, const string&path) const
/* Elaborate the increment assignment statement at the end of /* Elaborate the increment assignment statement at the end of
the for loop. This is also a very specific assignment the for loop. This is also a very specific assignment
statement. Put this into the "body" block. */ statement. Put this into the "body" block. */
sig = des->find_signal(path, id2->name()); sig = des->find_signal(scope, id2->name());
assert(sig); assert(sig);
NetAssign*step = new NetAssign("@for-assign", des, sig->pin_count(), NetAssign*step = new NetAssign("@for-assign", des, sig->pin_count(),
expr2_->elaborate_expr(des, scope)); expr2_->elaborate_expr(des, scope));
@ -2431,6 +2430,9 @@ Design* elaborate(const map<string,Module*>&modules,
/* /*
* $Log: elaborate.cc,v $ * $Log: elaborate.cc,v $
* Revision 1.167 2000/05/02 03:13:31 steve
* Move memories to the NetScope object.
*
* Revision 1.166 2000/05/02 00:58:11 steve * Revision 1.166 2000/05/02 00:58:11 steve
* Move signal tables to the NetScope class. * Move signal tables to the NetScope class.
* *

32
emit.cc
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: emit.cc,v 1.42 2000/05/02 00:58:12 steve Exp $" #ident "$Id: emit.cc,v 1.43 2000/05/02 03:13:31 steve Exp $"
#endif #endif
/* /*
@ -297,6 +297,14 @@ void NetScope::emit_scope(ostream&o, struct target_t*tgt) const
cur = cur->sig_next_; cur = cur->sig_next_;
} while (cur != signals_->sig_next_); } while (cur != signals_->sig_next_);
} }
if (memories_) {
NetMemory*cur = memories_->snext_;
do {
tgt->memory(o, cur);
cur = cur->snext_;
} while (cur != memories_->snext_);
}
} }
void NetWhile::emit_proc_recurse(ostream&o, struct target_t*tgt) const void NetWhile::emit_proc_recurse(ostream&o, struct target_t*tgt) const
@ -312,25 +320,6 @@ bool Design::emit(ostream&o, struct target_t*tgt) const
// enumerate the scopes // enumerate the scopes
root_scope_->emit_scope(o, tgt); root_scope_->emit_scope(o, tgt);
#if 0
// emit signals
if (signals_) {
NetNet*cur = signals_->sig_next_;
do {
tgt->signal(o, cur);
cur = cur->sig_next_;
} while (cur != signals_->sig_next_);
}
#endif
// emit memories
{
map<string,NetMemory*>::const_iterator mi;
for (mi = memories_.begin() ; mi != memories_.end() ; mi++) {
tgt->memory(o, (*mi).second);
}
}
// emit nodes // emit nodes
if (nodes_) { if (nodes_) {
@ -440,6 +429,9 @@ bool emit(ostream&o, const Design*des, const char*type)
/* /*
* $Log: emit.cc,v $ * $Log: emit.cc,v $
* Revision 1.43 2000/05/02 03:13:31 steve
* Move memories to the NetScope object.
*
* Revision 1.42 2000/05/02 00:58:12 steve * Revision 1.42 2000/05/02 00:58:12 steve
* Move signal tables to the NetScope class. * Move signal tables to the NetScope class.
* *

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: net_design.cc,v 1.6 2000/05/02 00:58:12 steve Exp $" #ident "$Id: net_design.cc,v 1.7 2000/05/02 03:13:31 steve Exp $"
#endif #endif
/* /*
@ -269,49 +269,27 @@ string Design::get_flag(const string&key) const
* This method looks for a string given a current context as a * This method looks for a string given a current context as a
* starting point. * starting point.
*/ */
NetNet* Design::find_signal(const string&path, const string&name) NetNet* Design::find_signal(NetScope*scope, const string&name)
{ {
NetScope*scope = find_scope(path);
if (scope == 0) {
cerr << "internal error: invalid scope: " << path << endl;
return 0;
}
assert(scope); assert(scope);
while (scope) { while (scope) {
if (NetNet*net = scope->find_signal(name)) if (NetNet*net = scope->find_signal(name))
return net; return net;
scope = scope->parent(); scope = scope->parent();
} }
return 0; return 0;
} }
void Design::add_memory(NetMemory*mem) NetMemory* Design::find_memory(NetScope*scope, const string&name)
{ {
memories_[mem->name()] = mem; assert(scope);
} while (scope) {
if (NetMemory*mem = scope->find_memory(name))
NetMemory* Design::find_memory(const string&path, const string&name) return mem;
{ scope = scope->parent();
string root = path;
for (;;) {
string fulname = root + "." + name;
map<string,NetMemory*>::const_iterator cur
= memories_.find(fulname);
if (cur != memories_.end())
return (*cur).second;
unsigned pos = root.rfind('.');
if (pos > root.length())
break;
root = root.substr(0, pos);
} }
return 0; return 0;
} }
@ -321,29 +299,20 @@ void Design::find_symbol(NetScope*scope, const string&key,
sig = 0; sig = 0;
mem = 0; mem = 0;
for (;;) { while (scope) {
/* Form the full heirarchical name for lookups. */ /* Form the full heirarchical name for lookups. */
string fulname = scope? (scope->name() + "." + key) : key; string fulname = scope->name() + "." + key;
if (scope) if (NetNet*cur = scope->find_signal(fulname)) {
if (NetNet*cur = scope->find_signal(fulname)) { sig = cur;
sig = cur;
return;
}
/* Is this a memory? If so, we are again done. */
map<string,NetMemory*>::const_iterator cur
= memories_.find(fulname);
if (cur != memories_.end()) {
mem = (*cur).second;
return; return;
} }
/* Neither a signal nor memory are found, so go up a if (NetMemory*cur = scope->find_memory(fulname)) {
scope level and try again. */ mem = cur;
if (scope == 0)
return; return;
}
scope = scope->parent(); scope = scope->parent();
} }
@ -504,6 +473,9 @@ NetNode* Design::find_node(bool (*func)(const NetNode*))
/* /*
* $Log: net_design.cc,v $ * $Log: net_design.cc,v $
* Revision 1.7 2000/05/02 03:13:31 steve
* Move memories to the NetScope object.
*
* Revision 1.6 2000/05/02 00:58:12 steve * Revision 1.6 2000/05/02 00:58:12 steve
* Move signal tables to the NetScope class. * Move signal tables to the NetScope class.
* *

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: net_scope.cc,v 1.5 2000/05/02 00:58:12 steve Exp $" #ident "$Id: net_scope.cc,v 1.6 2000/05/02 03:13:31 steve Exp $"
#endif #endif
# include "netlist.h" # include "netlist.h"
@ -34,6 +34,7 @@
NetScope::NetScope(const string&n) NetScope::NetScope(const string&n)
: type_(NetScope::MODULE), name_(n), up_(0), sib_(0), sub_(0) : type_(NetScope::MODULE), name_(n), up_(0), sib_(0), sub_(0)
{ {
memories_ = 0;
signals_ = 0; signals_ = 0;
events_ = 0; events_ = 0;
lcounter_ = 0; lcounter_ = 0;
@ -42,6 +43,7 @@ NetScope::NetScope(const string&n)
NetScope::NetScope(NetScope*up, const string&n, NetScope::TYPE t) NetScope::NetScope(NetScope*up, const string&n, NetScope::TYPE t)
: type_(t), name_(n), up_(up), sib_(0), sub_(0) : type_(t), name_(n), up_(up), sib_(0), sub_(0)
{ {
memories_ = 0;
signals_ = 0; signals_ = 0;
events_ = 0; events_ = 0;
sib_ = up_->sub_; sib_ = up_->sub_;
@ -184,6 +186,51 @@ NetNet* NetScope::find_signal(const string&key)
return 0; return 0;
} }
void NetScope::add_memory(NetMemory*mem)
{
if (memories_ == 0) {
mem->snext_ = mem;
mem->sprev_ = mem;
} else {
mem->snext_ = memories_->snext_;
mem->sprev_ = memories_;
mem->snext_->sprev_ = mem;
mem->sprev_->snext_ = mem;
}
memories_ = mem;
mem->scope_ = this;
}
void NetScope::rem_memory(NetMemory*mem)
{
assert(mem->scope_ == this);
if (memories_ == mem)
memories_ = mem->sprev_;
if (memories_ == mem) {
memories_ = 0;
} else {
mem->sprev_->snext_ = mem->snext_;
mem->snext_->sprev_ = mem->sprev_;
}
mem->scope_ = 0;
}
NetMemory* NetScope::find_memory(const string&key)
{
if (memories_ == 0)
return 0;
string fulname = name()+"."+key;
NetMemory*cur = memories_;
do {
if (cur->name() == fulname)
return cur;
cur = cur->sprev_;
} while (cur != memories_);
return 0;
}
/* /*
* This method locates a child scope by name. The name is the simple * This method locates a child scope by name. The name is the simple
* name of the child, no heirarchy is searched. * name of the child, no heirarchy is searched.
@ -234,6 +281,9 @@ string NetScope::local_symbol()
/* /*
* $Log: net_scope.cc,v $ * $Log: net_scope.cc,v $
* Revision 1.6 2000/05/02 03:13:31 steve
* Move memories to the NetScope object.
*
* Revision 1.5 2000/05/02 00:58:12 steve * Revision 1.5 2000/05/02 00:58:12 steve
* Move signal tables to the NetScope class. * Move signal tables to the NetScope class.
* *

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: netlist.cc,v 1.120 2000/05/02 00:58:12 steve Exp $" #ident "$Id: netlist.cc,v 1.121 2000/05/02 03:13:31 steve Exp $"
#endif #endif
# include <cassert> # include <cassert>
@ -2124,9 +2124,16 @@ NetEMemory::~NetEMemory()
{ {
} }
NetMemory::NetMemory(const string&n, long w, long s, long e) NetMemory::NetMemory(NetScope*sc, const string&n, long w, long s, long e)
: name_(n), width_(w), idxh_(s), idxl_(e), ram_list_(0) : name_(n), width_(w), idxh_(s), idxl_(e), ram_list_(0), scope_(sc)
{ {
scope_->add_memory(this);
}
NetMemory::~NetMemory()
{
assert(scope_);
scope_->rem_memory(this);
} }
unsigned NetMemory::count() const unsigned NetMemory::count() const
@ -2545,6 +2552,9 @@ bool NetUDP::sequ_glob_(string input, char output)
/* /*
* $Log: netlist.cc,v $ * $Log: netlist.cc,v $
* Revision 1.121 2000/05/02 03:13:31 steve
* Move memories to the NetScope object.
*
* Revision 1.120 2000/05/02 00:58:12 steve * Revision 1.120 2000/05/02 00:58:12 steve
* Move signal tables to the NetScope class. * Move signal tables to the NetScope class.
* *

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: netlist.h,v 1.133 2000/05/02 00:58:12 steve Exp $" #ident "$Id: netlist.h,v 1.134 2000/05/02 03:13:31 steve Exp $"
#endif #endif
/* /*
@ -495,13 +495,17 @@ class NetFF : public NetNode {
class NetMemory { class NetMemory {
public: public:
NetMemory(const string&n, long w, long s, long e); NetMemory(NetScope*sc, const string&n, long w, long s, long e);
~NetMemory();
const string&name() const { return name_; } const string&name() const { return name_; }
// This is the width (in bits) of a single memory position. // This is the width (in bits) of a single memory position.
unsigned width() const { return width_; } unsigned width() const { return width_; }
NetScope*scope();
const NetScope*scope() const;
// This is the number of memory positions. // This is the number of memory positions.
unsigned count() const; unsigned count() const;
@ -524,6 +528,14 @@ class NetMemory {
friend class NetRamDq; friend class NetRamDq;
NetRamDq* ram_list_; NetRamDq* ram_list_;
friend class NetScope;
NetMemory*snext_, *sprev_;
NetScope*scope_;
private: // not implemented
NetMemory(const NetMemory&);
NetMemory& operator= (const NetMemory&);
}; };
/* /*
@ -2267,6 +2279,16 @@ class NetScope {
NetNet* find_signal(const string&name); NetNet* find_signal(const string&name);
/* ... and these methods manage memory the same way as signals
are managed above. */
void add_memory(NetMemory*);
void rem_memory(NetMemory*);
NetMemory* find_memory(const string&name);
/* The parent and child() methods allow users of NetScope /* The parent and child() methods allow users of NetScope
objects to locate nearby scopes. */ objects to locate nearby scopes. */
NetScope* parent(); NetScope* parent();
@ -2310,8 +2332,9 @@ class NetScope {
map<string,NetExpr*>parameters_; map<string,NetExpr*>parameters_;
map<string,NetExpr*>localparams_; map<string,NetExpr*>localparams_;
NetEvent*events_; NetEvent *events_;
NetNet *signals_; NetNet *signals_;
NetMemory*memories_;
NetScope*up_; NetScope*up_;
NetScope*sib_; NetScope*sib_;
@ -2367,11 +2390,10 @@ class Design {
this method, unlike the NetScope::find_signal method, this method, unlike the NetScope::find_signal method,
handles global name binding. */ handles global name binding. */
NetNet*find_signal(const string&path, const string&name); NetNet*find_signal(NetScope*scope, const string&name);
// Memories // Memories
void add_memory(NetMemory*); NetMemory* find_memory(NetScope*scope, const string&name);
NetMemory* find_memory(const string&path, const string&name);
/* This is a more general lookup that finds the named signal /* This is a more general lookup that finds the named signal
or memory, whichever is first in the search path. */ or memory, whichever is first in the search path. */
@ -2416,8 +2438,6 @@ class Design {
// tree and per-hop searches for me. // tree and per-hop searches for me.
NetScope*root_scope_; NetScope*root_scope_;
map<string,NetMemory*> memories_;
// List the function definitions in the design. // List the function definitions in the design.
map<string,NetFuncDef*> funcs_; map<string,NetFuncDef*> funcs_;
@ -2485,6 +2505,9 @@ extern ostream& operator << (ostream&, NetNet::Type);
/* /*
* $Log: netlist.h,v $ * $Log: netlist.h,v $
* Revision 1.134 2000/05/02 03:13:31 steve
* Move memories to the NetScope object.
*
* Revision 1.133 2000/05/02 00:58:12 steve * Revision 1.133 2000/05/02 00:58:12 steve
* Move signal tables to the NetScope class. * Move signal tables to the NetScope class.
* *