Permalink
Browse files

Properly evaluate scope path expressions.

  • Loading branch information...
1 parent 1f9a246 commit c7d97f4146af277ebfb389d1e9f21836734bf6dc steve committed Jun 2, 2007
Showing with 508 additions and 510 deletions.
  1. +45 −188 HName.cc
  2. +23 −35 HName.h
  3. +2 −1 PGenerate.cc
  4. +5 −2 PGenerate.h
  5. +47 −24 design_dump.cc
  6. +15 −8 elab_expr.cc
  7. +7 −4 elab_lval.cc
  8. +14 −10 elab_net.cc
  9. +10 −4 elab_pexpr.cc
  10. +18 −20 elab_scope.cc
  11. +21 −16 elab_sig.cc
  12. +20 −14 elaborate.cc
  13. +5 −2 eval_tree.cc
  14. +4 −2 expr_synth.cc
  15. +27 −41 net_design.cc
  16. +6 −3 net_event.cc
  17. +6 −3 net_func.cc
  18. +5 −2 net_link.cc
  19. +12 −17 net_scope.cc
  20. +22 −9 netlist.cc
  21. +31 −21 netlist.h
  22. +38 −32 netmisc.cc
  23. +9 −3 netmisc.h
  24. +12 −4 pform.cc
  25. +15 −7 pform_dump.cc
  26. +12 −4 symbol_search.cc
  27. +7 −2 t-dll-proc.cc
  28. +60 −29 t-dll.cc
  29. +5 −1 t-dll.h
  30. +5 −2 target.cc
