diff --git a/Module.cc b/Module.cc index 72b617203..f7a214d7c 100644 --- a/Module.cc +++ b/Module.cc @@ -17,7 +17,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ #if !defined(WINNT) && !defined(macintosh) -#ident "$Id: Module.cc,v 1.15 2001/07/25 03:10:48 steve Exp $" +#ident "$Id: Module.cc,v 1.16 2001/10/20 05:21:51 steve Exp $" #endif # include "config.h" @@ -27,14 +27,19 @@ # include "PWire.h" # include -Module::Module(const string&name, const svector*pp) -: name_(name) +Module::Module(const char*name, const svector*pp) +: name_(strdup(name)) { if (pp) ports_ = *pp; } +Module::~Module() +{ + free(name_); +} + void Module::add_gate(PGate*gate) { gates_.push_back(gate); @@ -137,6 +142,9 @@ const list& Module::get_behaviors() const /* * $Log: Module.cc,v $ + * Revision 1.16 2001/10/20 05:21:51 steve + * Scope/module names are char* instead of string. + * * Revision 1.15 2001/07/25 03:10:48 steve * Create a config.h.in file to hold all the config * junk, and support gcc 3.0. (Stephan Boettcher) diff --git a/Module.h b/Module.h index 9497abd3f..cc8ef67e6 100644 --- a/Module.h +++ b/Module.h @@ -19,7 +19,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ #if !defined(WINNT) && !defined(macintosh) -#ident "$Id: Module.h,v 1.21 2000/11/05 06:05:59 steve Exp $" +#ident "$Id: Module.h,v 1.22 2001/10/20 05:21:51 steve Exp $" #endif # include @@ -58,7 +58,8 @@ class Module { }; public: - explicit Module(const string&name, const svector*); + explicit Module(const char*name, const svector*); + ~Module(); /* The module has parameters that are evaluated when the @@ -88,7 +89,7 @@ class Module { set by the `timescale directive. */ int time_unit, time_precision; - const string&get_name() const { return name_; } + const char*mod_name() const { return name_; } void add_gate(PGate*gate); @@ -122,7 +123,7 @@ class Module { bool elaborate_sig(Design*, NetScope*scope) const; private: - const string name_; + char* name_; /* This is an array of port descriptors, which is in turn a named array of PEident pointers. */ @@ -142,6 +143,9 @@ class Module { /* * $Log: Module.h,v $ + * Revision 1.22 2001/10/20 05:21:51 steve + * Scope/module names are char* instead of string. + * * Revision 1.21 2000/11/05 06:05:59 steve * Handle connectsion to internally unconnected modules (PR#38) * diff --git a/elab_scope.cc b/elab_scope.cc index d557849c2..61e0b68b3 100644 --- a/elab_scope.cc +++ b/elab_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: elab_scope.cc,v 1.10 2001/10/09 02:01:04 steve Exp $" +#ident "$Id: elab_scope.cc,v 1.11 2001/10/20 05:21:51 steve Exp $" #endif # include "config.h" @@ -134,7 +134,7 @@ bool Module::elaborate_scope(Design*des, NetScope*scope) const for (tasks_it_t cur = tasks_.begin() ; cur != tasks_.end() ; cur ++ ) { - NetScope*task_scope = new NetScope(scope, (*cur).first, + NetScope*task_scope = new NetScope(scope, (*cur).first.c_str(), NetScope::TASK); (*cur).second->elaborate_scope(des, task_scope); } @@ -149,7 +149,7 @@ bool Module::elaborate_scope(Design*des, NetScope*scope) const for (funcs_it_t cur = funcs_.begin() ; cur != funcs_.end() ; cur ++ ) { - NetScope*func_scope = new NetScope(scope, (*cur).first, + NetScope*func_scope = new NetScope(scope, (*cur).first.c_str(), NetScope::FUNC); (*cur).second->elaborate_scope(des, func_scope); } @@ -197,7 +197,7 @@ void PGModule::elaborate_scope_mod_(Design*des, Module*mod, NetScope*sc) const { if (get_name() == "") { cerr << get_line() << ": error: Instantiation of module " - << mod->get_name() << " requires an instance name." << endl; + << mod->mod_name() << " requires an instance name." << endl; des->errors += 1; return; } @@ -227,11 +227,11 @@ void PGModule::elaborate_scope_mod_(Design*des, Module*mod, NetScope*sc) const if (scn->type() != NetScope::MODULE) continue; - if (mod->get_name() != scn->module_name()) + if (strcmp(mod->mod_name(), scn->module_name()) != 0) continue; cerr << get_line() << ": error: You cannot instantiate " - << "module " << mod->get_name() << " within itself." << endl; + << "module " << mod->mod_name() << " within itself." << endl; cerr << get_line() << ": : The offending instance is " << sc->name() << "." << get_name() << " within " @@ -242,8 +242,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 = new NetScope(sc, get_name(), NetScope::MODULE); - my_scope->set_module_name(mod->get_name().c_str()); + NetScope*my_scope = new NetScope(sc, get_name().c_str(), NetScope::MODULE); + my_scope->set_module_name(mod->mod_name()); // Set time units and precision. my_scope->time_unit(mod->time_unit); @@ -349,7 +349,7 @@ 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 + my_scope = new NetScope(scope, name_.c_str(), bl_type_==BL_PAR ? NetScope::FORK_JOIN : NetScope::BEGIN_END); } @@ -458,6 +458,9 @@ void PWhile::elaborate_scope(Design*des, NetScope*scope) const /* * $Log: elab_scope.cc,v $ + * Revision 1.11 2001/10/20 05:21:51 steve + * Scope/module names are char* instead of string. + * * Revision 1.10 2001/10/09 02:01:04 steve * Tasks can have sub-scopes. * diff --git a/elaborate.cc b/elaborate.cc index 3e52b8e96..e72d9cc49 100644 --- a/elaborate.cc +++ b/elaborate.cc @@ -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.221 2001/10/19 21:53:24 steve Exp $" +#ident "$Id: elaborate.cc,v 1.222 2001/10/20 05:21:51 steve Exp $" #endif # include "config.h" @@ -2285,7 +2285,7 @@ struct root_elem { Design* elaborate(const map&modules, const map&primitives, - listroots) + listroots) { svector root_elems(roots.size()); bool rc = true; @@ -2298,7 +2298,7 @@ Design* elaborate(const map&modules, modlist = &modules; udplist = &primitives; - for (list::const_iterator root = roots.begin(); + for (list::const_iterator root = roots.begin(); root != roots.end(); root++) { // Look for the root module in the list. map::const_iterator mod = modules.find(*root); @@ -2372,6 +2372,9 @@ Design* elaborate(const map&modules, /* * $Log: elaborate.cc,v $ + * Revision 1.222 2001/10/20 05:21:51 steve + * Scope/module names are char* instead of string. + * * Revision 1.221 2001/10/19 21:53:24 steve * Support multiple root modules (Philip Blundell) * diff --git a/expr_synth.cc b/expr_synth.cc index 2978cfba8..827bb8311 100644 --- a/expr_synth.cc +++ b/expr_synth.cc @@ -17,7 +17,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ #if !defined(WINNT) && !defined(macintosh) -#ident "$Id: expr_synth.cc,v 1.26 2001/08/31 22:59:48 steve Exp $" +#ident "$Id: expr_synth.cc,v 1.27 2001/10/20 05:21:51 steve Exp $" #endif # include "config.h" @@ -353,27 +353,36 @@ NetNet* NetEBLogic::synthesize(Design*des) NetNet* NetEConcat::synthesize(Design*des) { - NetScope*scope = des->find_root_scope(); - assert(scope); - assert(repeat_ == 1); + /* First, synthesize the operands. */ + NetNet**tmp = new NetNet*[parms_.count()]; + for (unsigned idx = 0 ; idx < parms_.count() ; idx += 1) + tmp[idx] = parms_[idx]->synthesize(des); + assert(tmp[0]); + NetScope*scope = tmp[0]->scope(); + assert(scope); + + /* Make a NetNet object to carry the output vector. */ string path = scope->name() + "." + scope->local_symbol(); NetNet*osig = new NetNet(scope, path, NetNet::IMPLICIT, expr_width()); osig->local_flag(true); + /* Connect the output vector to the operands. */ unsigned obit = 0; for (unsigned idx = parms_.count() ; idx > 0 ; idx -= 1) { - NetNet*tmp = parms_[idx-1]->synthesize(des); - for (unsigned bit = 0 ; bit < tmp->pin_count() ; bit += 1) { - connect(osig->pin(obit), tmp->pin(bit)); + assert(tmp[idx-1]); + + for (unsigned bit = 0; bit < tmp[idx-1]->pin_count(); bit += 1) { + connect(osig->pin(obit), tmp[idx-1]->pin(bit)); obit += 1; } - if (tmp->local_flag() && tmp->get_eref() == 0) - delete tmp; + if (tmp[idx-1]->local_flag() && tmp[idx-1]->get_eref() == 0) + delete tmp[idx-1]; } + delete[]tmp; return osig; } @@ -553,6 +562,9 @@ NetNet* NetESignal::synthesize(Design*des) /* * $Log: expr_synth.cc,v $ + * Revision 1.27 2001/10/20 05:21:51 steve + * Scope/module names are char* instead of string. + * * Revision 1.26 2001/08/31 22:59:48 steve * synthesize the special case of compare with 0. * diff --git a/main.cc b/main.cc index 78c42d5d7..4ccd9e887 100644 --- a/main.cc +++ b/main.cc @@ -19,7 +19,7 @@ const char COPYRIGHT[] = * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ #if !defined(WINNT) && !defined(macintosh) -#ident "$Id: main.cc,v 1.48 2001/10/19 21:53:24 steve Exp $" +#ident "$Id: main.cc,v 1.49 2001/10/20 05:21:51 steve Exp $" #endif # include "config.h" @@ -102,7 +102,7 @@ static void parm_to_flagmap(const string&flag) extern Design* elaborate(const map&modules, const map&primitives, - list root); + list root); extern void cprop(Design*des); extern void synth(Design*des); @@ -175,7 +175,7 @@ int main(int argc, char*argv[]) int opt; unsigned flag_errors = 0; queue net_func_queue; - list roots; + list roots; struct tms cycles[5]; @@ -218,7 +218,7 @@ int main(int argc, char*argv[]) parm_to_flagmap(optarg); break; case 's': - roots.push_back(string(optarg)); + roots.push_back(optarg); break; case 'T': if (strcmp(optarg,"min") == 0) { @@ -359,10 +359,10 @@ int main(int argc, char*argv[]) } for (mod = modules.begin(); mod != modules.end(); mod++) { - if (mentioned_p[(*mod).second->get_name()] == false) { + if (mentioned_p[(*mod).second->mod_name()] == false) { if (verbose_flag) - cout << " " << (*mod).second->get_name(); - roots.push_back((*mod).second->get_name()); + cout << " " << (*mod).second->mod_name(); + roots.push_back((*mod).second->mod_name()); } } if (verbose_flag) @@ -455,6 +455,9 @@ int main(int argc, char*argv[]) /* * $Log: main.cc,v $ + * Revision 1.49 2001/10/20 05:21:51 steve + * Scope/module names are char* instead of string. + * * Revision 1.48 2001/10/19 21:53:24 steve * Support multiple root modules (Philip Blundell) * diff --git a/net_design.cc b/net_design.cc index 5c89c2f0c..d52100deb 100644 --- a/net_design.cc +++ b/net_design.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_design.cc,v 1.21 2001/10/19 21:53:24 steve Exp $" +#ident "$Id: net_design.cc,v 1.22 2001/10/20 05:21:51 steve Exp $" #endif # include "config.h" @@ -77,11 +77,11 @@ unsigned long Design::scale_to_precision(unsigned long val, return val; } -NetScope* Design::make_root_scope(const string&root) +NetScope* Design::make_root_scope(const char*root) { NetScope *root_scope_; root_scope_ = new NetScope(0, root, NetScope::MODULE); - root_scope_->set_module_name(root.c_str()); + root_scope_->set_module_name(root); root_scopes_.push_back(root_scope_); return root_scope_; } @@ -92,12 +92,6 @@ NetScope* Design::find_root_scope() return root_scopes_.front(); } -const NetScope* Design::find_root_scope() const -{ - assert(root_scopes_.front()); - return root_scopes_.front(); -} - list Design::find_root_scopes() { return root_scopes_; @@ -495,6 +489,9 @@ void Design::delete_process(NetProcTop*top) /* * $Log: net_design.cc,v $ + * Revision 1.22 2001/10/20 05:21:51 steve + * Scope/module names are char* instead of string. + * * Revision 1.21 2001/10/19 21:53:24 steve * Support multiple root modules (Philip Blundell) * diff --git a/net_scope.cc b/net_scope.cc index 0bcb7bdff..e53f8f092 100644 --- a/net_scope.cc +++ b/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.13 2001/07/25 03:10:49 steve Exp $" +#ident "$Id: net_scope.cc,v 1.14 2001/10/20 05:21:51 steve Exp $" #endif # include "config.h" @@ -34,7 +34,7 @@ * in question. */ -NetScope::NetScope(NetScope*up, const string&n, NetScope::TYPE t) +NetScope::NetScope(NetScope*up, const char*n, NetScope::TYPE t) : type_(t), up_(up), sib_(0), sub_(0) { memories_ = 0; @@ -63,8 +63,8 @@ NetScope::NetScope(NetScope*up, const string&n, NetScope::TYPE t) module_name_ = 0; break; } - name_ = new char[n.length()+1]; - strcpy(name_, n.c_str()); + name_ = new char[strlen(n)+1]; + strcpy(name_, n); } NetScope::~NetScope() @@ -371,6 +371,9 @@ string NetScope::local_symbol() /* * $Log: net_scope.cc,v $ + * Revision 1.14 2001/10/20 05:21:51 steve + * Scope/module names are char* instead of string. + * * Revision 1.13 2001/07/25 03:10:49 steve * Create a config.h.in file to hold all the config * junk, and support gcc 3.0. (Stephan Boettcher) diff --git a/netlist.h b/netlist.h index 89a339a71..ce19be589 100644 --- a/netlist.h +++ b/netlist.h @@ -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.217 2001/10/19 21:53:24 steve Exp $" +#ident "$Id: netlist.h,v 1.218 2001/10/20 05:21:51 steve Exp $" #endif /* @@ -2558,7 +2558,7 @@ class NetScope { public: enum TYPE { MODULE, TASK, FUNC, BEGIN_END, FORK_JOIN }; - NetScope(NetScope*up, const string&name, TYPE t); + NetScope(NetScope*up, const char*name, TYPE t); ~NetScope(); /* Parameters exist within a scope, and these methods allow @@ -2709,11 +2709,10 @@ class Design { string get_flag(const string&key) const; - NetScope* make_root_scope(const string&name); + NetScope* make_root_scope(const char*name); NetScope* find_root_scope(); list find_root_scopes(); - const NetScope* find_root_scope() const; const list find_root_scopes() const; /* Attempt to set the precision to the specified value. If the @@ -2851,6 +2850,9 @@ extern ostream& operator << (ostream&, NetNet::Type); /* * $Log: netlist.h,v $ + * Revision 1.218 2001/10/20 05:21:51 steve + * Scope/module names are char* instead of string. + * * Revision 1.217 2001/10/19 21:53:24 steve * Support multiple root modules (Philip Blundell) * diff --git a/pform.cc b/pform.cc index d58b417e1..93e84a753 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.78 2001/07/25 03:10:49 steve Exp $" +#ident "$Id: pform.cc,v 1.79 2001/10/20 05:21:51 steve Exp $" #endif # include "config.h" @@ -108,7 +108,7 @@ static unsigned long evaluate_delay(PExpr*delay) return pp->value().as_ulong(); } -void pform_startmodule(const string&name, svector*ports) +void pform_startmodule(const char*name, svector*ports) { assert( pform_cur_module == 0 ); @@ -126,10 +126,10 @@ void pform_startmodule(const string&name, svector*ports) delete ports; } -void pform_endmodule(const string&name) +void pform_endmodule(const char*name) { assert(pform_cur_module); - assert(name == pform_cur_module->get_name()); + assert(strcmp(name, pform_cur_module->mod_name()) == 0); vl_modules[name] = pform_cur_module; pform_cur_module = 0; } @@ -1019,6 +1019,9 @@ int pform_parse(const char*path, map&modules, /* * $Log: pform.cc,v $ + * Revision 1.79 2001/10/20 05:21:51 steve + * Scope/module names are char* instead of string. + * * Revision 1.78 2001/07/25 03:10:49 steve * Create a config.h.in file to hold all the config * junk, and support gcc 3.0. (Stephan Boettcher) diff --git a/pform.h b/pform.h index 4df816619..9bbff87fb 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.45 2000/12/11 00:31:43 steve Exp $" +#ident "$Id: pform.h,v 1.46 2001/10/20 05:21:51 steve Exp $" #endif # include "netlist.h" @@ -110,8 +110,8 @@ struct lgate { * are to apply to the scope of that module. The endmodule causes the * pform to close up and finish the named module. */ -extern void pform_startmodule(const string&, svector*); -extern void pform_endmodule(const string&); +extern void pform_startmodule(const char*, svector*); +extern void pform_endmodule(const char*); extern void pform_make_udp(const char*name, list*parms, svector*decl, list*table, @@ -202,6 +202,9 @@ extern void pform_dump(ostream&out, Module*mod); /* * $Log: pform.h,v $ + * Revision 1.46 2001/10/20 05:21:51 steve + * Scope/module names are char* instead of string. + * * Revision 1.45 2000/12/11 00:31:43 steve * Add support for signed reg variables, * simulate in t-vvm signed comparisons. diff --git a/xnfio.cc b/xnfio.cc index aeffd997a..ef15d4fa4 100644 --- a/xnfio.cc +++ b/xnfio.cc @@ -17,7 +17,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ #if !defined(WINNT) && !defined(macintosh) -#ident "$Id: xnfio.cc,v 1.18 2001/07/25 03:10:50 steve Exp $" +#ident "$Id: xnfio.cc,v 1.19 2001/10/20 05:21:51 steve Exp $" #endif # include "config.h" @@ -317,7 +317,7 @@ bool xnfio_f::compare_sideb_const(Design*des, NetCompare*dev) if (dev->width() > 4) return false; - NetScope*scope = des->find_root_scope(); + NetScope*scope = dev->scope(); verinum side (verinum::V0, dev->width()); @@ -367,6 +367,9 @@ void xnfio(Design*des) /* * $Log: xnfio.cc,v $ + * Revision 1.19 2001/10/20 05:21:51 steve + * Scope/module names are char* instead of string. + * * Revision 1.18 2001/07/25 03:10:50 steve * Create a config.h.in file to hold all the config * junk, and support gcc 3.0. (Stephan Boettcher)