diff --git a/Module.cc b/Module.cc index 65b599f454..c1d405df8b 100644 --- a/Module.cc +++ b/Module.cc @@ -17,7 +17,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ #ifdef HAVE_CVS_IDENT -#ident "$Id: Module.cc,v 1.19 2002/08/12 01:34:58 steve Exp $" +#ident "$Id: Module.cc,v 1.20 2003/03/06 04:37:12 steve Exp $" #endif # include "config.h" @@ -27,14 +27,14 @@ # include "PWire.h" # include -Module::Module(const char*name) -: name_(strdup(name)) +/* n is a permallocated string. */ +Module::Module(const char*n) +: name_(n) { } Module::~Module() { - free(name_); } void Module::add_gate(PGate*gate) @@ -139,6 +139,9 @@ const list& Module::get_behaviors() const /* * $Log: Module.cc,v $ + * Revision 1.20 2003/03/06 04:37:12 steve + * lex_strings.add module names earlier. + * * Revision 1.19 2002/08/12 01:34:58 steve * conditional ident string using autoconfig. * diff --git a/Module.h b/Module.h index ba2e6c544e..5d93eaf34a 100644 --- a/Module.h +++ b/Module.h @@ -19,7 +19,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ #ifdef HAVE_CVS_IDENT -#ident "$Id: Module.h,v 1.29 2003/02/27 06:45:11 steve Exp $" +#ident "$Id: Module.h,v 1.30 2003/03/06 04:37:12 steve Exp $" #endif # include @@ -61,6 +61,8 @@ class Module : public LineInfo { }; public: + /* The name passed here is the module name, not the instance + name. This make must be a permallocated string. */ explicit Module(const char*name); ~Module(); @@ -145,7 +147,7 @@ class Module : public LineInfo { bool elaborate_sig(Design*, NetScope*scope) const; private: - char* name_; + const char* name_; map wires_; list gates_; @@ -161,6 +163,9 @@ class Module : public LineInfo { /* * $Log: Module.h,v $ + * Revision 1.30 2003/03/06 04:37:12 steve + * lex_strings.add module names earlier. + * * Revision 1.29 2003/02/27 06:45:11 steve * specparams as far as pform. * @@ -176,97 +181,5 @@ class Module : public LineInfo { * * Revision 1.25 2002/05/19 23:37:28 steve * Parse port_declaration_lists from the 2001 Standard. - * - * Revision 1.24 2001/12/03 04:47:14 steve - * Parser and pform use hierarchical names as hname_t - * objects instead of encoded strings. - * - * 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 - * 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) - * - * Revision 1.20 2000/07/22 22:09:03 steve - * Parse and elaborate timescale to scopes. - * - * Revision 1.19 2000/05/16 04:05:15 steve - * Module ports are really special PEIdent - * expressions, because a name can be used - * many places in the port list. - * - * Revision 1.18 2000/05/02 16:27:38 steve - * Move signal elaboration to a seperate pass. - * - * Revision 1.17 2000/04/01 19:31:57 steve - * Named events as far as the pform. - * - * Revision 1.16 2000/03/12 17:09:40 steve - * Support localparam. - * - * Revision 1.15 2000/03/08 04:36:53 steve - * Redesign the implementation of scopes and parameters. - * I now generate the scopes and notice the parameters - * in a separate pass over the pform. Once the scopes - * are generated, I can process overrides and evalutate - * paremeters before elaboration begins. - * - * Revision 1.14 2000/02/23 02:56:53 steve - * Macintosh compilers do not support ident. - * - * Revision 1.13 2000/01/09 20:37:57 steve - * Careful with wires connected to multiple ports. - * - * Revision 1.12 2000/01/09 05:50:48 steve - * Support named parameter override lists. - * - * Revision 1.11 1999/12/11 05:45:41 steve - * Fix support for attaching attributes to primitive gates. - * - * Revision 1.10 1999/11/27 19:07:57 steve - * Support the creation of scopes. - * - * Revision 1.9 1999/08/23 16:48:39 steve - * Parameter overrides support from Peter Monta - * AND and XOR support wide expressions. - * - * Revision 1.8 1999/08/04 02:13:02 steve - * Elaborate module ports that are concatenations of - * module signals. - * - * Revision 1.7 1999/08/03 04:14:49 steve - * Parse into pform arbitrarily complex module - * port declarations. - * - * Revision 1.6 1999/07/31 19:14:47 steve - * Add functions up to elaboration (Ed Carter) - * - * Revision 1.5 1999/07/03 02:12:51 steve - * Elaborate user defined tasks. - * - * Revision 1.4 1999/06/15 03:44:53 steve - * Get rid of the STL vector template. - * - * Revision 1.3 1999/02/21 17:01:57 steve - * Add support for module parameters. - * - * Revision 1.2 1999/01/25 05:45:56 steve - * Add the LineInfo class to carry the source file - * location of things. PGate, Statement and PProcess. - * - * elaborate handles module parameter mismatches, - * missing or incorrect lvalues for procedural - * assignment, and errors are propogated to the - * top of the elaboration call tree. - * - * Attach line numbers to processes, gates and - * assignment statements. - * - * Revision 1.1 1998/11/03 23:28:52 steve - * Introduce verilog to CVS. - * */ #endif diff --git a/PGate.cc b/PGate.cc index 822a63c17f..dd380891b4 100644 --- a/PGate.cc +++ b/PGate.cc @@ -17,7 +17,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ #ifdef HAVE_CVS_IDENT -#ident "$Id: PGate.cc,v 1.14 2002/08/12 01:34:58 steve Exp $" +#ident "$Id: PGate.cc,v 1.15 2003/03/06 04:37:12 steve Exp $" #endif # include "config.h" @@ -146,7 +146,7 @@ PGModule::PGModule(const char*type, const string&name, svector*pins) : PGate(name, pins), overrides_(0), pins_(0), npins_(0), parms_(0), nparms_(0), msb_(0), lsb_(0) { - type_ = strdup(type); + type_ = type; } PGModule::PGModule(const char*type, const string&name, @@ -154,12 +154,11 @@ PGModule::PGModule(const char*type, const string&name, : PGate(name, 0), overrides_(0), pins_(pins), npins_(npins), parms_(0), nparms_(0), msb_(0), lsb_(0) { - type_ = strdup(type); + type_ = type; } PGModule::~PGModule() { - free(type_); } void PGModule::set_parameters(svector*o) @@ -192,6 +191,9 @@ const char* PGModule::get_type() /* * $Log: PGate.cc,v $ + * Revision 1.15 2003/03/06 04:37:12 steve + * lex_strings.add module names earlier. + * * Revision 1.14 2002/08/12 01:34:58 steve * conditional ident string using autoconfig. * diff --git a/PGate.h b/PGate.h index 5ca857a143..7970bd5ffd 100644 --- a/PGate.h +++ b/PGate.h @@ -19,7 +19,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ #ifdef HAVE_CVS_IDENT -#ident "$Id: PGate.h,v 1.24 2002/08/12 01:34:58 steve Exp $" +#ident "$Id: PGate.h,v 1.25 2003/03/06 04:37:12 steve Exp $" #endif # include "svector.h" @@ -171,6 +171,9 @@ class PGBuiltin : public PGate { class PGModule : public PGate { public: + // NOTE: The type parameter to all the constructors is assumed + // to have been permallocated. + // If the binding of ports is by position, this constructor // builds everything all at once. explicit PGModule(const char*type, const string&name, @@ -198,10 +201,12 @@ class PGModule : public PGate { virtual void elaborate_scope(Design*des, NetScope*sc) const; virtual bool elaborate_sig(Design*des, NetScope*scope) const; + // This returns the module name of this module. It is a + // permallocated string. const char* get_type(); private: - char* type_; + const char* type_; svector*overrides_; named*pins_; unsigned npins_; @@ -222,6 +227,9 @@ class PGModule : public PGate { /* * $Log: PGate.h,v $ + * Revision 1.25 2003/03/06 04:37:12 steve + * lex_strings.add module names earlier. + * * Revision 1.24 2002/08/12 01:34:58 steve * conditional ident string using autoconfig. * diff --git a/net_design.cc b/net_design.cc index 0450536489..c599e933a1 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 */ #ifdef HAVE_CVS_IDENT -#ident "$Id: net_design.cc,v 1.34 2003/02/01 23:37:34 steve Exp $" +#ident "$Id: net_design.cc,v 1.35 2003/03/06 04:37:12 steve Exp $" #endif # include "config.h" @@ -84,7 +84,9 @@ 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); + /* This relies on the fact that the basename return value is + permallocated. */ + root_scope_->set_module_name(root_scope_->basename()); root_scopes_.push_back(root_scope_); return root_scope_; } @@ -649,6 +651,9 @@ void Design::delete_process(NetProcTop*top) /* * $Log: net_design.cc,v $ + * Revision 1.35 2003/03/06 04:37:12 steve + * lex_strings.add module names earlier. + * * Revision 1.34 2003/02/01 23:37:34 steve * Allow parameter expressions to be type real. * diff --git a/net_scope.cc b/net_scope.cc index 4c126ce500..339a074f37 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 */ #ifdef HAVE_CVS_IDENT -#ident "$Id: net_scope.cc,v 1.26 2003/03/06 00:28:41 steve Exp $" +#ident "$Id: net_scope.cc,v 1.27 2003/03/06 04:37:12 steve Exp $" #endif # include "config.h" @@ -185,7 +185,7 @@ const NetFuncDef* NetScope::func_def() const void NetScope::set_module_name(const char*n) { assert(type_ == MODULE); - module_name_ = lex_strings.add(n); + module_name_ = n; /* NOTE: n mus have been permallocated. */ } const char* NetScope::module_name() const @@ -448,6 +448,9 @@ string NetScope::local_hsymbol() /* * $Log: net_scope.cc,v $ + * Revision 1.27 2003/03/06 04:37:12 steve + * lex_strings.add module names earlier. + * * Revision 1.26 2003/03/06 00:28:41 steve * All NetObj objects have lex_string base names. * diff --git a/pform.cc b/pform.cc index f7539e329b..f6c583fd21 100644 --- a/pform.cc +++ b/pform.cc @@ -17,7 +17,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ #ifdef HAVE_CVS_IDENT -#ident "$Id: pform.cc,v 1.110 2003/03/01 06:25:30 steve Exp $" +#ident "$Id: pform.cc,v 1.111 2003/03/06 04:37:12 steve Exp $" #endif # include "config.h" @@ -152,8 +152,8 @@ void pform_startmodule(const char*name, const char*file, unsigned lineno) { assert( pform_cur_module == 0 ); - - pform_cur_module = new Module(name); + const char*lex_name = lex_strings.add(name); + pform_cur_module = new Module(lex_name); pform_cur_module->time_unit = pform_time_unit; pform_cur_module->time_precision = pform_time_prec; @@ -717,6 +717,8 @@ void pform_make_modgates(const char*type, struct parmvalue_t*overrides, svector*gates) { + // Get a permallocated version of the type string. + type = lex_strings.add(type); for (unsigned idx = 0 ; idx < gates->count() ; idx += 1) { lgate cur = (*gates)[idx]; @@ -1412,6 +1414,9 @@ int pform_parse(const char*path, FILE*file) /* * $Log: pform.cc,v $ + * Revision 1.111 2003/03/06 04:37:12 steve + * lex_strings.add module names earlier. + * * Revision 1.110 2003/03/01 06:25:30 steve * Add the lex_strings string handler, and put * scope names and system task/function names