View
233 HName.cc
@@ -17,7 +17,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#ifdef HAVE_CVS_IDENT
-#ident "$Id: HName.cc,v 1.7 2007/05/16 19:12:33 steve Exp $"
+#ident "$Id: HName.cc,v 1.8 2007/06/02 03:42:12 steve Exp $"
#endif
# include "config.h"
@@ -29,244 +29,101 @@
# include <malloc.h>
#endif
-inline perm_string& hname_t::item_ref1_()
-{
- return *reinterpret_cast<perm_string*>(item_);
-}
-
-inline const perm_string& hname_t::item_ref1_() const
-{
- return *reinterpret_cast<const perm_string*>(item_);
-}
-
hname_t::hname_t()
{
- count_ = 0;
+ number_ = INT_MIN;
}
hname_t::hname_t(perm_string text)
{
- new (item_) perm_string(text);
- count_ = 1;
+ name_ = text;
+ number_ = INT_MIN;
}
-hname_t::hname_t(const hname_t&that)
+hname_t::hname_t(perm_string text, int num)
{
- count_ = that.count_;
- switch (count_) {
- case 0:
- break;
- case 1:
- new(item_) perm_string (that.item_ref1_());
- break;
- default:
- array_ = new perm_string[count_];
- for (unsigned idx = 0 ; idx < count_ ; idx += 1)
- array_[idx] = that.array_[idx];
- break;
- }
+ name_ = text;
+ number_ = num;
}
-hname_t::~hname_t()
+hname_t::hname_t(const hname_t&that)
{
- switch (count_) {
- case 0:
- break;
- case 1:
- item_ref1_().~perm_string();
- break;
- default:
- delete[]array_;
- break;
- }
+ name_ = that.name_;
+ number_ = that.number_;
}
-unsigned hname_t::component_count() const
+hname_t& hname_t::operator = (const hname_t&that)
{
- return count_;
+ name_ = that.name_;
+ number_ = that.number_;
+ return *this;
}
-void hname_t::append(perm_string text)
+hname_t::~hname_t()
{
- perm_string*tmp;
-
- switch (count_) {
- case 0:
- count_ = 1;
- new (item_) perm_string(text);
- break;
- case 1:
- count_ = 2;
- tmp = new perm_string[2];
- tmp[0] = item_ref1_();
- tmp[1] = text;
- item_ref1_().~perm_string();
- array_ = tmp;
- break;
- default:
- tmp = new perm_string[count_+1];
- for (unsigned idx = 0 ; idx < count_ ; idx += 1)
- tmp[idx] = array_[idx];
- delete[]array_;
- array_ = tmp;
- array_[count_] = text;
- count_ += 1;
- }
}
-void hname_t::prepend(perm_string text)
+perm_string hname_t::peek_name(void) const
{
- perm_string*tmp;
-
- switch (count_) {
- case 0:
- count_ = 1;
- new (item_) perm_string(text);
- break;
- case 1:
- count_ = 2;
- tmp = new perm_string[2];
- tmp[0] = text;
- tmp[1] = item_ref1_();
- item_ref1_().~perm_string();
- array_ = tmp;
- break;
- default:
- tmp = new perm_string[count_+1];
- tmp[0] = text;
- for (unsigned idx = 0 ; idx < count_ ; idx += 1)
- tmp[idx+1] = array_[idx];
- delete[]array_;
- array_ = tmp;
- count_ += 1;
- }
+ return name_;
}
-perm_string hname_t::remove_tail_name()
+bool hname_t::has_number() const
{
- if (count_ == 0)
- return perm_string();
-
- if (count_ == 1) {
- perm_string tmp = item_ref1_();
- count_ = 0;
- item_ref1_().~perm_string();
- return tmp;
- }
-
- if (count_ == 2) {
- perm_string tmp1 = array_[0];
- perm_string tmp2 = array_[1];
- delete[]array_;
- count_ = 1;
- new (item_) perm_string(tmp1);
- return tmp2;
- }
-
- perm_string tmpo = array_[count_-1];
- perm_string*tmpa = new perm_string[count_-1];
- for (unsigned idx = 0 ; idx < count_-1 ; idx += 1)
- tmpa[idx] = array_[idx];
-
- delete[]array_;
- array_ = tmpa;
- count_ -= 1;
- return tmpo;
+ return number_ != INT_MIN;
}
-perm_string hname_t::peek_name(unsigned idx) const
+int hname_t::peek_number() const
{
- if (idx >= count_)
- return perm_string();
-
- if (count_ == 1)
- return item_ref1_();
-
- return array_[idx];
-}
-
-perm_string hname_t::peek_tail_name() const
-{
- switch (count_) {
- case 0:
- return perm_string();
- case 1:
- return item_ref1_();
- default:
- return array_[count_-1];
- }
+ return number_;
}
bool operator < (const hname_t&l, const hname_t&r)
{
- unsigned idx = 0;
- const char*lc = l.peek_name(idx);
- const char*rc = r.peek_name(idx);
-
- while (lc && rc) {
- int cmp = strcmp(lc, rc);
- if (cmp < 0)
- return true;
- if (cmp > 0)
- return false;
- idx += 1;
- lc = l.peek_name(idx);
- rc = r.peek_name(idx);
- }
-
- if (lc && !rc)
+ int cmp = strcmp(l.peek_name(), r.peek_name());
+ if (cmp < 0) return true;
+ if (cmp > 0) return false;
+ if (l.has_number() && r.has_number())
+ return l.peek_number() < r.peek_number();
+ else
return false;
- if (rc && !lc)
- return true;
-
- // Must be ==
- return false;
}
bool operator == (const hname_t&l, const hname_t&r)
{
- unsigned idx = 0;
- const char*lc = l.peek_name(idx);
- const char*rc = r.peek_name(idx);
-
- while (lc && rc) {
- int cmp = strcmp(lc, rc);
- if (cmp != 0)
- return false;
- idx += 1;
- lc = l.peek_name(idx);
- rc = r.peek_name(idx);
+ if (l.peek_name() == r.peek_name()) {
+ if (l.has_number() && r.has_number())
+ return l.peek_number() == r.peek_number();
+ else
+ return true;
}
- if (lc || rc)
- return false;
-
- // Must be ==
- return true;
+ return false;
}
+bool operator != (const hname_t&l, const hname_t&r)
+{ return ! (l==r); }
+
ostream& operator<< (ostream&out, const hname_t&that)
{
- switch (that.count_) {
- case 0:
+ if (that.peek_name() == 0) {
out << "";
return out;
- case 1:
- out << that.item_;
- return out;
+ }
- default:
- out << that.array_[0];
- for (unsigned idx = 1 ; idx < that.count_ ; idx += 1)
- out << "." << that.array_[idx];
+ out << that.peek_name();
+ if (that.has_number())
+ out << "[" << that.peek_number() << "]";
- return out;
- }
+ return out;
}
/*
* $Log: HName.cc,v $
+ * Revision 1.8 2007/06/02 03:42:12 steve
+ * Properly evaluate scope path expressions.
+ *
* Revision 1.7 2007/05/16 19:12:33 steve
* Fix hname_t use of space for 1 perm_string.
*
View
58 HName.h
@@ -1,7 +1,7 @@
#ifndef __HName_H
#define __HName_H
/*
- * Copyright (c) 2001 Stephen Williams (steve@icarus.com)
+ * Copyright (c) 2001-2007 Stephen Williams (steve@icarus.com)
*
* This source code is free software; you can redistribute it
* and/or modify it in source code form under the terms of the GNU
@@ -19,7 +19,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#ifdef HAVE_CVS_IDENT
-#ident "$Id: HName.h,v 1.6 2007/05/16 19:12:33 steve Exp $"
+#ident "$Id: HName.h,v 1.7 2007/06/02 03:42:12 steve Exp $"
#endif
# include <iostream>
@@ -31,62 +31,50 @@ using namespace std;
#endif
/*
- * This class represents a Verilog hierarchical name. A hierarchical
- * name is an ordered list of simple names.
+ * This class represents a component of a Verilog hierarchical name. A
+ * hierarchical component contains a name string (prepresented here
+ * with a perm_string) and an optional signed number. This signed
+ * number is used if the scope is part of an array, for example an
+ * array of module instances or a loop generated scope.
*/
class hname_t {
public:
hname_t ();
explicit hname_t (perm_string text);
+ explicit hname_t (perm_string text, int num);
hname_t (const hname_t&that);
~hname_t();
- // This method adds a name to the end of the hierarchical
- // path. This becomes a new base name.
- void append(perm_string text);
-
- // This method adds a name to the *front* of the hierarchical
- // path. The base name remains the same, unless this is the
- // only component.
- void prepend(perm_string text);
-
- // This method removes the tail name from the hierarchy, and
- // returns a pointer to that tail name. That tail name now
- // must be removed by the caller.
- perm_string remove_tail_name();
-
- // Return the given component in the hierarchical name. If the
- // idx is too large, return 0.
- perm_string peek_name(unsigned idx) const;
- perm_string peek_tail_name() const;
+ hname_t& operator= (const hname_t&);
- // Return the number of components in the hierarchical
- // name. If this is a simple name, this will return 1.
- unsigned component_count() const;
+ // Return the string part of the hname_t.
+ perm_string peek_name(void) const;
- friend ostream& operator<< (ostream&, const hname_t&);
+ bool has_number() const;
+ int peek_number() const;
private:
- union {
- perm_string*array_;
- char item_[sizeof(perm_string)];
- };
- unsigned count_;
-
- perm_string& item_ref1_();
- const perm_string& item_ref1_() const;
+ perm_string name_;
+ // If the number is anything other then INT_MIN, then this is
+ // the numeric part of the name. Otherwise, it is not part of
+ // the name at all.
+ int number_;
private: // not implemented
- hname_t& operator= (const hname_t&);
};
extern bool operator < (const hname_t&, const hname_t&);
extern bool operator == (const hname_t&, const hname_t&);
+extern bool operator != (const hname_t&, const hname_t&);
+extern ostream& operator<< (ostream&, const hname_t&);
/*
* $Log: HName.h,v $
+ * Revision 1.7 2007/06/02 03:42:12 steve
+ * Properly evaluate scope path expressions.
+ *
* Revision 1.6 2007/05/16 19:12:33 steve
* Fix hname_t use of space for 1 perm_string.
*
View
3 PGenerate.cc
@@ -17,7 +17,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#ifdef HAVE_CVS_IDENT
-#ident "$Id: PGenerate.cc,v 1.3 2007/05/24 04:07:11 steve Exp $"
+#ident "$Id: PGenerate.cc,v 1.4 2007/06/02 03:42:12 steve Exp $"
#endif
# include "PGenerate.h"
@@ -26,6 +26,7 @@
PGenerate::PGenerate(unsigned id)
: id_number(id)
{
+ parent = 0;
}
PGenerate::~PGenerate()
View
7 PGenerate.h
@@ -19,7 +19,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#ifdef HAVE_CVS_IDENT
-#ident "$Id: PGenerate.h,v 1.3 2007/05/24 04:07:11 steve Exp $"
+#ident "$Id: PGenerate.h,v 1.4 2007/06/02 03:42:12 steve Exp $"
#endif
# include "LineInfo.h"
@@ -70,6 +70,9 @@ class PGenerate : public LineInfo {
list<PProcess*> behaviors;
void add_behavior(PProcess*behave);
+ list<PGenerate*> generates;
+ PGenerate*parent;
+
// This method is called by the elaboration of a module to
// generate scopes. the container is the scope that is to
// contain the generated scope.
@@ -78,7 +81,7 @@ class PGenerate : public LineInfo {
bool elaborate_sig(Design*des) const;
bool elaborate(Design*des) const;
- void dump(ostream&out) const;
+ void dump(ostream&out, unsigned indent) const;
private:
bool generate_scope_loop_(Design*des, NetScope*container);
View
71 design_dump.cc
@@ -17,7 +17,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#ifdef HAVE_CVS_IDENT
-#ident "$Id: design_dump.cc,v 1.175 2007/05/24 04:07:11 steve Exp $"
+#ident "$Id: design_dump.cc,v 1.176 2007/06/02 03:42:12 steve Exp $"
#endif
# include "config.h"
@@ -91,6 +91,25 @@ ostream& operator << (ostream&o, ivl_variable_type_t val)
return o;
}
+static inline void dump_scope_path(ostream&o, const NetScope*scope)
+{
+ if (const NetScope*parent = scope->parent()) {
+ dump_scope_path(o, parent);
+ o << ".";
+ }
+ const hname_t name = scope->fullname();
+ o << name.peek_name();
+ if (name.has_number())
+ o << "[" << name.peek_number() << "]";
+}
+
+ostream& operator <<(ostream&o, struct __ScopePathManip marg)
+{
+ if (marg.scope != 0)
+ dump_scope_path(o, marg.scope);
+ return o;
+}
+
void NetDelaySrc::dump(ostream&o, unsigned ind) const
{
o << setw(ind) << "" << "specify delay";
@@ -141,7 +160,7 @@ void NetNet::dump_net(ostream&o, unsigned ind) const
}
o << " (eref=" << peek_eref() << ", lref=" << peek_lref() << ")";
if (scope())
- o << " scope=" << scope()->name();
+ o << " scope=" << scope_path(scope());
o << " #(" << rise_time() << "," << fall_time() << ","
<< decay_time() << ") vector_width=" << vector_width()
<< " pin_count=" << pin_count()
@@ -264,7 +283,7 @@ void NetConcat::dump_node(ostream&o, unsigned ind) const
{
o << setw(ind) << "" << "NetConcat: "
<< name()
- << " scope=" << (scope()? scope()->name() : "")
+ << " scope=" << scope_path(scope())
<< " width=" << width_ << endl;
dump_node_pins(o, ind+4);
dump_obj_attr(o, ind+4);
@@ -288,15 +307,15 @@ void NetMux::dump_node(ostream&o, unsigned ind) const
{
o << setw(ind) << "" << "Multiplexer (NetMux): " << name()
<< " width=" << width_ << " swidth=" << swidth_ << " size=" << size_
- << " scope=" << scope()->name() << endl;
+ << " scope=" << scope_path(scope()) << endl;
dump_node_pins(o, ind+4);
dump_obj_attr(o, ind+4);
}
void NetBUFZ::dump_node(ostream&o, unsigned ind) const
{
o << setw(ind) << "" << "NetBUFZ: " << name()
- << " scope=" << (scope()? scope()->name() : "")
+ << " scope=" << scope_path(scope())
<< " delay=(" << rise_time() << "," << fall_time() << "," <<
decay_time() << ") width=" << width() << endl;
dump_node_pins(o, ind+4);
@@ -324,7 +343,7 @@ void NetConst::dump_node(ostream&o, unsigned ind) const
void NetFF::dump_node(ostream&o, unsigned ind) const
{
o << setw(ind) << "" << "LPM_FF: " << name()
- << " scope=" << (scope()? scope()->name() : "")
+ << " scope=" << scope_path(scope())
<< " aset_value=" << aset_value_ << endl;
dump_node_pins(o, ind+4);
@@ -399,7 +418,7 @@ void NetLogic::dump_node(ostream&o, unsigned ind) const
}
o << " #(" << rise_time()
<< "," << fall_time() << "," << decay_time() << ") " << name()
- << " scope=" << (scope()? scope()->name() : "")
+ << " scope=" << scope_path(scope())
<< endl;
dump_node_pins(o, ind+4);
@@ -478,7 +497,7 @@ void NetUReduce::dump_node(ostream&o, unsigned ind) const
}
o << " #(" << rise_time()
<< "," << fall_time() << "," << decay_time() << ") " << name()
- << " scope=" << (scope()? scope()->name() : "")
+ << " scope=" << scope_path(scope())
<< endl;
dump_node_pins(o, ind+4);
@@ -494,15 +513,15 @@ void NetSysFunc::dump_node(ostream&o, unsigned ind) const
void NetUserFunc::dump_node(ostream&o, unsigned ind) const
{
- o << setw(ind) << "" << def_->name() << "(";
+ o << setw(ind) << "" << scope_path(def_) << "(";
o << ")" << endl;
dump_node_pins(o, ind+4);
dump_obj_attr(o, ind+4);
}
void NetTaskDef::dump(ostream&o, unsigned ind) const
{
- o << setw(ind) << "" << "task " << name_ << ";" << endl;
+ o << setw(ind) << "" << "task " << scope_path(scope_) << ";" << endl;
for (unsigned idx = 0 ; idx < ports_.count() ; idx += 1) {
o << setw(ind+4) << "";
@@ -544,11 +563,11 @@ void NetProcTop::dump(ostream&o, unsigned ind) const
switch (type_) {
case NetProcTop::KINITIAL:
o << "initial /* " << get_line() << " in "
- << scope_->name() << " */" << endl;
+ << scope_path(scope_) << " */" << endl;
break;
case NetProcTop::KALWAYS:
o << "always /* " << get_line() << " in "
- << scope_->name() << " */" << endl;
+ << scope_path(scope_) << " */" << endl;
break;
}
@@ -630,7 +649,7 @@ void NetBlock::dump(ostream&o, unsigned ind) const
{
o << setw(ind) << "" << type_;
if (subscope_)
- o << " : " << subscope_->name();
+ o << " : " << scope_path(subscope_);
o << endl;
if (last_) {
@@ -707,7 +726,7 @@ void NetDeassign::dump(ostream&o, unsigned ind) const
void NetDisable::dump(ostream&o, unsigned ind) const
{
- o << setw(ind) << "" << "disable " << target_->name() << "; "
+ o << setw(ind) << "" << "disable " << scope_path(target_) << "; "
<< "/* " << get_line() << " */" << endl;
}
@@ -726,7 +745,7 @@ void NetEvProbe::dump_node(ostream&o, unsigned ind) const
o << "negedge ";
break;
}
- o << setw(ind) << "" << "-> " << event_->full_name() << "; " << endl;
+ o << setw(ind) << "" << "-> " << event_->name() << "; " << endl;
dump_node_pins(o, ind+4);
dump_obj_attr(o, ind+4);
}
@@ -742,10 +761,10 @@ void NetEvWait::dump(ostream&o, unsigned ind) const
o << setw(ind) <<"" << "@(";
if (nevents() > 0)
- o << event(0)->full_name();
+ o << event(0)->name();
for (unsigned idx = 1 ; idx < nevents() ; idx += 1)
- o << " or " << event(idx)->full_name();
+ o << " or " << event(idx)->name();
o << ") // " << get_line() << endl;
@@ -770,7 +789,7 @@ void NetForever::dump(ostream&o, unsigned ind) const
void NetFuncDef::dump(ostream&o, unsigned ind) const
{
- o << setw(ind) << "" << "function " << scope_->name() << endl;
+ o << setw(ind) << "" << "function " << scope_path(scope_) << endl;
if (result_sig_)
o << setw(ind+2) << "" << "Return signal: "
<< result_sig_->name() << endl;
@@ -813,7 +832,7 @@ void NetRepeat::dump(ostream&o, unsigned ind) const
void NetScope::dump(ostream&o) const
{
/* This is a constructed hierarchical name. */
- o << name();
+ o << scope_path(this);
switch (type_) {
case BEGIN_END:
@@ -882,7 +901,8 @@ void NetScope::dump(ostream&o) const
/* Dump the events in this scope. */
for (NetEvent*cur = events_ ; cur ; cur = cur->snext_) {
o << " event " << cur->name() << "; nprobe="
- << cur->nprobe() << " // " << cur->get_line() << endl;
+ << cur->nprobe() << " scope=" << scope_path(cur->scope())
+ << " // " << cur->get_line() << endl;
}
// Dump the signals,
@@ -956,7 +976,7 @@ void NetSTask::dump(ostream&o, unsigned ind) const
void NetUTask::dump(ostream&o, unsigned ind) const
{
- o << setw(ind) << "" << task_->name() << ";" << endl;
+ o << setw(ind) << "" << scope_path(task_) << ";" << endl;
}
void NetWhile::dump(ostream&o, unsigned ind) const
@@ -1091,7 +1111,7 @@ void NetEEvent::dump(ostream&o) const
void NetEScope::dump(ostream&o) const
{
- o << "<scope=" << scope_->name() << ">";
+ o << "<scope=" << scope_path(scope_) << ">";
}
void NetESelect::dump(ostream&o) const
@@ -1135,7 +1155,7 @@ void NetESignal::dump(ostream&o) const
void NetEParam::dump(ostream&o) const
{
if (scope_ != 0)
- o << "<" << scope_->name() << "." << name_ << ">";
+ o << "<" << scope_path(scope_) << "." << name_ << ">";
else if (name_)
o << "<" << name_ << ">";
else
@@ -1150,7 +1170,7 @@ void NetETernary::dump(ostream&o) const
void NetEUFunc::dump(ostream&o) const
{
- o << name() << "(";
+ o << func_->basename() << "(";
if (parms_.count() > 0) {
parms_[0]->dump(o);
for (unsigned idx = 1 ; idx < parms_.count() ; idx += 1) {
@@ -1205,6 +1225,9 @@ void Design::dump(ostream&o) const
/*
* $Log: design_dump.cc,v $
+ * Revision 1.176 2007/06/02 03:42:12 steve
+ * Properly evaluate scope path expressions.
+ *
* Revision 1.175 2007/05/24 04:07:11 steve
* Rework the heirarchical identifier parse syntax and pform
* to handle more general combinations of heirarch and bit selects.
View
23 elab_expr.cc
@@ -17,7 +17,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#ifdef HAVE_CVS_IDENT
-#ident "$Id: elab_expr.cc,v 1.125 2007/05/24 04:07:11 steve Exp $"
+#ident "$Id: elab_expr.cc,v 1.126 2007/06/02 03:42:12 steve Exp $"
#endif
# include "config.h"
@@ -474,7 +474,7 @@ NetExpr* PECallFunction::elaborate_expr(Design*des, NetScope*scope,
NetFuncDef*def = des->find_function(scope, path_);
if (def == 0) {
cerr << get_line() << ": error: No function " << path_ <<
- " in this context (" << scope->name() << ")." << endl;
+ " in this context (" << scope_path(scope) << ")." << endl;
des->errors += 1;
return 0;
}
@@ -538,7 +538,7 @@ NetExpr* PECallFunction::elaborate_expr(Design*des, NetScope*scope,
cerr << get_line() << ": internal error: Unable to locate "
"function return value for " << path_
- << " in " << def->name() << "." << endl;
+ << " in " << dscope->basename() << "." << endl;
des->errors += 1;
return 0;
}
@@ -830,30 +830,34 @@ NetExpr* PEIdent::elaborate_expr(Design*des, NetScope*scope,
// Finally, if this is a scope name, then return that. Look
// first to see if this is a name of a local scope. Failing
// that, search globally for a hierarchical name.
- if ((path_.size() == 1))
- if (NetScope*nsc = scope->child(peek_tail_name(path_))) {
+ if ((path_.size() == 1)) {
+ hname_t use_name ( peek_tail_name(path_) );
+ if (NetScope*nsc = scope->child(use_name)) {
NetEScope*tmp = new NetEScope(nsc);
tmp->set_line(*this);
return tmp;
}
+ }
+
+ list<hname_t> spath = eval_scope_path(des, scope, path_);
// Try full hierarchical scope name.
- if (NetScope*nsc = des->find_scope(path_)) {
+ if (NetScope*nsc = des->find_scope(spath)) {
NetEScope*tmp = new NetEScope(nsc);
tmp->set_line(*this);
return tmp;
}
// Try relative scope name.
- if (NetScope*nsc = des->find_scope(scope, path_)) {
+ if (NetScope*nsc = des->find_scope(scope, spath)) {
NetEScope*tmp = new NetEScope(nsc);
tmp->set_line(*this);
return tmp;
}
// I cannot interpret this identifier. Error message.
cerr << get_line() << ": error: Unable to bind wire/reg/memory "
- "`" << path_ << "' in `" << scope->name() << "'" << endl;
+ "`" << path_ << "' in `" << scope_path(scope) << "'" << endl;
des->errors += 1;
return 0;
}
@@ -1684,6 +1688,9 @@ NetExpr* PEUnary::elaborate_expr(Design*des, NetScope*scope,
/*
* $Log: elab_expr.cc,v $
+ * Revision 1.126 2007/06/02 03:42:12 steve
+ * Properly evaluate scope path expressions.
+ *
* Revision 1.125 2007/05/24 04:07:11 steve
* Rework the heirarchical identifier parse syntax and pform
* to handle more general combinations of heirarch and bit selects.
View
11 elab_lval.cc
@@ -17,7 +17,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#ifdef HAVE_CVS_IDENT
-#ident "$Id: elab_lval.cc,v 1.43 2007/05/24 04:07:11 steve Exp $"
+#ident "$Id: elab_lval.cc,v 1.44 2007/06/02 03:42:12 steve Exp $"
#endif
# include "config.h"
@@ -156,7 +156,7 @@ NetAssign_* PEIdent::elaborate_lval(Design*des,
symbol_search(des, scope, path_, reg, par, eve);
if (reg == 0) {
cerr << get_line() << ": error: Could not find variable ``"
- << path_ << "'' in ``" << scope->name() <<
+ << path_ << "'' in ``" << scope_path(scope) <<
"''" << endl;
des->errors += 1;
@@ -206,7 +206,7 @@ NetAssign_* PEIdent::elaborate_lval(Design*des,
unless this is the l-value of a force. */
if ((reg->type() != NetNet::REG) && !is_force) {
cerr << get_line() << ": error: " << path_ <<
- " is not a valid l-value in " << scope->name() <<
+ " is not a valid l-value in " << scope_path(scope) <<
"." << endl;
cerr << reg->get_line() << ": : " << path_ <<
" is declared here as " << reg->type() << "." << endl;
@@ -445,7 +445,7 @@ bool PEIdent::elaborate_lval_net_idx_up_(Design*des,
if (reg->type() != NetNet::REG) {
cerr << get_line() << ": error: " << path_ <<
- " is not a reg/integer/time in " << scope->name() <<
+ " is not a reg/integer/time in " << scope_path(scope) <<
"." << endl;
cerr << reg->get_line() << ": : " << path_ <<
" is declared here as " << reg->type() << "." << endl;
@@ -500,6 +500,9 @@ NetAssign_* PENumber::elaborate_lval(Design*des, NetScope*, bool) const
/*
* $Log: elab_lval.cc,v $
+ * Revision 1.44 2007/06/02 03:42:12 steve
+ * Properly evaluate scope path expressions.
+ *
* Revision 1.43 2007/05/24 04:07:11 steve
* Rework the heirarchical identifier parse syntax and pform
* to handle more general combinations of heirarch and bit selects.
View
24 elab_net.cc
@@ -17,7 +17,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#ifdef HAVE_CVS_IDENT
-#ident "$Id: elab_net.cc,v 1.204 2007/05/24 04:07:11 steve Exp $"
+#ident "$Id: elab_net.cc,v 1.205 2007/06/02 03:42:12 steve Exp $"
#endif
# include "config.h"
@@ -1240,7 +1240,7 @@ NetNet* PECallFunction::elaborate_net(Design*des, NetScope*scope,
NetFuncDef*def = des->find_function(scope, path_);
if (def == 0) {
cerr << get_line() << ": error: No function " << path_ <<
- " in this context (" << scope->name() << ")." << endl;
+ " in this context (" << scope_path(scope) << ")." << endl;
des->errors += 1;
return 0;
}
@@ -1657,12 +1657,13 @@ NetNet* PEIdent::elaborate_net(Design*des, NetScope*scope,
if (sig == 0 && path_.size() != 1) {
cerr << get_line() << ": error: The hierarchical name "
<< path_ << " is undefined in "
- << scope->name() << "." << endl;
+ << scope_path(scope) << "." << endl;
pform_name_t tmp_path = path_;
tmp_path.pop_back();
- NetScope*tmp_scope = des->find_scope(scope, tmp_path);
+ list<hname_t> stmp_path = eval_scope_path(des, scope, tmp_path);
+ NetScope*tmp_scope = des->find_scope(scope, stmp_path);
if (tmp_scope == 0) {
cerr << get_line() << ": : I can't even find "
<< "the scope " << tmp_path << "." << endl;
@@ -1681,13 +1682,13 @@ NetNet* PEIdent::elaborate_net(Design*des, NetScope*scope,
if (error_implicit || (nettype == NetNet::NONE)) {
cerr << get_line() << ": error: "
- << scope->name() << "." << name_tail.name
+ << scope_path(scope) << "." << name_tail.name
<< " not defined in this scope." << endl;
des->errors += 1;
} else if (warn_implicit) {
cerr << get_line() << ": warning: implicit "
- "definition of wire " << scope->name()
+ "definition of wire " << scope_path(scope)
<< "." << name_tail.name << "." << endl;
}
}
@@ -2032,7 +2033,7 @@ NetNet* PEIdent::make_implicit_net_(Design*des, NetScope*scope) const
if (warn_implicit) {
cerr << get_line() << ": warning: implicit "
- "definition of wire logic " << scope->name()
+ "definition of wire logic " << scope_path(scope)
<< "." << peek_tail_name(path_) << "." << endl;
}
@@ -2369,7 +2370,7 @@ NetNet* PEIdent::elaborate_port(Design*des, NetScope*scope) const
NetNet*sig = des->find_signal(scope, path_);
if (sig == 0) {
cerr << get_line() << ": error: no wire/reg " << path_
- << " in module " << scope->name() << "." << endl;
+ << " in module " << scope_path(scope) << "." << endl;
des->errors += 1;
return 0;
}
@@ -2388,7 +2389,7 @@ NetNet* PEIdent::elaborate_port(Design*des, NetScope*scope) const
case NetNet::NOT_A_PORT:
cerr << get_line() << ": error: signal " << path_ << " in"
- << " module " << scope->name() << " is not a port." << endl;
+ << " module " << scope_path(scope) << " is not a port." << endl;
cerr << get_line() << ": : Are you missing an input/"
<< "output/inout declaration?" << endl;
des->errors += 1;
@@ -2400,7 +2401,7 @@ NetNet* PEIdent::elaborate_port(Design*des, NetScope*scope) const
case NetNet::PIMPLICIT:
cerr << get_line() << ": internal error: signal " << path_
- << " in module " << scope->name() << " is left as "
+ << " in module " << scope_path(scope) << " is left as "
<< "port type PIMPLICIT." << endl;
des->errors += 1;
return 0;
@@ -2962,6 +2963,9 @@ NetNet* PEUnary::elaborate_net(Design*des, NetScope*scope,
/*
* $Log: elab_net.cc,v $
+ * Revision 1.205 2007/06/02 03:42:12 steve
+ * Properly evaluate scope path expressions.
+ *
* Revision 1.204 2007/05/24 04:07:11 steve
* Rework the heirarchical identifier parse syntax and pform
* to handle more general combinations of heirarch and bit selects.
View
14 elab_pexpr.cc
@@ -17,14 +17,15 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#ifdef HAVE_CVS_IDENT
-#ident "$Id: elab_pexpr.cc,v 1.27 2007/05/24 04:07:11 steve Exp $"
+#ident "$Id: elab_pexpr.cc,v 1.28 2007/06/02 03:42:12 steve Exp $"
#endif
# include "config.h"
# include "PExpr.h"
# include "compiler.h"
# include "util.h"
+# include "netmisc.h"
# include <iostream>
@@ -135,15 +136,17 @@ NetExpr*PEIdent::elaborate_pexpr(Design*des, NetScope*scope) const
path.pop_back();
NetScope*pscope = scope;
- if (path_.size() > 0)
- pscope = des->find_scope(scope, path);
+ if (path_.size() > 0) {
+ list<hname_t> tmp = eval_scope_path(des, scope, path);
+ pscope = des->find_scope(scope, tmp);
+ }
const NetExpr*ex_msb;
const NetExpr*ex_lsb;
const NetExpr*ex = pscope->get_parameter(name_tail.name, ex_msb, ex_lsb);
if (ex == 0) {
cerr << get_line() << ": error: identifier ``" << name_tail.name <<
- "'' is not a parameter in " << scope->name() << "." << endl;
+ "'' is not a parameter in "<< scope_path(scope)<< "." << endl;
des->errors += 1;
return 0;
}
@@ -240,6 +243,9 @@ NetExpr*PEUnary::elaborate_pexpr (Design*des, NetScope*scope) const
/*
* $Log: elab_pexpr.cc,v $
+ * Revision 1.28 2007/06/02 03:42:12 steve
+ * Properly evaluate scope path expressions.
+ *
* Revision 1.27 2007/05/24 04:07:11 steve
* Rework the heirarchical identifier parse syntax and pform
* to handle more general combinations of heirarch and bit selects.
View
38 elab_scope.cc
@@ -17,7 +17,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#ifdef HAVE_CVS_IDENT
-#ident "$Id: elab_scope.cc,v 1.45 2007/05/24 04:07:11 steve Exp $"
+#ident "$Id: elab_scope.cc,v 1.46 2007/06/02 03:42:12 steve Exp $"
#endif
# include "config.h"
@@ -51,7 +51,7 @@ bool Module::elaborate_scope(Design*des, NetScope*scope,
{
if (debug_scopes) {
cerr << get_line() << ": debug: Elaborate scope "
- << scope->name() << "." << endl;
+ << scope_path(scope) << "." << endl;
}
// Generate all the parameters that this instance of this
@@ -156,7 +156,7 @@ bool Module::elaborate_scope(Design*des, NetScope*scope,
if (! flag) {
cerr << val->get_line() << ": warning: parameter "
<< (*cur).first << " not found in "
- << scope->name() << "." << endl;
+ << scope_path(scope) << "." << endl;
}
}
@@ -243,7 +243,8 @@ bool Module::elaborate_scope(Design*des, NetScope*scope,
for (tasks_it_t cur = tasks_.begin()
; cur != tasks_.end() ; cur ++ ) {
- NetScope*task_scope = new NetScope(scope, (*cur).first,
+ hname_t use_name( (*cur).first );
+ NetScope*task_scope = new NetScope(scope, use_name,
NetScope::TASK);
(*cur).second->elaborate_scope(des, task_scope);
}
@@ -258,7 +259,8 @@ bool Module::elaborate_scope(Design*des, NetScope*scope,
for (funcs_it_t cur = funcs_.begin()
; cur != funcs_.end() ; cur ++ ) {
- NetScope*func_scope = new NetScope(scope, (*cur).first,
+ hname_t use_name( (*cur).first );
+ NetScope*func_scope = new NetScope(scope, use_name,
NetScope::FUNC);
(*cur).second->elaborate_scope(des, func_scope);
}
@@ -351,11 +353,7 @@ bool PGenerate::generate_scope_loop_(Design*des, NetScope*container)
// that each instance has a unique name in the
// container. The format of using [] is part of the
// Verilog standard.
- char name_buf[128];
- snprintf(name_buf, sizeof name_buf,
- "%s[%d]", scope_name.str(), genvar);
- perm_string use_name = lex_strings.make(name_buf);
-
+ hname_t use_name (scope_name, genvar);
if (debug_elaborate)
cerr << get_line() << ": debug: "
<< "Create generated scope " << use_name << endl;
@@ -431,7 +429,7 @@ void PGModule::elaborate_scope_mod_(Design*des, Module*mod, NetScope*sc) const
// about to create, and if I find it then somebody beat me to
// it.
- if (sc->child(get_name())) {
+ if (sc->child(hname_t(get_name()))) {
cerr << get_line() << ": error: Instance/Scope name " <<
get_name() << " already used in this context." <<
endl;
@@ -454,8 +452,8 @@ void PGModule::elaborate_scope_mod_(Design*des, Module*mod, NetScope*sc) const
<< "module " << mod->mod_name() << " within itself." << endl;
cerr << get_line() << ": : The offending instance is "
- << sc->name() << "." << get_name() << " within "
- << scn->name() << "." << endl;
+ << scope_path(sc) << "." << get_name() << " within "
+ << scope_path(scn) << "." << endl;
des->errors += 1;
return;
@@ -498,24 +496,21 @@ void PGModule::elaborate_scope_mod_(Design*des, Module*mod, NetScope*sc) const
// instantiation line.
for (int idx = 0 ; idx < instance_count ; idx += 1) {
- perm_string use_name = get_name();
+ hname_t use_name (get_name());
if (instance_array) {
- char name_buf[128];
int instance_idx = idx;
if (instance_low < instance_high)
instance_idx = instance_low + idx;
else
instance_idx = instance_low - idx;
- snprintf(name_buf, sizeof name_buf,
- "%s[%d]", get_name().str(), instance_idx);
- use_name = lex_strings.make(name_buf);
+ use_name = hname_t(get_name(), instance_idx);
}
if (debug_scopes) {
cerr << get_line() << ": debug: Module instance " << use_name
- << " becomes child of " << sc->name()
+ << " becomes child of " << scope_path(sc)
<< "." << endl;
}
@@ -652,7 +647,7 @@ void PBlock::elaborate_scope(Design*des, NetScope*scope) const
NetScope*my_scope = scope;
if (name_ != 0) {
- my_scope = new NetScope(scope, name_, bl_type_==BL_PAR
+ my_scope = new NetScope(scope, hname_t(name_), bl_type_==BL_PAR
? NetScope::FORK_JOIN
: NetScope::BEGIN_END);
}
@@ -761,6 +756,9 @@ void PWhile::elaborate_scope(Design*des, NetScope*scope) const
/*
* $Log: elab_scope.cc,v $
+ * Revision 1.46 2007/06/02 03:42:12 steve
+ * Properly evaluate scope path expressions.
+ *
* Revision 1.45 2007/05/24 04:07:11 steve
* Rework the heirarchical identifier parse syntax and pform
* to handle more general combinations of heirarch and bit selects.
View
37 elab_sig.cc
@@ -17,7 +17,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#ifdef HAVE_CVS_IDENT
-#ident "$Id: elab_sig.cc,v 1.51 2007/05/24 04:07:11 steve Exp $"
+#ident "$Id: elab_sig.cc,v 1.52 2007/06/02 03:42:12 steve Exp $"
#endif
# include "config.h"
@@ -208,11 +208,13 @@ bool Module::elaborate_sig(Design*des, NetScope*scope) const
for (mfunc_it_t cur = funcs_.begin()
; cur != funcs_.end() ; cur ++) {
- NetScope*fscope = scope->child((*cur).first);
+
+ hname_t use_name ( (*cur).first );
+ NetScope*fscope = scope->child(use_name);
if (scope == 0) {
cerr << (*cur).second->get_line() << ": internal error: "
<< "Child scope for function " << (*cur).first
- << " missing in " << scope->name() << "." << endl;
+ << " missing in " << scope_path(scope) << "." << endl;
des->errors += 1;
continue;
}
@@ -229,7 +231,7 @@ bool Module::elaborate_sig(Design*des, NetScope*scope) const
for (mtask_it_t cur = tasks_.begin()
; cur != tasks_.end() ; cur ++) {
- NetScope*tscope = scope->child((*cur).first);
+ NetScope*tscope = scope->child( hname_t((*cur).first) );
assert(tscope);
(*cur).second->elaborate_sig(des, tscope);
}
@@ -252,9 +254,9 @@ bool PGModule::elaborate_sig_mod_(Design*des, NetScope*scope,
if (my_scope->parent() != scope) {
cerr << get_line() << ": internal error: "
- << "Instance " << my_scope->name()
- << " is in parent " << my_scope->parent()->name()
- << " instead of " << scope->name()
+ << "Instance " << scope_path(my_scope)
+ << " is in parent " << scope_path(my_scope->parent())
+ << " instead of " << scope_path(scope)
<< endl;
}
assert(my_scope->parent() == scope);
@@ -277,7 +279,7 @@ bool PGenerate::elaborate_sig(Design*des) const
if (debug_elaborate)
cerr << get_line() << ": debug: Elaborate nets in "
- << "scope " << (*cur)->name() << endl;
+ << "scope " << scope_path(*cur) << endl;
flag = elaborate_sig_(des, *cur) & flag;
}
@@ -296,7 +298,7 @@ bool PGenerate::elaborate_sig_(Design*des, NetScope*scope) const
if (debug_elaborate)
cerr << get_line() << ": debug: Elaborate PWire "
- << cur->path() << " in scope " << scope->name() << endl;
+ << cur->path() << " in scope " << scope_path(scope) << endl;
cur->elaborate_sig(des, scope);
}
@@ -432,14 +434,14 @@ void PFunction::elaborate_sig(Design*des, NetScope*scope) const
cerr << get_line() << ": internal error: function "
<< "port " << (*ports_)[idx]->path()
<< " has wrong name for function "
- << scope->name() << "." << endl;
+ << scope_path(scope) << "." << endl;
des->errors += 1;
}
NetNet*tmp = scope->find_signal(pname);
if (tmp == 0) {
cerr << get_line() << ": internal error: function "
- << scope->name() << " is missing port "
+ << scope_path(scope) << " is missing port "
<< pname << "." << endl;
scope->dump(cerr);
cerr << get_line() << ": Continuing..." << endl;
@@ -497,14 +499,14 @@ void PTask::elaborate_sig(Design*des, NetScope*scope) const
if (tmp == 0) {
cerr << get_line() << ": internal error: "
<< "Could not find port " << port_name
- << " in scope " << scope->name() << endl;
+ << " in scope " << scope_path(scope) << endl;
scope->dump(cerr);
}
ports[idx] = tmp;
}
- NetTaskDef*def = new NetTaskDef(scope->name(), ports);
+ NetTaskDef*def = new NetTaskDef(scope, ports);
scope->set_task_def(def);
}
@@ -532,7 +534,7 @@ NetNet* PWire::elaborate_sig(Design*des, NetScope*scope) const
name_component_t cur = tmp_path.front();
tmp_path.pop_front();
- scope = scope->child(cur.name);
+ scope = scope->child( hname_t(cur.name) );
if (scope == 0) {
cerr << get_line() << ": internal error: "
@@ -727,7 +729,7 @@ NetNet* PWire::elaborate_sig(Design*des, NetScope*scope) const
if (debug_elaborate) {
cerr << get_line() << ": debug: Create signal "
<< wtype << " ["<<msb<<":"<<lsb<<"] " << name
- << " in scope " << scope->name() << endl;
+ << " in scope " << scope_path(scope) << endl;
}
@@ -741,7 +743,7 @@ NetNet* PWire::elaborate_sig(Design*des, NetScope*scope) const
if (debug_elaborate) {
cerr << get_line() << ": debug: "
<< "Signal " << name
- << " in scope " << scope->name()
+ << " in scope " << scope_path(scope)
<< " defaults to data type " << use_data_type << endl;
}
}
@@ -763,6 +765,9 @@ NetNet* PWire::elaborate_sig(Design*des, NetScope*scope) const
/*
* $Log: elab_sig.cc,v $
+ * Revision 1.52 2007/06/02 03:42:12 steve
+ * Properly evaluate scope path expressions.
+ *
* Revision 1.51 2007/05/24 04:07:11 steve
* Rework the heirarchical identifier parse syntax and pform
* to handle more general combinations of heirarch and bit selects.
View
34 elaborate.cc
@@ -17,7 +17,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#ifdef HAVE_CVS_IDENT
-#ident "$Id: elaborate.cc,v 1.371 2007/05/24 04:07:11 steve Exp $"
+#ident "$Id: elaborate.cc,v 1.372 2007/06/02 03:42:12 steve Exp $"
#endif
# include "config.h"
@@ -651,7 +651,7 @@ void PGModule::elaborate_mod_(Design*des, Module*rmod, NetScope*scope) const
if (debug_elaborate) {
cerr << get_line() << ": debug: Instantiate module "
<< rmod->mod_name() << " with instance name "
- << get_name() << " in scope " << scope->name() << endl;
+ << get_name() << " in scope " << scope_path(scope) << endl;
}
// This is the array of pin expressions, shuffled to match the
@@ -1495,7 +1495,6 @@ NetProc* PAssign::elaborate(Design*des, NetScope*scope) const
NetESignal*sig = new NetESignal(tmp);
/* Generate an assignment of the l-value to the temporary... */
- string n = scope->local_hsymbol();
NetAssign_*lvt = new NetAssign_(tmp);
NetAssign*a1 = new NetAssign(lvt, rv);
@@ -1618,10 +1617,10 @@ NetProc* PBlock::elaborate(Design*des, NetScope*scope) const
NetScope*nscope = 0;
if (name_.str() != 0) {
- nscope = scope->child(name_);
+ nscope = scope->child(hname_t(name_));
if (nscope == 0) {
cerr << get_line() << ": internal error: "
- "unable to find block scope " << scope->name()
+ "unable to find block scope " << scope_path(scope)
<< "<" << name_ << ">" << endl;
des->errors += 1;
return 0;
@@ -1927,7 +1926,7 @@ NetProc* PCallTask::elaborate_usr(Design*des, NetScope*scope) const
NetTaskDef*def = task->task_def();
if (def == 0) {
cerr << get_line() << ": internal error: task " << path_
- << " doesn't have a definition in " << scope->name()
+ << " doesn't have a definition in " << scope_path(scope)
<< "." << endl;
des->errors += 1;
return 0;
@@ -2138,10 +2137,12 @@ NetProc* PDisable::elaborate(Design*des, NetScope*scope) const
{
assert(scope);
- NetScope*target = des->find_scope(scope, scope_);
+ list<hname_t> spath = eval_scope_path(des, scope, scope_);
+
+ NetScope*target = des->find_scope(scope, spath);
if (target == 0) {
cerr << get_line() << ": error: Cannot find scope "
- << scope_ << " in " << scope->name() << endl;
+ << scope_ << " in " << scope_path(scope) << endl;
des->errors += 1;
return 0;
}
@@ -2758,7 +2759,7 @@ void PFunction::elaborate(Design*des, NetScope*scope) const
if (def == 0) {
cerr << get_line() << ": internal error: "
<< "No function definition for function "
- << scope->name() << endl;
+ << scope_path(scope) << endl;
return;
}
@@ -2767,7 +2768,7 @@ void PFunction::elaborate(Design*des, NetScope*scope) const
NetProc*st = statement_->elaborate(des, scope);
if (st == 0) {
cerr << statement_->get_line() << ": error: Unable to elaborate "
- "statement in function " << def->name() << "." << endl;
+ "statement in function " << scope->basename() << "." << endl;
des->errors += 1;
return;
}
@@ -2868,7 +2869,7 @@ void PTask::elaborate(Design*des, NetScope*task) const
st = statement_->elaborate(des, task);
if (st == 0) {
cerr << statement_->get_line() << ": Unable to elaborate "
- "statement in task " << task->name()
+ "statement in task " << scope_path(task)
<< " at " << get_line() << "." << endl;
return;
}
@@ -3226,7 +3227,8 @@ bool Module::elaborate(Design*des, NetScope*scope) const
for (mfunc_it_t cur = funcs_.begin()
; cur != funcs_.end() ; cur ++) {
- NetScope*fscope = scope->child((*cur).first);
+ hname_t use_name ( (*cur).first );
+ NetScope*fscope = scope->child(use_name);
assert(fscope);
(*cur).second->elaborate(des, fscope);
}
@@ -3238,7 +3240,8 @@ bool Module::elaborate(Design*des, NetScope*scope) const
for (mtask_it_t cur = tasks_.begin()
; cur != tasks_.end() ; cur ++) {
- NetScope*tscope = scope->child((*cur).first);
+ hname_t use_name ( (*cur).first );
+ NetScope*tscope = scope->child(use_name);
assert(tscope);
(*cur).second->elaborate(des, tscope);
}
@@ -3287,7 +3290,7 @@ bool PGenerate::elaborate(Design*des) const
if (debug_elaborate)
cerr << get_line() << ": debug: Elaborate in "
- << "scope " << (*cur)->name() << endl;
+ << "scope " << scope_path(*cur) << endl;
flag = elaborate_(des, *cur) & flag;
}
@@ -3417,6 +3420,9 @@ Design* elaborate(list<perm_string>roots)
/*
* $Log: elaborate.cc,v $
+ * Revision 1.372 2007/06/02 03:42:12 steve
+ * Properly evaluate scope path expressions.
+ *
* Revision 1.371 2007/05/24 04:07:11 steve
* Rework the heirarchical identifier parse syntax and pform
* to handle more general combinations of heirarch and bit selects.
View
7 eval_tree.cc
@@ -17,7 +17,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#ifdef HAVE_CVS_IDENT
-#ident "$Id: eval_tree.cc,v 1.76 2007/05/31 18:36:06 steve Exp $"
+#ident "$Id: eval_tree.cc,v 1.77 2007/06/02 03:42:12 steve Exp $"
#endif
# include "config.h"
@@ -1212,7 +1212,7 @@ NetExpr* NetEParam::eval_tree(int prune_to_width)
if (expr == 0) {
cerr << get_line() << ": internal error: Unable to match "
<< "parameter " << name_ << " in scope "
- << scope_->name() << endl;
+ << scope_path(scope_) << endl;
return 0;
}
@@ -1655,6 +1655,9 @@ NetEConst* NetEUReduce::eval_tree(int prune_to_width)
/*
* $Log: eval_tree.cc,v $
+ * Revision 1.77 2007/06/02 03:42:12 steve
+ * Properly evaluate scope path expressions.
+ *
* Revision 1.76 2007/05/31 18:36:06 steve
* Fix warning (ldolittle)
*
View
6 expr_synth.cc
@@ -17,7 +17,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#ifdef HAVE_CVS_IDENT
-#ident "$Id: expr_synth.cc,v 1.86 2007/04/15 01:37:29 steve Exp $"
+#ident "$Id: expr_synth.cc,v 1.87 2007/06/02 03:42:12 steve Exp $"
#endif
# include "config.h"
@@ -92,7 +92,6 @@ NetNet* NetEBBits::synthesize(Design*des)
NetScope*scope = lsig->scope();
assert(scope);
- string path = des->local_symbol(scope->name());
if (lsig->vector_width() != rsig->vector_width()) {
cerr << get_line() << ": internal error: bitwise (" << op_
@@ -871,6 +870,9 @@ NetNet* NetESignal::synthesize(Design*des)
/*
* $Log: expr_synth.cc,v $
+ * Revision 1.87 2007/06/02 03:42:12 steve
+ * Properly evaluate scope path expressions.
+ *
* Revision 1.86 2007/04/15 01:37:29 steve
* Allow bit/part select of vectors in continuous assignments.
*
View
68 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.52 2007/05/24 04:07:12 steve Exp $"
+#ident "$Id: net_design.cc,v 1.53 2007/06/02 03:42:13 steve Exp $"
#endif
# include "config.h"
@@ -32,6 +32,7 @@
# include "netlist.h"
# include "util.h"
# include "compiler.h"
+# include "netmisc.h"
# include <sstream>
Design:: Design()
@@ -84,7 +85,7 @@ uint64_t Design::scale_to_precision(uint64_t val,
NetScope* Design::make_root_scope(perm_string root)
{
NetScope *root_scope_;
- root_scope_ = new NetScope(0, root, NetScope::MODULE);
+ root_scope_ = new NetScope(0, hname_t(root), NetScope::MODULE);
/* This relies on the fact that the basename return value is
permallocated. */
root_scope_->set_module_name(root_scope_->basename());
@@ -114,7 +115,7 @@ const list<NetScope*> Design::find_root_scopes() const
* more step down the tree until the name runs out or the search
* fails.
*/
-NetScope* Design::find_scope(const pform_name_t&path) const
+NetScope* Design::find_scope(const std::list<hname_t>&path) const
{
if (path.empty())
return 0;
@@ -123,17 +124,16 @@ NetScope* Design::find_scope(const pform_name_t&path) const
; scope != root_scopes_.end(); scope++) {
NetScope*cur = *scope;
- if (strcmp(peek_head_name(path), cur->basename()) != 0)
+ if (path.front() != cur->fullname())
continue;
- pform_name_t tmp = path;
+ std::list<hname_t> tmp = path;
tmp.pop_front();
while (cur) {
if (tmp.empty()) return cur;
- perm_string name = peek_head_name(tmp);
- cur = cur->child(name);
+ cur = cur->child( tmp.front() );
tmp.pop_front();
}
@@ -149,27 +149,23 @@ NetScope* Design::find_scope(const pform_name_t&path) const
* I do not find the scope within the passed scope, start looking in
* parent scopes until I find it, or I run out of parent scopes.
*/
-NetScope* Design::find_scope(NetScope*scope, const pform_name_t&path) const
+NetScope* Design::find_scope(NetScope*scope, const std::list<hname_t>&path) const
{
assert(scope);
if (path.empty())
return scope;
for ( ; scope ; scope = scope->parent()) {
- pform_name_t tmp = path;
- name_component_t name_front = tmp.front();
- perm_string key = name_front.name;
+ std::list<hname_t> tmp = path;
NetScope*cur = scope;
do {
- cur = cur->child(key);
+ hname_t key = tmp.front();
+ cur = cur->child( key );
if (cur == 0) break;
tmp.pop_front();
- if (tmp.empty()) break;
- name_front = tmp.front();
- key = name_front.name;
- } while (key);
+ } while (!tmp.empty());
if (cur) return cur;
}
@@ -209,9 +205,11 @@ void NetScope::run_defparams(Design*des)
perm_string perm_name = peek_tail_name(path);
path.pop_back();
+ list<hname_t> eval_path = eval_scope_path(des, this, path);
+
/* If there is no path on the name, then the targ_scope
is the current scope. */
- NetScope*targ_scope = des->find_scope(this, path);
+ NetScope*targ_scope = des->find_scope(this, eval_path);
if (targ_scope == 0) {
cerr << val->get_line() << ": warning: scope of " <<
path << "." << perm_name << " not found." << endl;
@@ -222,7 +220,7 @@ void NetScope::run_defparams(Design*des)
if (! flag) {
cerr << val->get_line() << ": warning: parameter "
<< perm_name << " not found in "
- << targ_scope->name() << "." << endl;
+ << scope_path(targ_scope) << "." << endl;
}
}
@@ -435,8 +433,10 @@ NetNet* Design::find_signal(NetScope*scope, pform_name_t path)
perm_string key = peek_tail_name(path);
path.pop_back();
- if (! path.empty())
- scope = find_scope(scope, path);
+ if (! path.empty()) {
+ list<hname_t> eval_path = eval_scope_path(this, scope, path);
+ scope = find_scope(scope, eval_path);
+ }
while (scope) {
if (NetNet*net = scope->find_signal(key))
@@ -454,16 +454,9 @@ NetNet* Design::find_signal(NetScope*scope, pform_name_t path)
NetFuncDef* Design::find_function(NetScope*scope, const pform_name_t&name)
{
assert(scope);
- NetScope*func = find_scope(scope, name);
- if (func && (func->type() == NetScope::FUNC))
- return func->func_def();
- return 0;
-}
-
-NetFuncDef* Design::find_function(const pform_name_t&key)
-{
- NetScope*func = find_scope(key);
+ std::list<hname_t> eval_path = eval_scope_path(this, scope, name);
+ NetScope*func = find_scope(scope, eval_path);
if (func && (func->type() == NetScope::FUNC))
return func->func_def();
@@ -472,24 +465,14 @@ NetFuncDef* Design::find_function(const pform_name_t&key)
NetScope* Design::find_task(NetScope*scope, const pform_name_t&name)
{
- NetScope*task = find_scope(scope, name);
- if (task && (task->type() == NetScope::TASK))
- return task;
-
- return 0;
-}
-
-NetScope* Design::find_task(const pform_name_t&key)
-{
- NetScope*task = find_scope(key);
+ std::list<hname_t> eval_path = eval_scope_path(this, scope, name);
+ NetScope*task = find_scope(scope, eval_path);
if (task && (task->type() == NetScope::TASK))
return task;
return 0;
}
-
-
void Design::add_node(NetNode*net)
{
assert(net->design_ == 0);
@@ -565,6 +548,9 @@ void Design::delete_process(NetProcTop*top)
/*
* $Log: net_design.cc,v $
+ * Revision 1.53 2007/06/02 03:42:13 steve
+ * Properly evaluate scope path expressions.
+ *
* Revision 1.52 2007/05/24 04:07:12 steve
* Rework the heirarchical identifier parse syntax and pform
* to handle more general combinations of heirarch and bit selects.
View
9 net_event.cc
@@ -17,7 +17,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#ifdef HAVE_CVS_IDENT
-#ident "$Id: net_event.cc,v 1.26 2004/10/04 01:10:54 steve Exp $"
+#ident "$Id: net_event.cc,v 1.27 2007/06/02 03:42:13 steve Exp $"
#endif
# include "config.h"
@@ -56,10 +56,10 @@ perm_string NetEvent::name() const
return name_;
}
-string NetEvent::full_name() const
+NetScope* NetEvent::scope()
{
assert(scope_);
- return scope_->name() + "." + string(name_);
+ return scope_;
}
const NetScope* NetEvent::scope() const
@@ -449,6 +449,9 @@ NetProc* NetEvWait::statement()
/*
* $Log: net_event.cc,v $
+ * Revision 1.27 2007/06/02 03:42:13 steve
+ * Properly evaluate scope path expressions.
+ *
* Revision 1.26 2004/10/04 01:10:54 steve
* Clean up spurious trailing white space.
*
View
9 net_func.cc
@@ -17,7 +17,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#ifdef HAVE_CVS_IDENT
-#ident "$Id: net_func.cc,v 1.9 2007/04/17 04:17:47 steve Exp $"
+#ident "$Id: net_func.cc,v 1.10 2007/06/02 03:42:13 steve Exp $"
#endif
# include "config.h"
@@ -95,13 +95,13 @@ bool PECallFunction::check_call_matches_definition_(Design*des, NetScope*dscope)
if (dscope->type() != NetScope::FUNC) {
cerr << get_line() << ": error: Attempt to call scope "
- << dscope->name() << " as a function." << endl;
+ << scope_path(dscope) << " as a function." << endl;
des->errors += 1;
return false;
}
if (parms_count != dscope->func_def()->port_count()) {
- cerr << get_line() << ": error: Function " << dscope->name()
+ cerr << get_line() << ": error: Function " << scope_path(dscope)
<< " expects " << (dscope->func_def()->port_count())
<< " arguments, you passed " << parms_count << "."
<< endl;
@@ -149,6 +149,9 @@ unsigned NetSysFunc::vector_width() const
/*
* $Log: net_func.cc,v $
+ * Revision 1.10 2007/06/02 03:42:13 steve
+ * Properly evaluate scope path expressions.
+ *
* Revision 1.9 2007/04/17 04:17:47 steve
* Fix argument count in function error message.
*
View
7 net_link.cc
@@ -17,7 +17,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#ifdef HAVE_CVS_IDENT
-#ident "$Id: net_link.cc,v 1.20 2007/03/26 18:17:50 steve Exp $"
+#ident "$Id: net_link.cc,v 1.21 2007/06/02 03:42:13 steve Exp $"
#endif
# include "config.h"
@@ -391,7 +391,7 @@ const char* Nexus::name() const
}
assert(sig);
ostringstream tmp;
- tmp << sig->scope()->name() << "." << sig->name();
+ tmp << scope_path(sig->scope()) << "." << sig->name();
if (sig->pin_count() > 1)
tmp << "<" << pin << ">";
@@ -525,6 +525,9 @@ bool NexusSet::intersect(const NexusSet&that) const
/*
* $Log: net_link.cc,v $
+ * Revision 1.21 2007/06/02 03:42:13 steve
+ * Properly evaluate scope path expressions.
+ *
* Revision 1.20 2007/03/26 18:17:50 steve
* Remove pretense of general use for t_cookie.
*
View
29 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.37 2007/04/26 03:06:22 steve Exp $"
+#ident "$Id: net_scope.cc,v 1.38 2007/06/02 03:42:13 steve Exp $"
#endif
# include "config.h"
@@ -35,7 +35,7 @@
* in question.
*/
-NetScope::NetScope(NetScope*up, perm_string n, NetScope::TYPE t)
+NetScope::NetScope(NetScope*up, const hname_t&n, NetScope::TYPE t)
: type_(t), up_(up), sib_(0), sub_(0)
{
signals_ = 0;
@@ -241,15 +241,7 @@ NetNet::Type NetScope::default_nettype() const
perm_string NetScope::basename() const
{
- return name_;
-}
-
-string NetScope::name() const
-{
- if (up_)
- return up_->name() + "." + string(name_);
- else
- return string(name_);
+ return name_.peek_name();
}
void NetScope::add_event(NetEvent*ev)
@@ -340,25 +332,25 @@ NetNet* NetScope::find_signal(const char*key)
* This method locates a child scope by name. The name is the simple
* name of the child, no hierarchy is searched.
*/
-NetScope* NetScope::child(const char*name)
+NetScope* NetScope::child(const hname_t&name)
{
if (sub_ == 0) return 0;
NetScope*cur = sub_;
- while (strcmp(cur->name_, name) != 0) {
+ while (cur->name_ != name) {
if (cur->sib_ == 0) return 0;
cur = cur->sib_;
}
return cur;
}
-const NetScope* NetScope::child(const char*name) const
+const NetScope* NetScope::child(const hname_t&name) const
{
if (sub_ == 0) return 0;
NetScope*cur = sub_;
- while (strcmp(cur->name_, name) != 0) {
+ while (cur->name_ != name) {
if (cur->sib_ == 0) return 0;
cur = cur->sib_;
}
@@ -382,15 +374,18 @@ perm_string NetScope::local_symbol()
res << "_s" << (lcounter_++);
return lex_strings.make(res.str());
}
-
+#if 0
string NetScope::local_hsymbol()
{
return string(name()) + "." + string(local_symbol());
}
-
+#endif
/*
* $Log: net_scope.cc,v $
+ * Revision 1.38 2007/06/02 03:42:13 steve
+ * Properly evaluate scope path expressions.
+ *
* Revision 1.37 2007/04/26 03:06:22 steve
* Rework hname_t to use perm_strings.
*
View
31 netlist.cc
@@ -17,7 +17,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#ifdef HAVE_CVS_IDENT
-#ident "$Id: netlist.cc,v 1.257 2007/04/02 01:12:34 steve Exp $"
+#ident "$Id: netlist.cc,v 1.258 2007/06/02 03:42:13 steve Exp $"
#endif
# include "config.h"
@@ -1770,11 +1770,16 @@ NetFuncDef::NetFuncDef(NetScope*s, NetNet*result, const svector<NetNet*>&po)
NetFuncDef::~NetFuncDef()
{
}
-
+#if 0
const string NetFuncDef::name() const
{
return scope_->name();
}
+#endif
+const NetScope* NetFuncDef::scope() const
+{
+ return scope_;
+}
void NetFuncDef::set_proc(NetProc*st)
{
@@ -1850,12 +1855,12 @@ NetEUFunc::~NetEUFunc()
for (unsigned idx = 0 ; idx < parms_.count() ; idx += 1)
delete parms_[idx];
}
-
+#if 0
const string NetEUFunc::name() const
{
return func_->name();
}
-
+#endif
const NetESignal*NetEUFunc::result_sig() const
{
return result_sig_;
@@ -1893,12 +1898,12 @@ NetUTask::NetUTask(NetScope*def)
NetUTask::~NetUTask()
{
}
-
+#if 0
const string NetUTask::name() const
{
return task_->name();
}
-
+#endif
const NetScope* NetUTask::task() const
{
return task_;
@@ -2286,8 +2291,8 @@ unsigned NetUReduce::width() const
return width_;
}
-NetTaskDef::NetTaskDef(const string&n, const svector<NetNet*>&po)
-: name_(n), proc_(0), ports_(po)
+NetTaskDef::NetTaskDef(NetScope*n, const svector<NetNet*>&po)
+: scope_(n), proc_(0), ports_(po)
{
}
@@ -2312,11 +2317,16 @@ NetNet* NetTaskDef::port(unsigned idx)
assert(idx < ports_.count());
return ports_[idx];
}
-
+#if 0
const string& NetTaskDef::name() const
{
return name_;
}
+#endif
+const NetScope* NetTaskDef::scope() const
+{
+ return scope_;
+}
const NetProc*NetTaskDef::proc() const
{