Rework hname_t to use perm_strings.

This commit is contained in:
steve 2007-04-26 03:06:21 +00:00
parent 210e28e571
commit b981c81d37
12 changed files with 157 additions and 173 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
*/ */
#ifdef HAVE_CVS_IDENT #ifdef HAVE_CVS_IDENT
#ident "$Id: HName.cc,v 1.5 2002/11/02 03:27:52 steve Exp $" #ident "$Id: HName.cc,v 1.6 2007/04/26 03:06:21 steve Exp $"
#endif #endif
# include "config.h" # include "config.h"
@ -31,13 +31,12 @@
hname_t::hname_t() hname_t::hname_t()
{ {
item_ = 0;
count_ = 0; count_ = 0;
} }
hname_t::hname_t(const char*text) hname_t::hname_t(perm_string text)
{ {
item_ = strdup(text); new (item_) perm_string(text);
count_ = 1; count_ = 1;
} }
@ -46,15 +45,14 @@ hname_t::hname_t(const hname_t&that)
count_ = that.count_; count_ = that.count_;
switch (count_) { switch (count_) {
case 0: case 0:
item_ = 0;
break; break;
case 1: case 1:
item_ = strdup(that.item_); new(item_) perm_string (that.item_ref1_());
break; break;
default: default:
array_ = new char*[count_]; array_ = new perm_string[count_];
for (unsigned idx = 0 ; idx < count_ ; idx += 1) for (unsigned idx = 0 ; idx < count_ ; idx += 1)
array_[idx] = strdup(that.array_[idx]); array_[idx] = that.array_[idx];
break; break;
} }
} }
@ -65,11 +63,9 @@ hname_t::~hname_t()
case 0: case 0:
break; break;
case 1: case 1:
free(item_); item_ref1_().~perm_string();
break; break;
default: default:
for (unsigned idx = 0 ; idx < count_ ; idx += 1)
free(array_[idx]);
delete[]array_; delete[]array_;
break; break;
} }
@ -80,52 +76,54 @@ unsigned hname_t::component_count() const
return count_; return count_;
} }
void hname_t::append(const char*text) void hname_t::append(perm_string text)
{ {
char**tmp; perm_string*tmp;
switch (count_) { switch (count_) {
case 0: case 0:
count_ = 1; count_ = 1;
item_ = strdup(text); new (item_) perm_string(text);
break; break;
case 1: case 1:
count_ = 2; count_ = 2;
tmp = new char*[2]; tmp = new perm_string[2];
tmp[0] = item_; tmp[0] = item_ref1_();
tmp[1] = strdup(text); tmp[1] = text;
item_ref1_().~perm_string();
array_ = tmp; array_ = tmp;
break; break;
default: default:
tmp = new char*[count_+1]; tmp = new perm_string[count_+1];
for (unsigned idx = 0 ; idx < count_ ; idx += 1) for (unsigned idx = 0 ; idx < count_ ; idx += 1)
tmp[idx] = array_[idx]; tmp[idx] = array_[idx];
delete[]array_; delete[]array_;
array_ = tmp; array_ = tmp;
array_[count_] = strdup(text); array_[count_] = text;
count_ += 1; count_ += 1;
} }
} }
void hname_t::prepend(const char*text) void hname_t::prepend(perm_string text)
{ {
char**tmp; perm_string*tmp;
switch (count_) { switch (count_) {
case 0: case 0:
count_ = 1; count_ = 1;
item_ = strdup(text); new (item_) perm_string(text);
break; break;
case 1: case 1:
count_ = 2; count_ = 2;
tmp = new char*[2]; tmp = new perm_string[2];
tmp[0] = strdup(text); tmp[0] = text;
tmp[1] = item_; tmp[1] = item_ref1_();
item_ref1_().~perm_string();
array_ = tmp; array_ = tmp;
break; break;
default: default:
tmp = new char*[count_+1]; tmp = new perm_string[count_+1];
tmp[0] = strdup(text); tmp[0] = text;
for (unsigned idx = 0 ; idx < count_ ; idx += 1) for (unsigned idx = 0 ; idx < count_ ; idx += 1)
tmp[idx+1] = array_[idx]; tmp[idx+1] = array_[idx];
delete[]array_; delete[]array_;
@ -134,29 +132,29 @@ void hname_t::prepend(const char*text)
} }
} }
char* hname_t::remove_tail_name() perm_string hname_t::remove_tail_name()
{ {
if (count_ == 0) if (count_ == 0)
return 0; return perm_string();
if (count_ == 1) { if (count_ == 1) {
char*tmp = item_; perm_string tmp = item_ref1_();
count_ = 0; count_ = 0;
item_ = 0; item_ref1_().~perm_string();
return tmp; return tmp;
} }
if (count_ == 2) { if (count_ == 2) {
char*tmp1 = array_[0]; perm_string tmp1 = array_[0];
char*tmp2 = array_[1]; perm_string tmp2 = array_[1];
delete[]array_; delete[]array_;
count_ = 1; count_ = 1;
item_ = tmp1; new (item_) perm_string(tmp1);
return tmp2; return tmp2;
} }
char*tmpo = array_[count_-1]; perm_string tmpo = array_[count_-1];
char**tmpa = new char*[count_-1]; perm_string*tmpa = new perm_string[count_-1];
for (unsigned idx = 0 ; idx < count_-1 ; idx += 1) for (unsigned idx = 0 ; idx < count_-1 ; idx += 1)
tmpa[idx] = array_[idx]; tmpa[idx] = array_[idx];
@ -166,24 +164,24 @@ char* hname_t::remove_tail_name()
return tmpo; return tmpo;
} }
const char* hname_t::peek_name(unsigned idx) const perm_string hname_t::peek_name(unsigned idx) const
{ {
if (idx >= count_) if (idx >= count_)
return 0; return perm_string();
if (count_ == 1) if (count_ == 1)
return item_; return item_ref1_();
return array_[idx]; return array_[idx];
} }
const char* hname_t::peek_tail_name() const perm_string hname_t::peek_tail_name() const
{ {
switch (count_) { switch (count_) {
case 0: case 0:
return 0; return perm_string();
case 1: case 1:
return item_; return item_ref1_();
default: default:
return array_[count_-1]; return array_[count_-1];
} }
@ -258,6 +256,9 @@ ostream& operator<< (ostream&out, const hname_t&that)
/* /*
* $Log: HName.cc,v $ * $Log: HName.cc,v $
* Revision 1.6 2007/04/26 03:06:21 steve
* Rework hname_t to use perm_strings.
*
* Revision 1.5 2002/11/02 03:27:52 steve * Revision 1.5 2002/11/02 03:27:52 steve
* Allow named events to be referenced by * Allow named events to be referenced by
* hierarchical names. * hierarchical names.

25
HName.h
View File

@ -19,10 +19,11 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/ */
#ifdef HAVE_CVS_IDENT #ifdef HAVE_CVS_IDENT
#ident "$Id: HName.h,v 1.4 2002/11/02 03:27:51 steve Exp $" #ident "$Id: HName.h,v 1.5 2007/04/26 03:06:21 steve Exp $"
#endif #endif
# include <iostream> # include <iostream>
# include "StringHeap.h"
#ifdef __GNUC__ #ifdef __GNUC__
#if __GNUC__ > 2 #if __GNUC__ > 2
using namespace std; using namespace std;
@ -38,28 +39,28 @@ class hname_t {
public: public:
hname_t (); hname_t ();
explicit hname_t (const char*text); explicit hname_t (perm_string text);
hname_t (const hname_t&that); hname_t (const hname_t&that);
~hname_t(); ~hname_t();
// This method adds a name to the end of the hierarchical // This method adds a name to the end of the hierarchical
// path. This becomes a new base name. // path. This becomes a new base name.
void append(const char*text); void append(perm_string text);
// This method adds a name to the *front* of the hierarchical // This method adds a name to the *front* of the hierarchical
// path. The base name remains the same, unless this is the // path. The base name remains the same, unless this is the
// only component. // only component.
void prepend(const char*text); void prepend(perm_string text);
// This method removes the tail name from the hierarchy, and // This method removes the tail name from the hierarchy, and
// returns a pointer to that tail name. That tail name now // returns a pointer to that tail name. That tail name now
// must be removed by the caller. // must be removed by the caller.
char* remove_tail_name(); perm_string remove_tail_name();
// Return the given component in the hierarchical name. If the // Return the given component in the hierarchical name. If the
// idx is too large, return 0. // idx is too large, return 0.
const char*peek_name(unsigned idx) const; perm_string peek_name(unsigned idx) const;
const char*peek_tail_name() const; perm_string peek_tail_name() const;
// Return the number of components in the hierarchical // Return the number of components in the hierarchical
// name. If this is a simple name, this will return 1. // name. If this is a simple name, this will return 1.
@ -69,11 +70,14 @@ class hname_t {
private: private:
union { union {
char**array_; perm_string*array_;
char* item_; char* item_[sizeof(perm_string)];
}; };
unsigned count_; unsigned count_;
perm_string& item_ref1_() { return *(perm_string*)item_; }
const perm_string& item_ref1_() const { return *(perm_string*)item_; }
private: // not implemented private: // not implemented
hname_t& operator= (const hname_t&); hname_t& operator= (const hname_t&);
}; };
@ -83,6 +87,9 @@ extern bool operator == (const hname_t&, const hname_t&);
/* /*
* $Log: HName.h,v $ * $Log: HName.h,v $
* Revision 1.5 2007/04/26 03:06:21 steve
* Rework hname_t to use perm_strings.
*
* Revision 1.4 2002/11/02 03:27:51 steve * Revision 1.4 2002/11/02 03:27:51 steve
* Allow named events to be referenced by * Allow named events to be referenced by
* hierarchical names. * hierarchical names.

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
*/ */
#ifdef HAVE_CVS_IDENT #ifdef HAVE_CVS_IDENT
#ident "$Id: PWire.cc,v 1.12 2007/01/16 05:44:14 steve Exp $" #ident "$Id: PWire.cc,v 1.13 2007/04/26 03:06:21 steve Exp $"
#endif #endif
# include "config.h" # include "config.h"
@ -39,7 +39,7 @@ lidx_(0), ridx_(0)
} }
} }
PWire::PWire(char*n, PWire::PWire(perm_string n,
NetNet::Type t, NetNet::Type t,
NetNet::PortType pt, NetNet::PortType pt,
ivl_variable_type_t dt) ivl_variable_type_t dt)
@ -160,6 +160,9 @@ void PWire::set_memory_idx(PExpr*ldx, PExpr*rdx)
/* /*
* $Log: PWire.cc,v $ * $Log: PWire.cc,v $
* Revision 1.13 2007/04/26 03:06:21 steve
* Rework hname_t to use perm_strings.
*
* Revision 1.12 2007/01/16 05:44:14 steve * Revision 1.12 2007/01/16 05:44:14 steve
* Major rework of array handling. Memories are replaced with the * Major rework of array handling. Memories are replaced with the
* more general concept of arrays. The NetMemory and NetEMemory * more general concept of arrays. The NetMemory and NetEMemory

45
PWire.h
View File

@ -1,7 +1,7 @@
#ifndef __PWire_H #ifndef __PWire_H
#define __PWire_H #define __PWire_H
/* /*
* Copyright (c) 1998-2000 Stephen Williams (steve@icarus.com) * Copyright (c) 1998-2007 Stephen Williams (steve@icarus.com)
* *
* This source code is free software; you can redistribute it * This source code is free software; you can redistribute it
* and/or modify it in source code form under the terms of the GNU * and/or modify it in source code form under the terms of the GNU
@ -19,13 +19,14 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/ */
#ifdef HAVE_CVS_IDENT #ifdef HAVE_CVS_IDENT
#ident "$Id: PWire.h,v 1.19 2006/04/10 00:37:42 steve Exp $" #ident "$Id: PWire.h,v 1.20 2007/04/26 03:06:22 steve Exp $"
#endif #endif
# include "netlist.h" # include "netlist.h"
# include "LineInfo.h" # include "LineInfo.h"
# include <map> # include <map>
# include "svector.h" # include "svector.h"
# include "StringHeap.h"
#ifdef HAVE_IOSFWD #ifdef HAVE_IOSFWD
# include <iosfwd> # include <iosfwd>
@ -53,7 +54,7 @@ class PWire : public LineInfo {
NetNet::Type t, NetNet::Type t,
NetNet::PortType pt, NetNet::PortType pt,
ivl_variable_type_t dt); ivl_variable_type_t dt);
PWire(char*name, PWire(perm_string name,
NetNet::Type t, NetNet::Type t,
NetNet::PortType pt, NetNet::PortType pt,
ivl_variable_type_t dt); ivl_variable_type_t dt);
@ -110,6 +111,9 @@ class PWire : public LineInfo {
/* /*
* $Log: PWire.h,v $ * $Log: PWire.h,v $
* Revision 1.20 2007/04/26 03:06:22 steve
* Rework hname_t to use perm_strings.
*
* Revision 1.19 2006/04/10 00:37:42 steve * Revision 1.19 2006/04/10 00:37:42 steve
* Add support for generate loops w/ wires and gates. * Add support for generate loops w/ wires and gates.
* *
@ -146,40 +150,5 @@ class PWire : public LineInfo {
* *
* Revision 1.10 2001/01/16 02:44:18 steve * Revision 1.10 2001/01/16 02:44:18 steve
* Use the iosfwd header if available. * Use the iosfwd header if available.
*
* Revision 1.9 2000/12/11 00:31:43 steve
* Add support for signed reg variables,
* simulate in t-vvm signed comparisons.
*
* Revision 1.8 2000/05/02 16:27:38 steve
* Move signal elaboration to a seperate pass.
*
* Revision 1.7 2000/02/23 02:56:54 steve
* Macintosh compilers do not support ident.
*
* Revision 1.6 1999/11/27 19:07:57 steve
* Support the creation of scopes.
*
* Revision 1.5 1999/06/17 05:34:42 steve
* Clean up interface of the PWire class,
* Properly match wire ranges.
*
* Revision 1.4 1999/06/02 15:38:46 steve
* Line information with nets.
*
* Revision 1.3 1999/04/19 01:59:36 steve
* Add memories to the parse and elaboration phases.
*
* Revision 1.2 1998/11/23 00:20:22 steve
* NetAssign handles lvalues as pin links
* instead of a signal pointer,
* Wire attributes added,
* Ability to parse UDP descriptions added,
* XNF generates EXT records for signals with
* the PAD attribute.
*
* Revision 1.1 1998/11/03 23:28:55 steve
* Introduce verilog to CVS.
*
*/ */
#endif #endif

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
*/ */
#ifdef HAVE_CVS_IDENT #ifdef HAVE_CVS_IDENT
#ident "$Id: elab_pexpr.cc,v 1.25 2006/11/04 06:19:25 steve Exp $" #ident "$Id: elab_pexpr.cc,v 1.26 2007/04/26 03:06:22 steve Exp $"
#endif #endif
# include "config.h" # include "config.h"
@ -131,18 +131,15 @@ NetExpr*PEFNumber::elaborate_pexpr(Design*des, NetScope*scope) const
NetExpr*PEIdent::elaborate_pexpr(Design*des, NetScope*scope) const NetExpr*PEIdent::elaborate_pexpr(Design*des, NetScope*scope) const
{ {
hname_t path = path_; hname_t path = path_;
char*name = path.remove_tail_name(); perm_string name = path.remove_tail_name();
NetScope*pscope = scope; NetScope*pscope = scope;
if (path.peek_name(0)) if (path.peek_name(0))
pscope = des->find_scope(scope, path); pscope = des->find_scope(scope, path);
perm_string perm_name = lex_strings.make(name);
delete name;
const NetExpr*ex_msb; const NetExpr*ex_msb;
const NetExpr*ex_lsb; const NetExpr*ex_lsb;
const NetExpr*ex = pscope->get_parameter(perm_name, ex_msb, ex_lsb); const NetExpr*ex = pscope->get_parameter(name, ex_msb, ex_lsb);
if (ex == 0) { if (ex == 0) {
cerr << get_line() << ": error: identifier ``" << path_ << cerr << get_line() << ": error: identifier ``" << path_ <<
"'' is not a parameter in " << scope->name() << "." << endl; "'' is not a parameter in " << scope->name() << "." << endl;
@ -150,7 +147,7 @@ NetExpr*PEIdent::elaborate_pexpr(Design*des, NetScope*scope) const
return 0; return 0;
} }
NetExpr*res = new NetEParam(des, pscope, perm_name); NetExpr*res = new NetEParam(des, pscope, name);
res->set_line(*this); res->set_line(*this);
assert(res); assert(res);
@ -236,6 +233,9 @@ NetExpr*PEUnary::elaborate_pexpr (Design*des, NetScope*scope) const
/* /*
* $Log: elab_pexpr.cc,v $ * $Log: elab_pexpr.cc,v $
* Revision 1.26 2007/04/26 03:06:22 steve
* Rework hname_t to use perm_strings.
*
* Revision 1.25 2006/11/04 06:19:25 steve * Revision 1.25 2006/11/04 06:19:25 steve
* Remove last bits of relax_width methods, and use test_width * Remove last bits of relax_width methods, and use test_width
* to calculate the width of an r-value expression that may * to calculate the width of an r-value expression that may

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
*/ */
#ifdef HAVE_CVS_IDENT #ifdef HAVE_CVS_IDENT
#ident "$Id: elab_sig.cc,v 1.49 2007/04/02 01:12:34 steve Exp $" #ident "$Id: elab_sig.cc,v 1.50 2007/04/26 03:06:22 steve Exp $"
#endif #endif
# include "config.h" # include "config.h"
@ -63,6 +63,22 @@ static bool signal_is_in_port(const svector<Module::port_t*>&ports,
return false; return false;
} }
static NetNet*find_signal_in_scope(NetScope*scope, const hname_t&path)
{
NetScope*cur = scope;
unsigned idx = 0;
while (path.peek_name(idx+1)) {
cur = cur->child(path.peek_name(idx));
if (cur == 0)
return 0;
idx += 1;
}
return cur->find_signal(path.peek_name(idx));
}
bool Module::elaborate_sig(Design*des, NetScope*scope) const bool Module::elaborate_sig(Design*des, NetScope*scope) const
{ {
bool flag = true; bool flag = true;
@ -110,7 +126,7 @@ bool Module::elaborate_sig(Design*des, NetScope*scope) const
PWire*cur = (*wt).second; PWire*cur = (*wt).second;
cur->elaborate_sig(des, scope); cur->elaborate_sig(des, scope);
NetNet*sig = scope->find_signal_in_child(cur->path()); NetNet*sig = find_signal_in_scope(scope, cur->path());
// If this wire is a signal of the module (as opposed to // If this wire is a signal of the module (as opposed to
// a port of a function) and is a port, then check that // a port of a function) and is a port, then check that
@ -509,7 +525,7 @@ void PWire::elaborate_sig(Design*des, NetScope*scope) const
follow the scopes down to the base where I actually want to follow the scopes down to the base where I actually want to
elaborate the NetNet object. */ elaborate the NetNet object. */
{ hname_t tmp_path = hname_; { hname_t tmp_path = hname_;
free(tmp_path.remove_tail_name()); tmp_path.remove_tail_name();
for (unsigned idx = 0 ; tmp_path.peek_name(idx) ; idx += 1) { for (unsigned idx = 0 ; tmp_path.peek_name(idx) ; idx += 1) {
scope = scope->child(tmp_path.peek_name(idx)); scope = scope->child(tmp_path.peek_name(idx));
@ -742,6 +758,9 @@ void PWire::elaborate_sig(Design*des, NetScope*scope) const
/* /*
* $Log: elab_sig.cc,v $ * $Log: elab_sig.cc,v $
* Revision 1.50 2007/04/26 03:06:22 steve
* Rework hname_t to use perm_strings.
*
* Revision 1.49 2007/04/02 01:12:34 steve * Revision 1.49 2007/04/02 01:12:34 steve
* Seperate arrayness from word count * Seperate arrayness from word count
* *

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
*/ */
#ifdef HAVE_CVS_IDENT #ifdef HAVE_CVS_IDENT
#ident "$Id: net_design.cc,v 1.50 2006/08/08 05:11:37 steve Exp $" #ident "$Id: net_design.cc,v 1.51 2007/04/26 03:06:22 steve Exp $"
#endif #endif
# include "config.h" # include "config.h"
@ -201,9 +201,7 @@ void NetScope::run_defparams(Design*des)
NetExpr*val = (*pp).second; NetExpr*val = (*pp).second;
hname_t path = (*pp).first; hname_t path = (*pp).first;
char*tmp = path.remove_tail_name(); perm_string perm_name = path.remove_tail_name();
perm_string perm_name = lex_strings.make(tmp);
delete[]tmp;
/* If there is no path on the name, then the targ_scope /* If there is no path on the name, then the targ_scope
is the current scope. */ is the current scope. */
@ -429,22 +427,20 @@ NetNet* Design::find_signal(NetScope*scope, hname_t path)
{ {
assert(scope); assert(scope);
char*key = path.remove_tail_name(); perm_string key = path.remove_tail_name();
if (path.peek_name(0)) if (path.peek_name(0))
scope = find_scope(scope, path); scope = find_scope(scope, path);
while (scope) { while (scope) {
if (NetNet*net = scope->find_signal(key)) { if (NetNet*net = scope->find_signal(key))
delete key;
return net; return net;
}
if (scope->type() == NetScope::MODULE) if (scope->type() == NetScope::MODULE)
break; break;
scope = scope->parent(); scope = scope->parent();
} }
delete key;
return 0; return 0;
} }
@ -562,6 +558,9 @@ void Design::delete_process(NetProcTop*top)
/* /*
* $Log: net_design.cc,v $ * $Log: net_design.cc,v $
* Revision 1.51 2007/04/26 03:06:22 steve
* Rework hname_t to use perm_strings.
*
* Revision 1.50 2006/08/08 05:11:37 steve * Revision 1.50 2006/08/08 05:11:37 steve
* Handle 64bit delay constants. * Handle 64bit delay constants.
* *

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
*/ */
#ifdef HAVE_CVS_IDENT #ifdef HAVE_CVS_IDENT
#ident "$Id: net_scope.cc,v 1.36 2007/01/16 05:44:15 steve Exp $" #ident "$Id: net_scope.cc,v 1.37 2007/04/26 03:06:22 steve Exp $"
#endif #endif
# include "config.h" # include "config.h"
@ -336,27 +336,6 @@ NetNet* NetScope::find_signal(const char*key)
return 0; return 0;
} }
/*
* This method searches for the signal within this scope. If the path
* has hierarchy, I follow the child scopes until I get the base name,
* and look for the key in the deepest scope.
*/
NetNet* NetScope::find_signal_in_child(const hname_t&path)
{
NetScope*cur = this;
unsigned idx = 0;
while (path.peek_name(idx+1)) {
cur = cur->child(path.peek_name(idx));
if (cur == 0)
return 0;
idx += 1;
}
return cur->find_signal(path.peek_name(idx));
}
/* /*
* 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 hierarchy is searched. * name of the child, no hierarchy is searched.
@ -412,6 +391,9 @@ string NetScope::local_hsymbol()
/* /*
* $Log: net_scope.cc,v $ * $Log: net_scope.cc,v $
* Revision 1.37 2007/04/26 03:06:22 steve
* Rework hname_t to use perm_strings.
*
* Revision 1.36 2007/01/16 05:44:15 steve * Revision 1.36 2007/01/16 05:44:15 steve
* Major rework of array handling. Memories are replaced with the * Major rework of array handling. Memories are replaced with the
* more general concept of arrays. The NetMemory and NetEMemory * more general concept of arrays. The NetMemory and NetEMemory

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
*/ */
#ifdef HAVE_CVS_IDENT #ifdef HAVE_CVS_IDENT
#ident "$Id: netlist.h,v 1.377 2007/04/17 04:34:23 steve Exp $" #ident "$Id: netlist.h,v 1.378 2007/04/26 03:06:22 steve Exp $"
#endif #endif
/* /*
@ -3220,10 +3220,7 @@ class NetScope : public Attrib {
void add_signal(NetNet*); void add_signal(NetNet*);
void rem_signal(NetNet*); void rem_signal(NetNet*);
NetNet* find_signal(const char*name); NetNet* find_signal(const char*name);
NetNet* find_signal_in_child(const hname_t&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. */
@ -3503,6 +3500,9 @@ extern ostream& operator << (ostream&, NetNet::Type);
/* /*
* $Log: netlist.h,v $ * $Log: netlist.h,v $
* Revision 1.378 2007/04/26 03:06:22 steve
* Rework hname_t to use perm_strings.
*
* Revision 1.377 2007/04/17 04:34:23 steve * Revision 1.377 2007/04/17 04:34:23 steve
* Fix handling calls to tasks in combinational always block * Fix handling calls to tasks in combinational always block
* *

35
parse.y
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
*/ */
#ifdef HAVE_CVS_IDENT #ifdef HAVE_CVS_IDENT
#ident "$Id: parse.y,v 1.235 2007/04/21 04:45:36 steve Exp $" #ident "$Id: parse.y,v 1.236 2007/04/26 03:06:22 steve Exp $"
#endif #endif
# include "config.h" # include "config.h"
@ -605,7 +605,7 @@ delay_value_simple
} }
} }
| IDENTIFIER | IDENTIFIER
{ PEIdent*tmp = new PEIdent(hname_t($1)); { PEIdent*tmp = new PEIdent(hname_t(lex_strings.make($1)));
tmp->set_file(@1.text); tmp->set_file(@1.text);
tmp->set_lineno(@1.first_line); tmp->set_lineno(@1.first_line);
$$ = tmp; $$ = tmp;
@ -1033,7 +1033,8 @@ expr_primary
$$ = tmp; $$ = tmp;
} }
| SYSTEM_IDENTIFIER | SYSTEM_IDENTIFIER
{ PECallFunction*tmp = new PECallFunction(hname_t($1)); { perm_string tn = lex_strings.make($1);
PECallFunction*tmp = new PECallFunction(hname_t(tn));
tmp->set_file(@1.text); tmp->set_file(@1.text);
tmp->set_lineno(@1.first_line); tmp->set_lineno(@1.first_line);
$$ = tmp; $$ = tmp;
@ -1087,7 +1088,8 @@ expr_primary
$$ = tmp; $$ = tmp;
} }
| SYSTEM_IDENTIFIER '(' expression_list_proper ')' | SYSTEM_IDENTIFIER '(' expression_list_proper ')'
{ PECallFunction*tmp = new PECallFunction(hname_t($1), *$3); { perm_string tn = lex_strings.make($1);
PECallFunction*tmp = new PECallFunction(hname_t(tn), *$3);
tmp->set_file(@1.text); tmp->set_file(@1.text);
tmp->set_lineno(@1.first_line); tmp->set_lineno(@1.first_line);
$$ = tmp; $$ = tmp;
@ -1346,12 +1348,12 @@ gatetype
hierarchical name from left to right, forming a list of names. */ hierarchical name from left to right, forming a list of names. */
identifier identifier
: IDENTIFIER : IDENTIFIER
{ $$ = new hname_t($1); { $$ = new hname_t(lex_strings.make($1));
delete $1; delete $1;
} }
| identifier '.' IDENTIFIER | identifier '.' IDENTIFIER
{ hname_t * tmp = $1; { hname_t * tmp = $1;
tmp->append($3); tmp->append(lex_strings.make($3));
delete $3; delete $3;
$$ = tmp; $$ = tmp;
} }
@ -2313,7 +2315,7 @@ port_reference
} }
| IDENTIFIER '[' expression ':' expression ']' | IDENTIFIER '[' expression ':' expression ']'
{ PEIdent*wtmp = new PEIdent(hname_t($1)); { PEIdent*wtmp = new PEIdent(hname_t(lex_strings.make($1)));
wtmp->set_file(@1.text); wtmp->set_file(@1.text);
wtmp->set_lineno(@1.first_line); wtmp->set_lineno(@1.first_line);
if (!pform_expression_is_constant($3)) { if (!pform_expression_is_constant($3)) {
@ -2336,7 +2338,7 @@ port_reference
} }
| IDENTIFIER '[' expression ']' | IDENTIFIER '[' expression ']'
{ PEIdent*tmp = new PEIdent(hname_t($1)); { PEIdent*tmp = new PEIdent(hname_t(lex_strings.make($1)));
tmp->set_file(@1.text); tmp->set_file(@1.text);
tmp->set_lineno(@1.first_line); tmp->set_lineno(@1.first_line);
if (!pform_expression_is_constant($3)) { if (!pform_expression_is_constant($3)) {
@ -2355,7 +2357,7 @@ port_reference
| IDENTIFIER '[' error ']' | IDENTIFIER '[' error ']'
{ yyerror(@1, "error: invalid port bit select"); { yyerror(@1, "error: invalid port bit select");
Module::port_t*ptmp = new Module::port_t; Module::port_t*ptmp = new Module::port_t;
PEIdent*wtmp = new PEIdent(hname_t($1)); PEIdent*wtmp = new PEIdent(hname_t(lex_strings.make($1)));
wtmp->set_file(@1.text); wtmp->set_file(@1.text);
wtmp->set_lineno(@1.first_line); wtmp->set_lineno(@1.first_line);
ptmp->name = lex_strings.make($1); ptmp->name = lex_strings.make($1);
@ -3130,7 +3132,7 @@ statement
$$ = tmp; $$ = tmp;
} }
| SYSTEM_IDENTIFIER '(' expression_list_with_nuls ')' ';' | SYSTEM_IDENTIFIER '(' expression_list_with_nuls ')' ';'
{ PCallTask*tmp = new PCallTask(hname_t($1), *$3); { PCallTask*tmp = new PCallTask(hname_t(lex_strings.make($1)), *$3);
tmp->set_file(@1.text); tmp->set_file(@1.text);
tmp->set_lineno(@1.first_line); tmp->set_lineno(@1.first_line);
delete $1; delete $1;
@ -3139,7 +3141,7 @@ statement
} }
| SYSTEM_IDENTIFIER ';' | SYSTEM_IDENTIFIER ';'
{ svector<PExpr*>pt (0); { svector<PExpr*>pt (0);
PCallTask*tmp = new PCallTask(hname_t($1), pt); PCallTask*tmp = new PCallTask(hname_t(lex_strings.make($1)), pt);
tmp->set_file(@1.text); tmp->set_file(@1.text);
tmp->set_lineno(@1.first_line); tmp->set_lineno(@1.first_line);
delete $1; delete $1;
@ -3521,7 +3523,7 @@ udp_sequ_entry
udp_initial udp_initial
: K_initial IDENTIFIER '=' number ';' : K_initial IDENTIFIER '=' number ';'
{ PExpr*etmp = new PENumber($4); { PExpr*etmp = new PENumber($4);
PEIdent*itmp = new PEIdent(hname_t($2)); PEIdent*itmp = new PEIdent(hname_t(lex_strings.make($2)));
PAssign*atmp = new PAssign(itmp, etmp); PAssign*atmp = new PAssign(itmp, etmp);
atmp->set_file(@2.text); atmp->set_file(@2.text);
atmp->set_lineno(@2.first_line); atmp->set_lineno(@2.first_line);
@ -3590,31 +3592,34 @@ udp_port_decl
: K_input list_of_identifiers ';' : K_input list_of_identifiers ';'
{ $$ = pform_make_udp_input_ports($2); } { $$ = pform_make_udp_input_ports($2); }
| K_output IDENTIFIER ';' | K_output IDENTIFIER ';'
{ PWire*pp = new PWire($2, { PWire*pp = new PWire(lex_strings.make($2),
NetNet::IMPLICIT, NetNet::IMPLICIT,
NetNet::POUTPUT, NetNet::POUTPUT,
IVL_VT_LOGIC); IVL_VT_LOGIC);
svector<PWire*>*tmp = new svector<PWire*>(1); svector<PWire*>*tmp = new svector<PWire*>(1);
(*tmp)[0] = pp; (*tmp)[0] = pp;
$$ = tmp; $$ = tmp;
delete $2;
} }
| K_reg IDENTIFIER ';' | K_reg IDENTIFIER ';'
{ PWire*pp = new PWire($2, { PWire*pp = new PWire(lex_strings.make($2),
NetNet::REG, NetNet::REG,
NetNet::PIMPLICIT, NetNet::PIMPLICIT,
IVL_VT_LOGIC); IVL_VT_LOGIC);
svector<PWire*>*tmp = new svector<PWire*>(1); svector<PWire*>*tmp = new svector<PWire*>(1);
(*tmp)[0] = pp; (*tmp)[0] = pp;
$$ = tmp; $$ = tmp;
delete $2;
} }
| K_reg K_output IDENTIFIER ';' | K_reg K_output IDENTIFIER ';'
{ PWire*pp = new PWire($3, { PWire*pp = new PWire(lex_strings.make($3),
NetNet::REG, NetNet::REG,
NetNet::POUTPUT, NetNet::POUTPUT,
IVL_VT_LOGIC); IVL_VT_LOGIC);
svector<PWire*>*tmp = new svector<PWire*>(1); svector<PWire*>*tmp = new svector<PWire*>(1);
(*tmp)[0] = pp; (*tmp)[0] = pp;
$$ = tmp; $$ = tmp;
delete $3;
} }
; ;

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
*/ */
#ifdef HAVE_CVS_IDENT #ifdef HAVE_CVS_IDENT
#ident "$Id: pform.cc,v 1.144 2007/04/19 02:52:53 steve Exp $" #ident "$Id: pform.cc,v 1.145 2007/04/26 03:06:22 steve Exp $"
#endif #endif
# include "config.h" # include "config.h"
@ -91,20 +91,19 @@ static hname_t scope_stack;
void pform_push_scope(char*name) void pform_push_scope(char*name)
{ {
scope_stack.append(name); scope_stack.append(lex_strings.make(name));
} }
void pform_pop_scope() void pform_pop_scope()
{ {
char*tmp = scope_stack.remove_tail_name(); perm_string tmp = scope_stack.remove_tail_name();
assert(tmp); assert(tmp);
free(tmp);
} }
static hname_t hier_name(const char*tail) static hname_t hier_name(const char*tail)
{ {
hname_t name = scope_stack; hname_t name = scope_stack;
name.append(tail); name.append(lex_strings.make(tail));
return name; return name;
} }
@ -278,7 +277,7 @@ Module::port_t* pform_module_port_reference(char*name,
unsigned lineno) unsigned lineno)
{ {
Module::port_t*ptmp = new Module::port_t; Module::port_t*ptmp = new Module::port_t;
PEIdent*tmp = new PEIdent(hname_t(name)); PEIdent*tmp = new PEIdent(hname_t(lex_strings.make(name)));
tmp->set_file(file); tmp->set_file(file);
tmp->set_lineno(lineno); tmp->set_lineno(lineno);
ptmp->name = lex_strings.make(name); ptmp->name = lex_strings.make(name);
@ -514,7 +513,7 @@ void pform_make_udp(perm_string name, list<string>*parms,
hname_t pname = (*decl)[idx]->path(); hname_t pname = (*decl)[idx]->path();
if (PWire*cur = defs[pname.peek_name(0)]) { if (PWire*cur = defs[pname.peek_name(0).str()]) {
bool rc = true; bool rc = true;
assert((*decl)[idx]); assert((*decl)[idx]);
if ((*decl)[idx]->get_port_type() != NetNet::PIMPLICIT) { if ((*decl)[idx]->get_port_type() != NetNet::PIMPLICIT) {
@ -527,7 +526,7 @@ void pform_make_udp(perm_string name, list<string>*parms,
} }
} else { } else {
defs[pname.peek_name(0)] = (*decl)[idx]; defs[pname.peek_name(0).str()] = (*decl)[idx];
} }
} }
@ -1286,10 +1285,11 @@ void pform_makewire(const vlltype&li,
pform_makewire(li, first->name, type, NetNet::NOT_A_PORT, dt, 0); pform_makewire(li, first->name, type, NetNet::NOT_A_PORT, dt, 0);
pform_set_net_range(first->name, range, signed_flag, dt); pform_set_net_range(first->name, range, signed_flag, dt);
hname_t name = hier_name(first->name); perm_string first_name = lex_strings.make(first->name);
hname_t name = hier_name(first_name);
PWire*cur = get_wire_in_module(name); PWire*cur = get_wire_in_module(name);
if (cur != 0) { if (cur != 0) {
PEIdent*lval = new PEIdent(hname_t(first->name)); PEIdent*lval = new PEIdent(hname_t(first_name));
lval->set_file(li.text); lval->set_file(li.text);
lval->set_lineno(li.first_line); lval->set_lineno(li.first_line);
PGAssign*ass = pform_make_pgassign(lval, first->expr, PGAssign*ass = pform_make_pgassign(lval, first->expr,
@ -1769,6 +1769,9 @@ int pform_parse(const char*path, FILE*file)
/* /*
* $Log: pform.cc,v $ * $Log: pform.cc,v $
* Revision 1.145 2007/04/26 03:06:22 steve
* Rework hname_t to use perm_strings.
*
* Revision 1.144 2007/04/19 02:52:53 steve * Revision 1.144 2007/04/19 02:52:53 steve
* Add support for -v flag in command file. * Add support for -v flag in command file.
* *

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
*/ */
#ifdef HAVE_CVS_IDENT #ifdef HAVE_CVS_IDENT
#ident "$Id: symbol_search.cc,v 1.4 2007/01/16 05:44:15 steve Exp $" #ident "$Id: symbol_search.cc,v 1.5 2007/04/26 03:06:22 steve Exp $"
#endif #endif
# include "netlist.h" # include "netlist.h"
@ -36,7 +36,7 @@ NetScope*symbol_search(const Design*des, NetScope*scope, hname_t path,
assert(scope); assert(scope);
/* Get the tail name of the object we are looking for. */ /* Get the tail name of the object we are looking for. */
char*key = path.remove_tail_name(); perm_string key = path.remove_tail_name();
/* Initialize output argument to cleared. */ /* Initialize output argument to cleared. */
net = 0; net = 0;
@ -49,20 +49,14 @@ NetScope*symbol_search(const Design*des, NetScope*scope, hname_t path,
scope = des->find_scope(scope, path); scope = des->find_scope(scope, path);
while (scope) { while (scope) {
if ( (net = scope->find_signal(key)) ) { if ( (net = scope->find_signal(key)) )
delete key;
return scope; return scope;
}
if ( (eve = scope->find_event(key)) ) { if ( (eve = scope->find_event(key)) )
delete key;
return scope; return scope;
}
if ( (par = scope->get_parameter(key, ex1, ex2)) ) { if ( (par = scope->get_parameter(key, ex1, ex2)) )
delete key;
return scope; return scope;
}
if (scope->type() == NetScope::MODULE) if (scope->type() == NetScope::MODULE)
scope = 0; scope = 0;
@ -70,12 +64,14 @@ NetScope*symbol_search(const Design*des, NetScope*scope, hname_t path,
scope = scope->parent(); scope = scope->parent();
} }
delete key;
return 0; return 0;
} }
/* /*
* $Log: symbol_search.cc,v $ * $Log: symbol_search.cc,v $
* Revision 1.5 2007/04/26 03:06:22 steve
* Rework hname_t to use perm_strings.
*
* Revision 1.4 2007/01/16 05:44:15 steve * Revision 1.4 2007/01/16 05:44:15 steve
* Major rework of array handling. Memories are replaced with the * Major rework of array handling. Memories are replaced with the
* more general concept of arrays. The NetMemory and NetEMemory * more general concept of arrays. The NetMemory and NetEMemory