From c7d97f4146af277ebfb389d1e9f21836734bf6dc Mon Sep 17 00:00:00 2001 From: steve Date: Sat, 2 Jun 2007 03:42:12 +0000 Subject: [PATCH] Properly evaluate scope path expressions. --- HName.cc | 243 ++++++++++------------------------------------- HName.h | 58 +++++------ PGenerate.cc | 3 +- PGenerate.h | 7 +- design_dump.cc | 71 +++++++++----- elab_expr.cc | 23 +++-- elab_lval.cc | 11 ++- elab_net.cc | 24 +++-- elab_pexpr.cc | 14 ++- elab_scope.cc | 38 ++++---- elab_sig.cc | 37 ++++---- elaborate.cc | 34 ++++--- eval_tree.cc | 7 +- expr_synth.cc | 6 +- net_design.cc | 68 ++++++------- net_event.cc | 9 +- net_func.cc | 9 +- net_link.cc | 7 +- net_scope.cc | 29 +++--- netlist.cc | 31 ++++-- netlist.h | 52 ++++++---- netmisc.cc | 70 +++++++------- netmisc.h | 12 ++- pform.cc | 16 +++- pform_dump.cc | 22 +++-- symbol_search.cc | 16 +++- t-dll-proc.cc | 9 +- t-dll.cc | 103 +++++++++++++------- t-dll.h | 6 +- target.cc | 7 +- 30 files changed, 520 insertions(+), 522 deletions(-) diff --git a/HName.cc b/HName.cc index 3ccac5319..891eb541e 100644 --- a/HName.cc +++ b/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 #endif -inline perm_string& hname_t::item_ref1_() -{ - return *reinterpret_cast(item_); -} - -inline const perm_string& hname_t::item_ref1_() const -{ - return *reinterpret_cast(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(perm_string text, int num) +{ + name_ = text; + number_ = num; } hname_t::hname_t(const hname_t&that) { - 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_ = that.name_; + number_ = that.number_; +} + +hname_t& hname_t::operator = (const hname_t&that) +{ + name_ = that.name_; + number_ = that.number_; + return *this; } hname_t::~hname_t() { - switch (count_) { - case 0: - break; - case 1: - item_ref1_().~perm_string(); - break; - default: - delete[]array_; - break; - } } -unsigned hname_t::component_count() const +perm_string hname_t::peek_name(void) const { - return count_; + return name_; } -void hname_t::append(perm_string text) +bool hname_t::has_number() 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] = 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; - } + return number_ != INT_MIN; } -void hname_t::prepend(perm_string text) +int hname_t::peek_number() 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; - } -} - -perm_string hname_t::remove_tail_name() -{ - 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; -} - -perm_string hname_t::peek_name(unsigned idx) 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]; - - return out; } + + out << that.peek_name(); + if (that.has_number()) + out << "[" << that.peek_number() << "]"; + + 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. * diff --git a/HName.h b/HName.h index 6a754fddf..c436eeaf6 100644 --- a/HName.h +++ b/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 @@ -31,8 +31,11 @@ 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 { @@ -40,53 +43,38 @@ 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); + hname_t& operator= (const hname_t&); - // 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); + // Return the string part of the hname_t. + perm_string peek_name(void) const; - // 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; - - // Return the number of components in the hierarchical - // name. If this is a simple name, this will return 1. - unsigned component_count() 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. * diff --git a/PGenerate.cc b/PGenerate.cc index 26b7dbff4..aa9b597fe 100644 --- a/PGenerate.cc +++ b/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() diff --git a/PGenerate.h b/PGenerate.h index 13232b6ea..010c3793a 100644 --- a/PGenerate.h +++ b/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 behaviors; void add_behavior(PProcess*behave); + list 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); diff --git a/design_dump.cc b/design_dump.cc index 0286031f1..37a1c8156 100644 --- a/design_dump.cc +++ b/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,7 +307,7 @@ 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); } @@ -296,7 +315,7 @@ void NetMux::dump_node(ostream&o, unsigned ind) const 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,7 +513,7 @@ 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); @@ -502,7 +521,7 @@ void NetUserFunc::dump_node(ostream&o, unsigned ind) const 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 << "name() << ">"; + o << ""; } 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. diff --git a/elab_expr.cc b/elab_expr.cc index f320730e4..3e730dfec 100644 --- a/elab_expr.cc +++ b/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,22 +830,26 @@ 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 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; @@ -853,7 +857,7 @@ NetExpr* PEIdent::elaborate_expr(Design*des, NetScope*scope, // 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. diff --git a/elab_lval.cc b/elab_lval.cc index 2225c14ba..0591b225b 100644 --- a/elab_lval.cc +++ b/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. diff --git a/elab_net.cc b/elab_net.cc index 0a8d3247d..5dc2be4c9 100644 --- a/elab_net.cc +++ b/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 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. diff --git a/elab_pexpr.cc b/elab_pexpr.cc index 8f71778ec..19d589b18 100644 --- a/elab_pexpr.cc +++ b/elab_pexpr.cc @@ -17,7 +17,7 @@ * 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" @@ -25,6 +25,7 @@ # include "PExpr.h" # include "compiler.h" # include "util.h" +# include "netmisc.h" # include @@ -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 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. diff --git a/elab_scope.cc b/elab_scope.cc index a31bc495e..6288e6028 100644 --- a/elab_scope.cc +++ b/elab_scope.cc @@ -17,7 +17,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ #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. diff --git a/elab_sig.cc b/elab_sig.cc index fc1a07297..1d85de367 100644 --- a/elab_sig.cc +++ b/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 << " ["<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. diff --git a/elaborate.cc b/elaborate.cc index b55bb91db..99a57587f 100644 --- a/elaborate.cc +++ b/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 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(listroots) /* * $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. diff --git a/eval_tree.cc b/eval_tree.cc index 894660551..1dae172a4 100644 --- a/eval_tree.cc +++ b/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) * diff --git a/expr_synth.cc b/expr_synth.cc index 7fee02418..ed2c0a3c3 100644 --- a/expr_synth.cc +++ b/expr_synth.cc @@ -17,7 +17,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ #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. * diff --git a/net_design.cc b/net_design.cc index e2b865386..8f3b3d2f2 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.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 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 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&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 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,7 +149,7 @@ 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&path) const { assert(scope); if (path.empty()) @@ -157,19 +157,15 @@ NetScope* Design::find_scope(NetScope*scope, const pform_name_t&path) const 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 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 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 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 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); + std::list 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; } -NetScope* Design::find_task(const pform_name_t&key) -{ - NetScope*task = find_scope(key); - 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. diff --git a/net_event.cc b/net_event.cc index 3d1504628..a214cdd48 100644 --- a/net_event.cc +++ b/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. * diff --git a/net_func.cc b/net_func.cc index 69794cbf7..b1091107b 100644 --- a/net_func.cc +++ b/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. * diff --git a/net_link.cc b/net_link.cc index ed414cd55..a6275a68f 100644 --- a/net_link.cc +++ b/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. * diff --git a/net_scope.cc b/net_scope.cc index f32a0e144..18c5dab90 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.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,12 +332,12 @@ 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_; } @@ -353,12 +345,12 @@ NetScope* NetScope::child(const char*name) 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. * diff --git a/netlist.cc b/netlist.cc index b8e68b441..17cfc9f76 100644 --- a/netlist.cc +++ b/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&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&po) -: name_(n), proc_(0), ports_(po) +NetTaskDef::NetTaskDef(NetScope*n, const svector&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 { @@ -2325,6 +2335,9 @@ const NetProc*NetTaskDef::proc() const /* * $Log: netlist.cc,v $ + * Revision 1.258 2007/06/02 03:42:13 steve + * Properly evaluate scope path expressions. + * * Revision 1.257 2007/04/02 01:12:34 steve * Seperate arrayness from word count * diff --git a/netlist.h b/netlist.h index e635e1494..c6b23b631 100644 --- a/netlist.h +++ b/netlist.h @@ -19,7 +19,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ #ifdef HAVE_CVS_IDENT -#ident "$Id: netlist.h,v 1.379 2007/05/24 04:07:12 steve Exp $" +#ident "$Id: netlist.h,v 1.380 2007/06/02 03:42:13 steve Exp $" #endif /* @@ -2060,7 +2060,6 @@ class NetEvent : public LineInfo { ~NetEvent(); perm_string name() const; - string full_name() const; // Get information about probes connected to me. unsigned nprobe() const; @@ -2267,8 +2266,9 @@ class NetFuncDef { void set_proc(NetProc*st); - const string name() const; + //const string name() const; const NetProc*proc() const; + const NetScope*scope() const; NetScope*scope(); unsigned port_count() const; @@ -2406,12 +2406,13 @@ class NetSTask : public NetProc { class NetTaskDef { public: - NetTaskDef(const string&n, const svector&po); + NetTaskDef(NetScope*n, const svector&po); ~NetTaskDef(); void set_proc(NetProc*p); - const string& name() const; + //const string& name() const; + const NetScope* scope() const; const NetProc*proc() const; unsigned port_count() const; @@ -2420,7 +2421,7 @@ class NetTaskDef { void dump(ostream&, unsigned) const; private: - string name_; + NetScope*scope_; NetProc*proc_; svectorports_; @@ -2437,11 +2438,9 @@ class NetTaskDef { class NetEUFunc : public NetExpr { public: - NetEUFunc(NetScope*, NetESignal*, svector&); + NetEUFunc(NetScope*, NetESignal*, svector&); ~NetEUFunc(); - const string name() const; - const NetESignal*result_sig() const; unsigned parm_count() const; @@ -3183,7 +3182,7 @@ class NetScope : public Attrib { /* Create a new scope, and attach it to the given parent. The name is expected to have been permallocated. */ - NetScope(NetScope*up, perm_string name, TYPE t); + NetScope(NetScope*up, const hname_t&name, TYPE t); ~NetScope(); /* Parameters exist within a scope, and these methods allow @@ -3226,9 +3225,9 @@ class NetScope : public Attrib { /* The parent and child() methods allow users of NetScope objects to locate nearby scopes. */ NetScope* parent(); - NetScope* child(const char*name); + NetScope* child(const hname_t&name); const NetScope* parent() const; - const NetScope* child(const char*name) const; + const NetScope* child(const hname_t&name) const; TYPE type() const; @@ -3267,7 +3266,7 @@ class NetScope : public Attrib { name, whereas the basename is just my name within my parent scope. */ perm_string basename() const; - string name() const; + const hname_t& fullname() const { return name_; } void run_defparams(class Design*); void evaluate_parameters(class Design*); @@ -3275,9 +3274,6 @@ class NetScope : public Attrib { /* This method generates a non-hierarchical name that is guaranteed to be unique within this scope. */ perm_string local_symbol(); - /* This method generates a hierarchical name that is - guaranteed to be unique globally. */ - string local_hsymbol(); void dump(ostream&) const; void emit_scope(struct target_t*tgt) const; @@ -3328,7 +3324,7 @@ class NetScope : public Attrib { private: TYPE type_; - perm_string name_; + hname_t name_; signed char time_unit_, time_prec_; NetNet::Type default_nettype_; @@ -3392,8 +3388,8 @@ class Design { path is taken as an absolute scope name. Otherwise, the scope is located starting at the passed scope and working up if needed. */ - NetScope* find_scope(const pform_name_t&path) const; - NetScope* find_scope(NetScope*, const pform_name_t&path) const; + NetScope* find_scope(const std::list&path) const; + NetScope* find_scope(NetScope*, const std::list&path) const; // PARAMETERS @@ -3409,11 +3405,9 @@ class Design { // Functions NetFuncDef* find_function(NetScope*scope, const pform_name_t&key); - NetFuncDef* find_function(const pform_name_t&path); // Tasks NetScope* find_task(NetScope*scope, const pform_name_t&name); - NetScope* find_task(const pform_name_t&key); // NODES void add_node(NetNode*); @@ -3499,8 +3493,24 @@ inline ostream& operator << (ostream&o, const NetExpr&exp) extern ostream& operator << (ostream&, NetNet::Type); +/* + * Manipulator to dump a scope complete path to the output. The + * manipulator is "scope_path" and works like this: + * + * out << .... << scope_path(sc) << ... ; + */ +struct __ScopePathManip { const NetScope*scope; }; +inline __ScopePathManip scope_path(const NetScope*scope) +{ __ScopePathManip tmp; tmp.scope = scope; return tmp; } + +extern ostream& operator << (ostream&o, __ScopePathManip); + + /* * $Log: netlist.h,v $ + * Revision 1.380 2007/06/02 03:42:13 steve + * Properly evaluate scope path expressions. + * * Revision 1.379 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. diff --git a/netmisc.cc b/netmisc.cc index fc9083fda..ac84cb993 100644 --- a/netmisc.cc +++ b/netmisc.cc @@ -17,7 +17,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ #ifdef HAVE_CVS_IDENT -#ident "$Id: netmisc.cc,v 1.13 2007/03/08 05:30:03 steve Exp $" +#ident "$Id: netmisc.cc,v 1.14 2007/06/02 03:42:13 steve Exp $" #endif # include "config.h" @@ -25,6 +25,8 @@ # include "netlist.h" # include "netmisc.h" # include "PExpr.h" +# include "pform_types.h" +# include "ivl_assert.h" NetNet* add_to_net(Design*des, NetNet*sig, long val) { @@ -138,9 +140,44 @@ NetExpr* elab_and_eval(Design*des, NetScope*scope, return tmp; } +std::list eval_scope_path(Design*des, NetScope*scope, + const pform_name_t&path) +{ + list res; + + typedef pform_name_t::const_iterator pform_path_it; + + for (pform_path_it cur = path.begin() ; cur != path.end(); cur++) { + const name_component_t&comp = *cur; + if (comp.index.empty()) { + res.push_back(hname_t(comp.name)); + continue; + } + + assert(comp.index.size() == 1); + const index_component_t&index = comp.index.front(); + assert(index.sel == index_component_t::SEL_BIT); + + NetExpr*tmp = elab_and_eval(des, scope, index.msb, -1); + ivl_assert(*index.msb, tmp); + + if (NetEConst*ctmp = dynamic_cast(tmp)) { + res.push_back(hname_t(comp.name, ctmp->value().as_long())); + delete ctmp; + continue; + } + + return res; + } + + return res; +} /* * $Log: netmisc.cc,v $ + * Revision 1.14 2007/06/02 03:42:13 steve + * Properly evaluate scope path expressions. + * * Revision 1.13 2007/03/08 05:30:03 steve * Limit the calculated widths of constants. * @@ -156,36 +193,5 @@ NetExpr* elab_and_eval(Design*des, NetScope*scope, * Remove the NetEBitSel and combine all bit/part select * behavior into the NetESelect node and IVL_EX_SELECT * ivl_target expression type. - * - * Revision 1.9 2004/12/11 02:31:27 steve - * Rework of internals to carry vectors through nexus instead - * of single bits. Make the ivl, tgt-vvp and vvp initial changes - * down this path. - * - * Revision 1.8 2004/02/20 18:53:35 steve - * Addtrbute keys are perm_strings. - * - * Revision 1.7 2004/02/18 17:11:57 steve - * Use perm_strings for named langiage items. - * - * Revision 1.6 2003/03/06 00:28:42 steve - * All NetObj objects have lex_string base names. - * - * Revision 1.5 2003/02/26 01:29:24 steve - * LPM objects store only their base names. - * - * Revision 1.4 2002/08/31 03:48:50 steve - * Fix reverse bit ordered bit select in continuous assignment. - * - * Revision 1.3 2002/08/12 01:35:00 steve - * conditional ident string using autoconfig. - * - * Revision 1.2 2001/07/25 03:10:49 steve - * Create a config.h.in file to hold all the config - * junk, and support gcc 3.0. (Stephan Boettcher) - * - * Revision 1.1 2001/02/11 02:15:52 steve - * Add the netmisc.cc source file. - * */ diff --git a/netmisc.h b/netmisc.h index 416f8de39..caa5ed702 100644 --- a/netmisc.h +++ b/netmisc.h @@ -19,7 +19,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ #ifdef HAVE_CVS_IDENT -#ident "$Id: netmisc.h,v 1.30 2007/05/24 04:07:12 steve Exp $" +#ident "$Id: netmisc.h,v 1.31 2007/06/02 03:42:13 steve Exp $" #endif # include "netlist.h" @@ -39,14 +39,14 @@ * ex2 is the lsb expression for the range. If there is no range, then * these values are set to 0. */ -extern NetScope* symbol_search(const Design*des, +extern NetScope* symbol_search(Design*des, NetScope*start, pform_name_t path, NetNet*&net, /* net/reg */ const NetExpr*&par,/* parameter */ NetEvent*&eve, /* named event */ const NetExpr*&ex1, const NetExpr*&ex2); -inline NetScope* symbol_search(const Design*des, +inline NetScope* symbol_search(Design*des, NetScope*start, const pform_name_t&path, NetNet*&net, /* net/reg */ const NetExpr*&par,/* parameter */ @@ -123,8 +123,14 @@ extern NetExpr* elab_and_eval(Design*des, NetScope*scope, const PExpr*pe, int expr_wid, int prune_width =-1); +extern std::list eval_scope_path(Design*des, NetScope*scope, + const pform_name_t&path); + /* * $Log: netmisc.h,v $ + * Revision 1.31 2007/06/02 03:42:13 steve + * Properly evaluate scope path expressions. + * * Revision 1.30 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. diff --git a/pform.cc b/pform.cc index cf23bf6cc..ea45f8f2a 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.146 2007/05/24 04:07:12 steve Exp $" +#ident "$Id: pform.cc,v 1.147 2007/06/02 03:42:13 steve Exp $" #endif # include "config.h" @@ -348,7 +348,7 @@ void pform_start_generate_for(const struct vlltype&li, gen->set_lineno(li.first_line); // For now, assume that generates do not nest. - assert(pform_cur_generate == 0); + gen->parent = pform_cur_generate; pform_cur_generate = gen; pform_cur_generate->scheme_type = PGenerate::GS_LOOP; @@ -375,8 +375,13 @@ void pform_endgenerate() assert(pform_cur_generate != 0); assert(pform_cur_module); - pform_cur_module->generate_schemes.push_back(pform_cur_generate); - pform_cur_generate = 0; + PGenerate*cur = pform_cur_generate; + pform_cur_generate = cur->parent; + + if (pform_cur_generate != 0) + pform_cur_generate->generates.push_back(cur); + else + pform_cur_module->generate_schemes.push_back(cur); } bool pform_expression_is_constant(const PExpr*ex) @@ -1773,6 +1778,9 @@ int pform_parse(const char*path, FILE*file) /* * $Log: pform.cc,v $ + * Revision 1.147 2007/06/02 03:42:13 steve + * Properly evaluate scope path expressions. + * * Revision 1.146 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. diff --git a/pform_dump.cc b/pform_dump.cc index 8ef98ba81..f18fcf7e3 100644 --- a/pform_dump.cc +++ b/pform_dump.cc @@ -17,7 +17,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ #ifdef HAVE_CVS_IDENT -#ident "$Id: pform_dump.cc,v 1.99 2007/05/31 18:35:50 steve Exp $" +#ident "$Id: pform_dump.cc,v 1.100 2007/06/02 03:42:13 steve Exp $" #endif # include "config.h" @@ -817,9 +817,9 @@ void PSpecPath::dump(std::ostream&out, unsigned ind) const out << ");" << endl; } -void PGenerate::dump(ostream&out) const +void PGenerate::dump(ostream&out, unsigned indent) const { - out << " generate(" << id_number << ")"; + out << setw(indent) << "" << "generate(" << id_number << ")"; switch (scheme_type) { case GS_NONE: @@ -844,17 +844,22 @@ void PGenerate::dump(ostream&out) const for (map::const_iterator idx = wires.begin() ; idx != wires.end() ; idx++) { - (*idx).second->dump(out, 6); + (*idx).second->dump(out, indent+2); } for (list::const_iterator idx = gates.begin() ; idx != gates.end() ; idx++) { - (*idx)->dump(out, 6); + (*idx)->dump(out, indent+2); } for (list::const_iterator idx = behaviors.begin() ; idx != behaviors.end() ; idx++) { - (*idx)->dump(out, 6); + (*idx)->dump(out, indent+2); + } + + for (list::const_iterator idx = generates.begin() + ; idx != generates.end() ; idx++) { + (*idx)->dump(out, indent+2); } out << " endgenerate" << endl; @@ -934,7 +939,7 @@ void Module::dump(ostream&out) const typedef list::const_iterator genscheme_iter_t; for (genscheme_iter_t cur = generate_schemes.begin() ; cur != generate_schemes.end() ; cur++) { - (*cur)->dump(out); + (*cur)->dump(out, 4); } typedef map::const_iterator specparm_iter_t; @@ -1062,6 +1067,9 @@ void PUdp::dump(ostream&out) const /* * $Log: pform_dump.cc,v $ + * Revision 1.100 2007/06/02 03:42:13 steve + * Properly evaluate scope path expressions. + * * Revision 1.99 2007/05/31 18:35:50 steve * Missing return value to perm_string dump * diff --git a/symbol_search.cc b/symbol_search.cc index 1d75e5712..399b2c65a 100644 --- a/symbol_search.cc +++ b/symbol_search.cc @@ -17,17 +17,18 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ #ifdef HAVE_CVS_IDENT -#ident "$Id: symbol_search.cc,v 1.6 2007/05/24 04:07:12 steve Exp $" +#ident "$Id: symbol_search.cc,v 1.7 2007/06/02 03:42:13 steve Exp $" #endif # include "netlist.h" +# include "netmisc.h" # include /* * Search for the hierarchical name. */ -NetScope*symbol_search(const Design*des, NetScope*scope, pform_name_t path, +NetScope*symbol_search(Design*des, NetScope*scope, pform_name_t path, NetNet*&net, const NetExpr*&par, NetEvent*&eve, @@ -46,8 +47,11 @@ NetScope*symbol_search(const Design*des, NetScope*scope, pform_name_t path, /* If the path has a scope part, then search for the specified scope that we are supposed to search. */ - if (! path.empty()) - scope = des->find_scope(scope, path); + if (! path.empty()) { + list path_list = eval_scope_path(des, scope, path); + assert(path_list.size() == path.size()); + scope = des->find_scope(scope, path_list); + } while (scope) { if ( (net = scope->find_signal(key)) ) @@ -68,8 +72,12 @@ NetScope*symbol_search(const Design*des, NetScope*scope, pform_name_t path, return 0; } + /* * $Log: symbol_search.cc,v $ + * Revision 1.7 2007/06/02 03:42:13 steve + * Properly evaluate scope path expressions. + * * Revision 1.6 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. diff --git a/t-dll-proc.cc b/t-dll-proc.cc index 6381e04d2..1632aadd8 100644 --- a/t-dll-proc.cc +++ b/t-dll-proc.cc @@ -18,7 +18,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ #ifdef HAVE_CVS_IDENT -#ident "$Id: t-dll-proc.cc,v 1.70 2007/04/04 01:50:38 steve Exp $" +#ident "$Id: t-dll-proc.cc,v 1.71 2007/06/02 03:42:13 steve Exp $" #endif # include "config.h" @@ -131,7 +131,7 @@ bool dll_target::func_def(const NetScope*net) } cerr << "?:0" << ": internal error: " - << "Function " << net->name() << " has a return type" + << "Function " << net->basename() << " has a return type" << " that I do not understand." << endl; return false; @@ -641,6 +641,8 @@ bool dll_target::proc_wait(const NetEvWait*net) ivl_scope_t ev_scope = lookup_scope_(ev->scope()); ivl_event_t ev_tmp=0; + assert(ev_scope); + assert(ev_scope->nevent_ > 0); for (unsigned idx = 0 ; idx < ev_scope->nevent_ ; idx += 1) { const char*ename = ivl_event_basename(ev_scope->event_[idx]); if (strcmp(ev->name(), ename) == 0) { @@ -735,6 +737,9 @@ void dll_target::proc_while(const NetWhile*net) /* * $Log: t-dll-proc.cc,v $ + * Revision 1.71 2007/06/02 03:42:13 steve + * Properly evaluate scope path expressions. + * * Revision 1.70 2007/04/04 01:50:38 steve * t-dll should not canonicalize word addresses, elaboration already does it. * diff --git a/t-dll.cc b/t-dll.cc index 515836405..9cb116445 100644 --- a/t-dll.cc +++ b/t-dll.cc @@ -17,7 +17,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ #ifdef HAVE_CVS_IDENT -#ident "$Id: t-dll.cc,v 1.170 2007/04/02 01:12:34 steve Exp $" +#ident "$Id: t-dll.cc,v 1.171 2007/06/02 03:42:13 steve Exp $" #endif # include "config.h" @@ -134,6 +134,17 @@ inline static const char *basename(ivl_scope_t scope, const char *inst) return inst+1; } +static perm_string make_scope_name(const hname_t&name) +{ + if (! name.has_number()) + return name.peek_name(); + + char buf[1024]; + snprintf(buf, sizeof buf, "%s[%d]", + name.peek_name().str(), name.peek_number()); + return lex_strings.make(buf); +} + static struct dll_target dll_target_obj; static void drive_from_link(const Link&lnk, ivl_drive_t&drv0, ivl_drive_t&drv1) @@ -212,6 +223,7 @@ ivl_attribute_s* dll_target::fill_in_attributes(const Attrib*net) static ivl_scope_t find_scope_from_root(ivl_scope_t root, const NetScope*cur) { ivl_scope_t parent, tmp; + perm_string cur_name = make_scope_name(cur->fullname()); if (const NetScope*par = cur->parent()) { parent = find_scope_from_root(root, par); @@ -219,11 +231,11 @@ static ivl_scope_t find_scope_from_root(ivl_scope_t root, const NetScope*cur) return 0; for (tmp = parent->child_ ; tmp ; tmp = tmp->sibling_) - if (strcmp(tmp->name_, cur->basename()) == 0) + if (strcmp(tmp->name_, cur_name) == 0) return tmp; } else { - if (strcmp(root->name_, cur->basename()) == 0) + if (strcmp(root->name_, cur_name) == 0) return root; } @@ -442,7 +454,7 @@ ivl_parameter_t dll_target::scope_find_param(ivl_scope_t scope, */ void dll_target::make_scope_parameters(ivl_scope_t scope, const NetScope*net) { - scope->nparam_ = net->parameters.size(); + scope->nparam_ = net->parameters.size() + net->localparams.size(); if (scope->nparam_ == 0) { scope->param_ = 0; return; @@ -462,37 +474,52 @@ void dll_target::make_scope_parameters(ivl_scope_t scope, const NetScope*net) cur_par->scope = scope; NetExpr*etmp = (*cur_pit).second.expr; - - if (const NetEConst*e = dynamic_cast(etmp)) { - - expr_const(e); - assert(expr_); - - switch (expr_->type_) { - case IVL_EX_STRING: - expr_->u_.string_.parameter = cur_par; - break; - case IVL_EX_NUMBER: - expr_->u_.number_.parameter = cur_par; - break; - default: - assert(0); - } - - } else if (const NetECReal*e = dynamic_cast(etmp)) { - - expr_creal(e); - assert(expr_); - assert(expr_->type_ == IVL_EX_REALNUM); - expr_->u_.real_.parameter = cur_par; - - } - - cur_par->value = expr_; - expr_ = 0; - + make_scope_param_expr(cur_par, etmp); idx += 1; } + for (pit_t cur_pit = net->localparams.begin() + ; cur_pit != net->localparams.end() ; cur_pit ++) { + + assert(idx < scope->nparam_); + ivl_parameter_t cur_par = scope->param_ + idx; + cur_par->basename = (*cur_pit).first; + cur_par->scope = scope; + + NetExpr*etmp = (*cur_pit).second.expr; + make_scope_param_expr(cur_par, etmp); + idx += 1; + } +} + +void dll_target::make_scope_param_expr(ivl_parameter_t cur_par, NetExpr*etmp) +{ + if (const NetEConst*e = dynamic_cast(etmp)) { + + expr_const(e); + assert(expr_); + + switch (expr_->type_) { + case IVL_EX_STRING: + expr_->u_.string_.parameter = cur_par; + break; + case IVL_EX_NUMBER: + expr_->u_.number_.parameter = cur_par; + break; + default: + assert(0); + } + + } else if (const NetECReal*e = dynamic_cast(etmp)) { + + expr_creal(e); + assert(expr_); + assert(expr_->type_ == IVL_EX_REALNUM); + expr_->u_.real_.parameter = cur_par; + + } + + cur_par->value = expr_; + expr_ = 0; } void dll_target::add_root(ivl_design_s &des_, const NetScope *s) @@ -1951,8 +1978,9 @@ void dll_target::scope(const NetScope*net) assert(scope); } else { + perm_string sname = make_scope_name(net->fullname()); scope = new struct ivl_scope_s; - scope->name_ = net->basename(); + scope->name_ = sname; scope->child_ = 0; scope->sibling_ = 0; scope->parent = find_scope(des_, net->parent()); @@ -1985,12 +2013,12 @@ void dll_target::scope(const NetScope*net) } assert(def); scope->type_ = IVL_SCT_TASK; - scope->tname_ = strings_.make(def->name().c_str()); + scope->tname_ = def->scope()->basename(); break; } case NetScope::FUNC: scope->type_ = IVL_SCT_FUNCTION; - scope->tname_ = strings_.make(net->func_def()->name().c_str()); + scope->tname_ = net->func_def()->scope()->basename(); break; case NetScope::BEGIN_END: scope->type_ = IVL_SCT_BEGIN; @@ -2227,6 +2255,9 @@ extern const struct target tgt_dll = { "dll", &dll_target_obj }; /* * $Log: t-dll.cc,v $ + * Revision 1.171 2007/06/02 03:42:13 steve + * Properly evaluate scope path expressions. + * * Revision 1.170 2007/04/02 01:12:34 steve * Seperate arrayness from word count * diff --git a/t-dll.h b/t-dll.h index 8afd862b7..7f1e4c86e 100644 --- a/t-dll.h +++ b/t-dll.h @@ -19,7 +19,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ #ifdef HAVE_CVS_IDENT -#ident "$Id: t-dll.h,v 1.142 2007/04/02 01:12:34 steve Exp $" +#ident "$Id: t-dll.h,v 1.143 2007/06/02 03:42:13 steve Exp $" #endif # include "target.h" @@ -165,6 +165,7 @@ struct dll_target : public target_t, public expr_scan_t { void make_logic_delays_(struct ivl_net_logic_s*obj, const NetObj*net); void make_scope_parameters(ivl_scope_t scope, const NetScope*net); + void make_scope_param_expr(ivl_parameter_t cur_par, NetExpr*etmp); static ivl_expr_t expr_from_value_(const verinum&that); }; @@ -679,6 +680,9 @@ struct ivl_statement_s { /* * $Log: t-dll.h,v $ + * Revision 1.143 2007/06/02 03:42:13 steve + * Properly evaluate scope path expressions. + * * Revision 1.142 2007/04/02 01:12:34 steve * Seperate arrayness from word count * diff --git a/target.cc b/target.cc index 9a6f6678f..674ff156a 100644 --- a/target.cc +++ b/target.cc @@ -17,7 +17,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ #ifdef HAVE_CVS_IDENT -#ident "$Id: target.cc,v 1.80 2007/01/16 05:44:16 steve Exp $" +#ident "$Id: target.cc,v 1.81 2007/06/02 03:42:13 steve Exp $" #endif # include "config.h" @@ -38,7 +38,7 @@ void target_t::scope(const NetScope*) void target_t::event(const NetEvent*ev) { cerr << ev->get_line() << ": error: target (" << typeid(*this).name() - << "): Unhandled event <" << ev->full_name() << ">." << endl; + << "): Unhandled event <" << ev->name() << ">." << endl; } bool target_t::signal_paths(const NetNet*) @@ -429,6 +429,9 @@ void expr_scan_t::expr_binary(const NetEBinary*ex) /* * $Log: target.cc,v $ + * Revision 1.81 2007/06/02 03:42:13 steve + * Properly evaluate scope path expressions. + * * Revision 1.80 2007/01/16 05:44:16 steve * Major rework of array handling. Memories are replaced with the * more general concept of arrays. The NetMemory and NetEMemory