Properly evaluate scope path expressions.

This commit is contained in:
steve 2007-06-02 03:42:12 +00:00
parent 1f9a246c6d
commit c7d97f4146
30 changed files with 520 additions and 522 deletions

243
HName.cc
View File

@ -17,7 +17,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/ */
#ifdef HAVE_CVS_IDENT #ifdef HAVE_CVS_IDENT
#ident "$Id: HName.cc,v 1.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 #endif
# include "config.h" # include "config.h"
@ -29,244 +29,101 @@
# include <malloc.h> # include <malloc.h>
#endif #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() hname_t::hname_t()
{ {
count_ = 0; number_ = INT_MIN;
} }
hname_t::hname_t(perm_string text) hname_t::hname_t(perm_string text)
{ {
new (item_) perm_string(text); name_ = text;
count_ = 1; number_ = INT_MIN;
}
hname_t::hname_t(perm_string text, int num)
{
name_ = text;
number_ = num;
} }
hname_t::hname_t(const hname_t&that) hname_t::hname_t(const hname_t&that)
{ {
count_ = that.count_; name_ = that.name_;
switch (count_) { number_ = that.number_;
case 0: }
break;
case 1: hname_t& hname_t::operator = (const hname_t&that)
new(item_) perm_string (that.item_ref1_()); {
break; name_ = that.name_;
default: number_ = that.number_;
array_ = new perm_string[count_]; return *this;
for (unsigned idx = 0 ; idx < count_ ; idx += 1)
array_[idx] = that.array_[idx];
break;
}
} }
hname_t::~hname_t() 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; return number_ != INT_MIN;
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) int hname_t::peek_number() const
{ {
perm_string*tmp; return number_;
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];
}
} }
bool operator < (const hname_t&l, const hname_t&r) bool operator < (const hname_t&l, const hname_t&r)
{ {
unsigned idx = 0; int cmp = strcmp(l.peek_name(), r.peek_name());
const char*lc = l.peek_name(idx); if (cmp < 0) return true;
const char*rc = r.peek_name(idx); if (cmp > 0) return false;
if (l.has_number() && r.has_number())
while (lc && rc) { return l.peek_number() < r.peek_number();
int cmp = strcmp(lc, rc); else
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)
return false; return false;
if (rc && !lc)
return true;
// Must be ==
return false;
} }
bool operator == (const hname_t&l, const hname_t&r) bool operator == (const hname_t&l, const hname_t&r)
{ {
unsigned idx = 0; if (l.peek_name() == r.peek_name()) {
const char*lc = l.peek_name(idx); if (l.has_number() && r.has_number())
const char*rc = r.peek_name(idx); return l.peek_number() == r.peek_number();
else
while (lc && rc) { return true;
int cmp = strcmp(lc, rc);
if (cmp != 0)
return false;
idx += 1;
lc = l.peek_name(idx);
rc = r.peek_name(idx);
} }
if (lc || rc) return false;
return false;
// Must be ==
return true;
} }
bool operator != (const hname_t&l, const hname_t&r)
{ return ! (l==r); }
ostream& operator<< (ostream&out, const hname_t&that) ostream& operator<< (ostream&out, const hname_t&that)
{ {
switch (that.count_) { if (that.peek_name() == 0) {
case 0:
out << ""; out << "";
return 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 $ * $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 * Revision 1.7 2007/05/16 19:12:33 steve
* Fix hname_t use of space for 1 perm_string. * Fix hname_t use of space for 1 perm_string.
* *

58
HName.h
View File

@ -1,7 +1,7 @@
#ifndef __HName_H #ifndef __HName_H
#define __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 * This source code is free software; you can redistribute it
* and/or modify it in source code form under the terms of the GNU * and/or modify it in source code form under the terms of the GNU
@ -19,7 +19,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/ */
#ifdef HAVE_CVS_IDENT #ifdef HAVE_CVS_IDENT
#ident "$Id: 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 #endif
# include <iostream> # include <iostream>
@ -31,8 +31,11 @@ using namespace std;
#endif #endif
/* /*
* This class represents a Verilog hierarchical name. A hierarchical * This class represents a component of a Verilog hierarchical name. A
* name is an ordered list of simple names. * 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 { class hname_t {
@ -40,53 +43,38 @@ class hname_t {
public: public:
hname_t (); hname_t ();
explicit hname_t (perm_string text); explicit hname_t (perm_string text);
explicit hname_t (perm_string text, int num);
hname_t (const hname_t&that); hname_t (const hname_t&that);
~hname_t(); ~hname_t();
// This method adds a name to the end of the hierarchical hname_t& operator= (const hname_t&);
// path. This becomes a new base name.
void append(perm_string text);
// This method adds a name to the *front* of the hierarchical // Return the string part of the hname_t.
// path. The base name remains the same, unless this is the perm_string peek_name(void) const;
// only component.
void prepend(perm_string text);
// This method removes the tail name from the hierarchy, and bool has_number() const;
// returns a pointer to that tail name. That tail name now int peek_number() const;
// 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&);
private: private:
union { perm_string name_;
perm_string*array_; // If the number is anything other then INT_MIN, then this is
char item_[sizeof(perm_string)]; // the numeric part of the name. Otherwise, it is not part of
}; // the name at all.
unsigned count_; int number_;
perm_string& item_ref1_();
const perm_string& item_ref1_() const;
private: // not implemented 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 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 $ * $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 * Revision 1.6 2007/05/16 19:12:33 steve
* Fix hname_t use of space for 1 perm_string. * Fix hname_t use of space for 1 perm_string.
* *

View File

@ -17,7 +17,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/ */
#ifdef HAVE_CVS_IDENT #ifdef HAVE_CVS_IDENT
#ident "$Id: 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 #endif
# include "PGenerate.h" # include "PGenerate.h"
@ -26,6 +26,7 @@
PGenerate::PGenerate(unsigned id) PGenerate::PGenerate(unsigned id)
: id_number(id) : id_number(id)
{ {
parent = 0;
} }
PGenerate::~PGenerate() PGenerate::~PGenerate()

View File

@ -19,7 +19,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/ */
#ifdef HAVE_CVS_IDENT #ifdef HAVE_CVS_IDENT
#ident "$Id: 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 #endif
# include "LineInfo.h" # include "LineInfo.h"
@ -70,6 +70,9 @@ class PGenerate : public LineInfo {
list<PProcess*> behaviors; list<PProcess*> behaviors;
void add_behavior(PProcess*behave); void add_behavior(PProcess*behave);
list<PGenerate*> generates;
PGenerate*parent;
// This method is called by the elaboration of a module to // This method is called by the elaboration of a module to
// generate scopes. the container is the scope that is to // generate scopes. the container is the scope that is to
// contain the generated scope. // contain the generated scope.
@ -78,7 +81,7 @@ class PGenerate : public LineInfo {
bool elaborate_sig(Design*des) const; bool elaborate_sig(Design*des) const;
bool elaborate(Design*des) const; bool elaborate(Design*des) const;
void dump(ostream&out) const; void dump(ostream&out, unsigned indent) const;
private: private:
bool generate_scope_loop_(Design*des, NetScope*container); bool generate_scope_loop_(Design*des, NetScope*container);

View File

@ -17,7 +17,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/ */
#ifdef HAVE_CVS_IDENT #ifdef HAVE_CVS_IDENT
#ident "$Id: 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 #endif
# include "config.h" # include "config.h"
@ -91,6 +91,25 @@ ostream& operator << (ostream&o, ivl_variable_type_t val)
return o; 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 void NetDelaySrc::dump(ostream&o, unsigned ind) const
{ {
o << setw(ind) << "" << "specify delay"; 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() << ")"; o << " (eref=" << peek_eref() << ", lref=" << peek_lref() << ")";
if (scope()) if (scope())
o << " scope=" << scope()->name(); o << " scope=" << scope_path(scope());
o << " #(" << rise_time() << "," << fall_time() << "," o << " #(" << rise_time() << "," << fall_time() << ","
<< decay_time() << ") vector_width=" << vector_width() << decay_time() << ") vector_width=" << vector_width()
<< " pin_count=" << pin_count() << " pin_count=" << pin_count()
@ -264,7 +283,7 @@ void NetConcat::dump_node(ostream&o, unsigned ind) const
{ {
o << setw(ind) << "" << "NetConcat: " o << setw(ind) << "" << "NetConcat: "
<< name() << name()
<< " scope=" << (scope()? scope()->name() : "") << " scope=" << scope_path(scope())
<< " width=" << width_ << endl; << " width=" << width_ << endl;
dump_node_pins(o, ind+4); dump_node_pins(o, ind+4);
dump_obj_attr(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() o << setw(ind) << "" << "Multiplexer (NetMux): " << name()
<< " width=" << width_ << " swidth=" << swidth_ << " size=" << size_ << " width=" << width_ << " swidth=" << swidth_ << " size=" << size_
<< " scope=" << scope()->name() << endl; << " scope=" << scope_path(scope()) << endl;
dump_node_pins(o, ind+4); dump_node_pins(o, ind+4);
dump_obj_attr(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 void NetBUFZ::dump_node(ostream&o, unsigned ind) const
{ {
o << setw(ind) << "" << "NetBUFZ: " << name() o << setw(ind) << "" << "NetBUFZ: " << name()
<< " scope=" << (scope()? scope()->name() : "") << " scope=" << scope_path(scope())
<< " delay=(" << rise_time() << "," << fall_time() << "," << << " delay=(" << rise_time() << "," << fall_time() << "," <<
decay_time() << ") width=" << width() << endl; decay_time() << ") width=" << width() << endl;
dump_node_pins(o, ind+4); 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 void NetFF::dump_node(ostream&o, unsigned ind) const
{ {
o << setw(ind) << "" << "LPM_FF: " << name() o << setw(ind) << "" << "LPM_FF: " << name()
<< " scope=" << (scope()? scope()->name() : "") << " scope=" << scope_path(scope())
<< " aset_value=" << aset_value_ << endl; << " aset_value=" << aset_value_ << endl;
dump_node_pins(o, ind+4); dump_node_pins(o, ind+4);
@ -399,7 +418,7 @@ void NetLogic::dump_node(ostream&o, unsigned ind) const
} }
o << " #(" << rise_time() o << " #(" << rise_time()
<< "," << fall_time() << "," << decay_time() << ") " << name() << "," << fall_time() << "," << decay_time() << ") " << name()
<< " scope=" << (scope()? scope()->name() : "") << " scope=" << scope_path(scope())
<< endl; << endl;
dump_node_pins(o, ind+4); dump_node_pins(o, ind+4);
@ -478,7 +497,7 @@ void NetUReduce::dump_node(ostream&o, unsigned ind) const
} }
o << " #(" << rise_time() o << " #(" << rise_time()
<< "," << fall_time() << "," << decay_time() << ") " << name() << "," << fall_time() << "," << decay_time() << ") " << name()
<< " scope=" << (scope()? scope()->name() : "") << " scope=" << scope_path(scope())
<< endl; << endl;
dump_node_pins(o, ind+4); 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 void NetUserFunc::dump_node(ostream&o, unsigned ind) const
{ {
o << setw(ind) << "" << def_->name() << "("; o << setw(ind) << "" << scope_path(def_) << "(";
o << ")" << endl; o << ")" << endl;
dump_node_pins(o, ind+4); dump_node_pins(o, ind+4);
dump_obj_attr(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 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) { for (unsigned idx = 0 ; idx < ports_.count() ; idx += 1) {
o << setw(ind+4) << ""; o << setw(ind+4) << "";
@ -544,11 +563,11 @@ void NetProcTop::dump(ostream&o, unsigned ind) const
switch (type_) { switch (type_) {
case NetProcTop::KINITIAL: case NetProcTop::KINITIAL:
o << "initial /* " << get_line() << " in " o << "initial /* " << get_line() << " in "
<< scope_->name() << " */" << endl; << scope_path(scope_) << " */" << endl;
break; break;
case NetProcTop::KALWAYS: case NetProcTop::KALWAYS:
o << "always /* " << get_line() << " in " o << "always /* " << get_line() << " in "
<< scope_->name() << " */" << endl; << scope_path(scope_) << " */" << endl;
break; break;
} }
@ -630,7 +649,7 @@ void NetBlock::dump(ostream&o, unsigned ind) const
{ {
o << setw(ind) << "" << type_; o << setw(ind) << "" << type_;
if (subscope_) if (subscope_)
o << " : " << subscope_->name(); o << " : " << scope_path(subscope_);
o << endl; o << endl;
if (last_) { if (last_) {
@ -707,7 +726,7 @@ void NetDeassign::dump(ostream&o, unsigned ind) const
void NetDisable::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; << "/* " << get_line() << " */" << endl;
} }
@ -726,7 +745,7 @@ void NetEvProbe::dump_node(ostream&o, unsigned ind) const
o << "negedge "; o << "negedge ";
break; break;
} }
o << setw(ind) << "" << "-> " << event_->full_name() << "; " << endl; o << setw(ind) << "" << "-> " << event_->name() << "; " << endl;
dump_node_pins(o, ind+4); dump_node_pins(o, ind+4);
dump_obj_attr(o, ind+4); dump_obj_attr(o, ind+4);
} }
@ -742,10 +761,10 @@ void NetEvWait::dump(ostream&o, unsigned ind) const
o << setw(ind) <<"" << "@("; o << setw(ind) <<"" << "@(";
if (nevents() > 0) if (nevents() > 0)
o << event(0)->full_name(); o << event(0)->name();
for (unsigned idx = 1 ; idx < nevents() ; idx += 1) for (unsigned idx = 1 ; idx < nevents() ; idx += 1)
o << " or " << event(idx)->full_name(); o << " or " << event(idx)->name();
o << ") // " << get_line() << endl; o << ") // " << get_line() << endl;
@ -770,7 +789,7 @@ void NetForever::dump(ostream&o, unsigned ind) const
void NetFuncDef::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_) if (result_sig_)
o << setw(ind+2) << "" << "Return signal: " o << setw(ind+2) << "" << "Return signal: "
<< result_sig_->name() << endl; << result_sig_->name() << endl;
@ -813,7 +832,7 @@ void NetRepeat::dump(ostream&o, unsigned ind) const
void NetScope::dump(ostream&o) const void NetScope::dump(ostream&o) const
{ {
/* This is a constructed hierarchical name. */ /* This is a constructed hierarchical name. */
o << name(); o << scope_path(this);
switch (type_) { switch (type_) {
case BEGIN_END: case BEGIN_END:
@ -882,7 +901,8 @@ void NetScope::dump(ostream&o) const
/* Dump the events in this scope. */ /* Dump the events in this scope. */
for (NetEvent*cur = events_ ; cur ; cur = cur->snext_) { for (NetEvent*cur = events_ ; cur ; cur = cur->snext_) {
o << " event " << cur->name() << "; nprobe=" 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, // Dump the signals,
@ -956,7 +976,7 @@ void NetSTask::dump(ostream&o, unsigned ind) const
void NetUTask::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 void NetWhile::dump(ostream&o, unsigned ind) const
@ -1091,7 +1111,7 @@ void NetEEvent::dump(ostream&o) const
void NetEScope::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 void NetESelect::dump(ostream&o) const
@ -1135,7 +1155,7 @@ void NetESignal::dump(ostream&o) const
void NetEParam::dump(ostream&o) const void NetEParam::dump(ostream&o) const
{ {
if (scope_ != 0) if (scope_ != 0)
o << "<" << scope_->name() << "." << name_ << ">"; o << "<" << scope_path(scope_) << "." << name_ << ">";
else if (name_) else if (name_)
o << "<" << name_ << ">"; o << "<" << name_ << ">";
else else
@ -1150,7 +1170,7 @@ void NetETernary::dump(ostream&o) const
void NetEUFunc::dump(ostream&o) const void NetEUFunc::dump(ostream&o) const
{ {
o << name() << "("; o << func_->basename() << "(";
if (parms_.count() > 0) { if (parms_.count() > 0) {
parms_[0]->dump(o); parms_[0]->dump(o);
for (unsigned idx = 1 ; idx < parms_.count() ; idx += 1) { for (unsigned idx = 1 ; idx < parms_.count() ; idx += 1) {
@ -1205,6 +1225,9 @@ void Design::dump(ostream&o) const
/* /*
* $Log: design_dump.cc,v $ * $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 * Revision 1.175 2007/05/24 04:07:11 steve
* Rework the heirarchical identifier parse syntax and pform * Rework the heirarchical identifier parse syntax and pform
* to handle more general combinations of heirarch and bit selects. * to handle more general combinations of heirarch and bit selects.

View File

@ -17,7 +17,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/ */
#ifdef HAVE_CVS_IDENT #ifdef HAVE_CVS_IDENT
#ident "$Id: elab_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 #endif
# include "config.h" # include "config.h"
@ -474,7 +474,7 @@ NetExpr* PECallFunction::elaborate_expr(Design*des, NetScope*scope,
NetFuncDef*def = des->find_function(scope, path_); NetFuncDef*def = des->find_function(scope, path_);
if (def == 0) { if (def == 0) {
cerr << get_line() << ": error: No function " << path_ << cerr << get_line() << ": error: No function " << path_ <<
" in this context (" << scope->name() << ")." << endl; " in this context (" << scope_path(scope) << ")." << endl;
des->errors += 1; des->errors += 1;
return 0; return 0;
} }
@ -538,7 +538,7 @@ NetExpr* PECallFunction::elaborate_expr(Design*des, NetScope*scope,
cerr << get_line() << ": internal error: Unable to locate " cerr << get_line() << ": internal error: Unable to locate "
"function return value for " << path_ "function return value for " << path_
<< " in " << def->name() << "." << endl; << " in " << dscope->basename() << "." << endl;
des->errors += 1; des->errors += 1;
return 0; 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 // Finally, if this is a scope name, then return that. Look
// first to see if this is a name of a local scope. Failing // first to see if this is a name of a local scope. Failing
// that, search globally for a hierarchical name. // that, search globally for a hierarchical name.
if ((path_.size() == 1)) if ((path_.size() == 1)) {
if (NetScope*nsc = scope->child(peek_tail_name(path_))) { hname_t use_name ( peek_tail_name(path_) );
if (NetScope*nsc = scope->child(use_name)) {
NetEScope*tmp = new NetEScope(nsc); NetEScope*tmp = new NetEScope(nsc);
tmp->set_line(*this); tmp->set_line(*this);
return tmp; return tmp;
} }
}
list<hname_t> spath = eval_scope_path(des, scope, path_);
// Try full hierarchical scope name. // Try full hierarchical scope name.
if (NetScope*nsc = des->find_scope(path_)) { if (NetScope*nsc = des->find_scope(spath)) {
NetEScope*tmp = new NetEScope(nsc); NetEScope*tmp = new NetEScope(nsc);
tmp->set_line(*this); tmp->set_line(*this);
return tmp; return tmp;
} }
// Try relative scope name. // 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); NetEScope*tmp = new NetEScope(nsc);
tmp->set_line(*this); tmp->set_line(*this);
return tmp; return tmp;
@ -853,7 +857,7 @@ NetExpr* PEIdent::elaborate_expr(Design*des, NetScope*scope,
// I cannot interpret this identifier. Error message. // I cannot interpret this identifier. Error message.
cerr << get_line() << ": error: Unable to bind wire/reg/memory " cerr << get_line() << ": error: Unable to bind wire/reg/memory "
"`" << path_ << "' in `" << scope->name() << "'" << endl; "`" << path_ << "' in `" << scope_path(scope) << "'" << endl;
des->errors += 1; des->errors += 1;
return 0; return 0;
} }
@ -1684,6 +1688,9 @@ NetExpr* PEUnary::elaborate_expr(Design*des, NetScope*scope,
/* /*
* $Log: elab_expr.cc,v $ * $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 * Revision 1.125 2007/05/24 04:07:11 steve
* Rework the heirarchical identifier parse syntax and pform * Rework the heirarchical identifier parse syntax and pform
* to handle more general combinations of heirarch and bit selects. * to handle more general combinations of heirarch and bit selects.

View File

@ -17,7 +17,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/ */
#ifdef HAVE_CVS_IDENT #ifdef HAVE_CVS_IDENT
#ident "$Id: elab_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 #endif
# include "config.h" # include "config.h"
@ -156,7 +156,7 @@ NetAssign_* PEIdent::elaborate_lval(Design*des,
symbol_search(des, scope, path_, reg, par, eve); symbol_search(des, scope, path_, reg, par, eve);
if (reg == 0) { if (reg == 0) {
cerr << get_line() << ": error: Could not find variable ``" cerr << get_line() << ": error: Could not find variable ``"
<< path_ << "'' in ``" << scope->name() << << path_ << "'' in ``" << scope_path(scope) <<
"''" << endl; "''" << endl;
des->errors += 1; des->errors += 1;
@ -206,7 +206,7 @@ NetAssign_* PEIdent::elaborate_lval(Design*des,
unless this is the l-value of a force. */ unless this is the l-value of a force. */
if ((reg->type() != NetNet::REG) && !is_force) { if ((reg->type() != NetNet::REG) && !is_force) {
cerr << get_line() << ": error: " << path_ << 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; "." << endl;
cerr << reg->get_line() << ": : " << path_ << cerr << reg->get_line() << ": : " << path_ <<
" is declared here as " << reg->type() << "." << endl; " 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) { if (reg->type() != NetNet::REG) {
cerr << get_line() << ": error: " << path_ << 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; "." << endl;
cerr << reg->get_line() << ": : " << path_ << cerr << reg->get_line() << ": : " << path_ <<
" is declared here as " << reg->type() << "." << endl; " 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 $ * $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 * Revision 1.43 2007/05/24 04:07:11 steve
* Rework the heirarchical identifier parse syntax and pform * Rework the heirarchical identifier parse syntax and pform
* to handle more general combinations of heirarch and bit selects. * to handle more general combinations of heirarch and bit selects.

View File

@ -17,7 +17,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/ */
#ifdef HAVE_CVS_IDENT #ifdef HAVE_CVS_IDENT
#ident "$Id: elab_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 #endif
# include "config.h" # include "config.h"
@ -1240,7 +1240,7 @@ NetNet* PECallFunction::elaborate_net(Design*des, NetScope*scope,
NetFuncDef*def = des->find_function(scope, path_); NetFuncDef*def = des->find_function(scope, path_);
if (def == 0) { if (def == 0) {
cerr << get_line() << ": error: No function " << path_ << cerr << get_line() << ": error: No function " << path_ <<
" in this context (" << scope->name() << ")." << endl; " in this context (" << scope_path(scope) << ")." << endl;
des->errors += 1; des->errors += 1;
return 0; return 0;
} }
@ -1657,12 +1657,13 @@ NetNet* PEIdent::elaborate_net(Design*des, NetScope*scope,
if (sig == 0 && path_.size() != 1) { if (sig == 0 && path_.size() != 1) {
cerr << get_line() << ": error: The hierarchical name " cerr << get_line() << ": error: The hierarchical name "
<< path_ << " is undefined in " << path_ << " is undefined in "
<< scope->name() << "." << endl; << scope_path(scope) << "." << endl;
pform_name_t tmp_path = path_; pform_name_t tmp_path = path_;
tmp_path.pop_back(); 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) { if (tmp_scope == 0) {
cerr << get_line() << ": : I can't even find " cerr << get_line() << ": : I can't even find "
<< "the scope " << tmp_path << "." << endl; << "the scope " << tmp_path << "." << endl;
@ -1681,13 +1682,13 @@ NetNet* PEIdent::elaborate_net(Design*des, NetScope*scope,
if (error_implicit || (nettype == NetNet::NONE)) { if (error_implicit || (nettype == NetNet::NONE)) {
cerr << get_line() << ": error: " cerr << get_line() << ": error: "
<< scope->name() << "." << name_tail.name << scope_path(scope) << "." << name_tail.name
<< " not defined in this scope." << endl; << " not defined in this scope." << endl;
des->errors += 1; des->errors += 1;
} else if (warn_implicit) { } else if (warn_implicit) {
cerr << get_line() << ": warning: implicit " cerr << get_line() << ": warning: implicit "
"definition of wire " << scope->name() "definition of wire " << scope_path(scope)
<< "." << name_tail.name << "." << endl; << "." << name_tail.name << "." << endl;
} }
} }
@ -2032,7 +2033,7 @@ NetNet* PEIdent::make_implicit_net_(Design*des, NetScope*scope) const
if (warn_implicit) { if (warn_implicit) {
cerr << get_line() << ": warning: implicit " cerr << get_line() << ": warning: implicit "
"definition of wire logic " << scope->name() "definition of wire logic " << scope_path(scope)
<< "." << peek_tail_name(path_) << "." << endl; << "." << 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_); NetNet*sig = des->find_signal(scope, path_);
if (sig == 0) { if (sig == 0) {
cerr << get_line() << ": error: no wire/reg " << path_ cerr << get_line() << ": error: no wire/reg " << path_
<< " in module " << scope->name() << "." << endl; << " in module " << scope_path(scope) << "." << endl;
des->errors += 1; des->errors += 1;
return 0; return 0;
} }
@ -2388,7 +2389,7 @@ NetNet* PEIdent::elaborate_port(Design*des, NetScope*scope) const
case NetNet::NOT_A_PORT: case NetNet::NOT_A_PORT:
cerr << get_line() << ": error: signal " << path_ << " in" 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/" cerr << get_line() << ": : Are you missing an input/"
<< "output/inout declaration?" << endl; << "output/inout declaration?" << endl;
des->errors += 1; des->errors += 1;
@ -2400,7 +2401,7 @@ NetNet* PEIdent::elaborate_port(Design*des, NetScope*scope) const
case NetNet::PIMPLICIT: case NetNet::PIMPLICIT:
cerr << get_line() << ": internal error: signal " << path_ 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; << "port type PIMPLICIT." << endl;
des->errors += 1; des->errors += 1;
return 0; return 0;
@ -2962,6 +2963,9 @@ NetNet* PEUnary::elaborate_net(Design*des, NetScope*scope,
/* /*
* $Log: elab_net.cc,v $ * $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 * Revision 1.204 2007/05/24 04:07:11 steve
* Rework the heirarchical identifier parse syntax and pform * Rework the heirarchical identifier parse syntax and pform
* to handle more general combinations of heirarch and bit selects. * to handle more general combinations of heirarch and bit selects.

View File

@ -17,7 +17,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/ */
#ifdef HAVE_CVS_IDENT #ifdef HAVE_CVS_IDENT
#ident "$Id: elab_pexpr.cc,v 1.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 #endif
# include "config.h" # include "config.h"
@ -25,6 +25,7 @@
# include "PExpr.h" # include "PExpr.h"
# include "compiler.h" # include "compiler.h"
# include "util.h" # include "util.h"
# include "netmisc.h"
# include <iostream> # include <iostream>
@ -135,15 +136,17 @@ NetExpr*PEIdent::elaborate_pexpr(Design*des, NetScope*scope) const
path.pop_back(); path.pop_back();
NetScope*pscope = scope; NetScope*pscope = scope;
if (path_.size() > 0) if (path_.size() > 0) {
pscope = des->find_scope(scope, path); list<hname_t> tmp = eval_scope_path(des, scope, path);
pscope = des->find_scope(scope, tmp);
}
const NetExpr*ex_msb; const NetExpr*ex_msb;
const NetExpr*ex_lsb; const NetExpr*ex_lsb;
const NetExpr*ex = pscope->get_parameter(name_tail.name, ex_msb, ex_lsb); const NetExpr*ex = pscope->get_parameter(name_tail.name, ex_msb, ex_lsb);
if (ex == 0) { if (ex == 0) {
cerr << get_line() << ": error: identifier ``" << name_tail.name << 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; des->errors += 1;
return 0; return 0;
} }
@ -240,6 +243,9 @@ NetExpr*PEUnary::elaborate_pexpr (Design*des, NetScope*scope) const
/* /*
* $Log: elab_pexpr.cc,v $ * $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 * Revision 1.27 2007/05/24 04:07:11 steve
* Rework the heirarchical identifier parse syntax and pform * Rework the heirarchical identifier parse syntax and pform
* to handle more general combinations of heirarch and bit selects. * to handle more general combinations of heirarch and bit selects.

View File

@ -17,7 +17,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/ */
#ifdef HAVE_CVS_IDENT #ifdef HAVE_CVS_IDENT
#ident "$Id: elab_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 #endif
# include "config.h" # include "config.h"
@ -51,7 +51,7 @@ bool Module::elaborate_scope(Design*des, NetScope*scope,
{ {
if (debug_scopes) { if (debug_scopes) {
cerr << get_line() << ": debug: Elaborate scope " cerr << get_line() << ": debug: Elaborate scope "
<< scope->name() << "." << endl; << scope_path(scope) << "." << endl;
} }
// Generate all the parameters that this instance of this // Generate all the parameters that this instance of this
@ -156,7 +156,7 @@ bool Module::elaborate_scope(Design*des, NetScope*scope,
if (! flag) { if (! flag) {
cerr << val->get_line() << ": warning: parameter " cerr << val->get_line() << ": warning: parameter "
<< (*cur).first << " not found in " << (*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() for (tasks_it_t cur = tasks_.begin()
; cur != tasks_.end() ; cur ++ ) { ; 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); NetScope::TASK);
(*cur).second->elaborate_scope(des, task_scope); (*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() for (funcs_it_t cur = funcs_.begin()
; cur != funcs_.end() ; cur ++ ) { ; 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); NetScope::FUNC);
(*cur).second->elaborate_scope(des, func_scope); (*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 // that each instance has a unique name in the
// container. The format of using [] is part of the // container. The format of using [] is part of the
// Verilog standard. // Verilog standard.
char name_buf[128]; hname_t use_name (scope_name, genvar);
snprintf(name_buf, sizeof name_buf,
"%s[%d]", scope_name.str(), genvar);
perm_string use_name = lex_strings.make(name_buf);
if (debug_elaborate) if (debug_elaborate)
cerr << get_line() << ": debug: " cerr << get_line() << ": debug: "
<< "Create generated scope " << use_name << endl; << "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 // about to create, and if I find it then somebody beat me to
// it. // it.
if (sc->child(get_name())) { if (sc->child(hname_t(get_name()))) {
cerr << get_line() << ": error: Instance/Scope name " << cerr << get_line() << ": error: Instance/Scope name " <<
get_name() << " already used in this context." << get_name() << " already used in this context." <<
endl; endl;
@ -454,8 +452,8 @@ void PGModule::elaborate_scope_mod_(Design*des, Module*mod, NetScope*sc) const
<< "module " << mod->mod_name() << " within itself." << endl; << "module " << mod->mod_name() << " within itself." << endl;
cerr << get_line() << ": : The offending instance is " cerr << get_line() << ": : The offending instance is "
<< sc->name() << "." << get_name() << " within " << scope_path(sc) << "." << get_name() << " within "
<< scn->name() << "." << endl; << scope_path(scn) << "." << endl;
des->errors += 1; des->errors += 1;
return; return;
@ -498,24 +496,21 @@ void PGModule::elaborate_scope_mod_(Design*des, Module*mod, NetScope*sc) const
// instantiation line. // instantiation line.
for (int idx = 0 ; idx < instance_count ; idx += 1) { for (int idx = 0 ; idx < instance_count ; idx += 1) {
perm_string use_name = get_name(); hname_t use_name (get_name());
if (instance_array) { if (instance_array) {
char name_buf[128];
int instance_idx = idx; int instance_idx = idx;
if (instance_low < instance_high) if (instance_low < instance_high)
instance_idx = instance_low + idx; instance_idx = instance_low + idx;
else else
instance_idx = instance_low - idx; instance_idx = instance_low - idx;
snprintf(name_buf, sizeof name_buf, use_name = hname_t(get_name(), instance_idx);
"%s[%d]", get_name().str(), instance_idx);
use_name = lex_strings.make(name_buf);
} }
if (debug_scopes) { if (debug_scopes) {
cerr << get_line() << ": debug: Module instance " << use_name cerr << get_line() << ": debug: Module instance " << use_name
<< " becomes child of " << sc->name() << " becomes child of " << scope_path(sc)
<< "." << endl; << "." << endl;
} }
@ -652,7 +647,7 @@ void PBlock::elaborate_scope(Design*des, NetScope*scope) const
NetScope*my_scope = scope; NetScope*my_scope = scope;
if (name_ != 0) { 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::FORK_JOIN
: NetScope::BEGIN_END); : NetScope::BEGIN_END);
} }
@ -761,6 +756,9 @@ void PWhile::elaborate_scope(Design*des, NetScope*scope) const
/* /*
* $Log: elab_scope.cc,v $ * $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 * Revision 1.45 2007/05/24 04:07:11 steve
* Rework the heirarchical identifier parse syntax and pform * Rework the heirarchical identifier parse syntax and pform
* to handle more general combinations of heirarch and bit selects. * to handle more general combinations of heirarch and bit selects.

View File

@ -17,7 +17,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/ */
#ifdef HAVE_CVS_IDENT #ifdef HAVE_CVS_IDENT
#ident "$Id: elab_sig.cc,v 1.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 #endif
# include "config.h" # include "config.h"
@ -208,11 +208,13 @@ bool Module::elaborate_sig(Design*des, NetScope*scope) const
for (mfunc_it_t cur = funcs_.begin() for (mfunc_it_t cur = funcs_.begin()
; cur != funcs_.end() ; cur ++) { ; 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) { if (scope == 0) {
cerr << (*cur).second->get_line() << ": internal error: " cerr << (*cur).second->get_line() << ": internal error: "
<< "Child scope for function " << (*cur).first << "Child scope for function " << (*cur).first
<< " missing in " << scope->name() << "." << endl; << " missing in " << scope_path(scope) << "." << endl;
des->errors += 1; des->errors += 1;
continue; continue;
} }
@ -229,7 +231,7 @@ bool Module::elaborate_sig(Design*des, NetScope*scope) const
for (mtask_it_t cur = tasks_.begin() for (mtask_it_t cur = tasks_.begin()
; cur != tasks_.end() ; cur ++) { ; cur != tasks_.end() ; cur ++) {
NetScope*tscope = scope->child((*cur).first); NetScope*tscope = scope->child( hname_t((*cur).first) );
assert(tscope); assert(tscope);
(*cur).second->elaborate_sig(des, 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) { if (my_scope->parent() != scope) {
cerr << get_line() << ": internal error: " cerr << get_line() << ": internal error: "
<< "Instance " << my_scope->name() << "Instance " << scope_path(my_scope)
<< " is in parent " << my_scope->parent()->name() << " is in parent " << scope_path(my_scope->parent())
<< " instead of " << scope->name() << " instead of " << scope_path(scope)
<< endl; << endl;
} }
assert(my_scope->parent() == scope); assert(my_scope->parent() == scope);
@ -277,7 +279,7 @@ bool PGenerate::elaborate_sig(Design*des) const
if (debug_elaborate) if (debug_elaborate)
cerr << get_line() << ": debug: Elaborate nets in " cerr << get_line() << ": debug: Elaborate nets in "
<< "scope " << (*cur)->name() << endl; << "scope " << scope_path(*cur) << endl;
flag = elaborate_sig_(des, *cur) & flag; flag = elaborate_sig_(des, *cur) & flag;
} }
@ -296,7 +298,7 @@ bool PGenerate::elaborate_sig_(Design*des, NetScope*scope) const
if (debug_elaborate) if (debug_elaborate)
cerr << get_line() << ": debug: Elaborate PWire " 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); cur->elaborate_sig(des, scope);
} }
@ -432,14 +434,14 @@ void PFunction::elaborate_sig(Design*des, NetScope*scope) const
cerr << get_line() << ": internal error: function " cerr << get_line() << ": internal error: function "
<< "port " << (*ports_)[idx]->path() << "port " << (*ports_)[idx]->path()
<< " has wrong name for function " << " has wrong name for function "
<< scope->name() << "." << endl; << scope_path(scope) << "." << endl;
des->errors += 1; des->errors += 1;
} }
NetNet*tmp = scope->find_signal(pname); NetNet*tmp = scope->find_signal(pname);
if (tmp == 0) { if (tmp == 0) {
cerr << get_line() << ": internal error: function " cerr << get_line() << ": internal error: function "
<< scope->name() << " is missing port " << scope_path(scope) << " is missing port "
<< pname << "." << endl; << pname << "." << endl;
scope->dump(cerr); scope->dump(cerr);
cerr << get_line() << ": Continuing..." << endl; cerr << get_line() << ": Continuing..." << endl;
@ -497,14 +499,14 @@ void PTask::elaborate_sig(Design*des, NetScope*scope) const
if (tmp == 0) { if (tmp == 0) {
cerr << get_line() << ": internal error: " cerr << get_line() << ": internal error: "
<< "Could not find port " << port_name << "Could not find port " << port_name
<< " in scope " << scope->name() << endl; << " in scope " << scope_path(scope) << endl;
scope->dump(cerr); scope->dump(cerr);
} }
ports[idx] = tmp; ports[idx] = tmp;
} }
NetTaskDef*def = new NetTaskDef(scope->name(), ports); NetTaskDef*def = new NetTaskDef(scope, ports);
scope->set_task_def(def); 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(); name_component_t cur = tmp_path.front();
tmp_path.pop_front(); tmp_path.pop_front();
scope = scope->child(cur.name); scope = scope->child( hname_t(cur.name) );
if (scope == 0) { if (scope == 0) {
cerr << get_line() << ": internal error: " cerr << get_line() << ": internal error: "
@ -727,7 +729,7 @@ NetNet* PWire::elaborate_sig(Design*des, NetScope*scope) const
if (debug_elaborate) { if (debug_elaborate) {
cerr << get_line() << ": debug: Create signal " cerr << get_line() << ": debug: Create signal "
<< wtype << " ["<<msb<<":"<<lsb<<"] " << name << 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) { if (debug_elaborate) {
cerr << get_line() << ": debug: " cerr << get_line() << ": debug: "
<< "Signal " << name << "Signal " << name
<< " in scope " << scope->name() << " in scope " << scope_path(scope)
<< " defaults to data type " << use_data_type << endl; << " 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 $ * $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 * Revision 1.51 2007/05/24 04:07:11 steve
* Rework the heirarchical identifier parse syntax and pform * Rework the heirarchical identifier parse syntax and pform
* to handle more general combinations of heirarch and bit selects. * to handle more general combinations of heirarch and bit selects.

View File

@ -17,7 +17,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/ */
#ifdef HAVE_CVS_IDENT #ifdef HAVE_CVS_IDENT
#ident "$Id: 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 #endif
# include "config.h" # include "config.h"
@ -651,7 +651,7 @@ void PGModule::elaborate_mod_(Design*des, Module*rmod, NetScope*scope) const
if (debug_elaborate) { if (debug_elaborate) {
cerr << get_line() << ": debug: Instantiate module " cerr << get_line() << ": debug: Instantiate module "
<< rmod->mod_name() << " with instance name " << 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 // 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); NetESignal*sig = new NetESignal(tmp);
/* Generate an assignment of the l-value to the temporary... */ /* Generate an assignment of the l-value to the temporary... */
string n = scope->local_hsymbol();
NetAssign_*lvt = new NetAssign_(tmp); NetAssign_*lvt = new NetAssign_(tmp);
NetAssign*a1 = new NetAssign(lvt, rv); NetAssign*a1 = new NetAssign(lvt, rv);
@ -1618,10 +1617,10 @@ NetProc* PBlock::elaborate(Design*des, NetScope*scope) const
NetScope*nscope = 0; NetScope*nscope = 0;
if (name_.str() != 0) { if (name_.str() != 0) {
nscope = scope->child(name_); nscope = scope->child(hname_t(name_));
if (nscope == 0) { if (nscope == 0) {
cerr << get_line() << ": internal error: " cerr << get_line() << ": internal error: "
"unable to find block scope " << scope->name() "unable to find block scope " << scope_path(scope)
<< "<" << name_ << ">" << endl; << "<" << name_ << ">" << endl;
des->errors += 1; des->errors += 1;
return 0; return 0;
@ -1927,7 +1926,7 @@ NetProc* PCallTask::elaborate_usr(Design*des, NetScope*scope) const
NetTaskDef*def = task->task_def(); NetTaskDef*def = task->task_def();
if (def == 0) { if (def == 0) {
cerr << get_line() << ": internal error: task " << path_ 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; << "." << endl;
des->errors += 1; des->errors += 1;
return 0; return 0;
@ -2138,10 +2137,12 @@ NetProc* PDisable::elaborate(Design*des, NetScope*scope) const
{ {
assert(scope); 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) { if (target == 0) {
cerr << get_line() << ": error: Cannot find scope " cerr << get_line() << ": error: Cannot find scope "
<< scope_ << " in " << scope->name() << endl; << scope_ << " in " << scope_path(scope) << endl;
des->errors += 1; des->errors += 1;
return 0; return 0;
} }
@ -2758,7 +2759,7 @@ void PFunction::elaborate(Design*des, NetScope*scope) const
if (def == 0) { if (def == 0) {
cerr << get_line() << ": internal error: " cerr << get_line() << ": internal error: "
<< "No function definition for function " << "No function definition for function "
<< scope->name() << endl; << scope_path(scope) << endl;
return; return;
} }
@ -2767,7 +2768,7 @@ void PFunction::elaborate(Design*des, NetScope*scope) const
NetProc*st = statement_->elaborate(des, scope); NetProc*st = statement_->elaborate(des, scope);
if (st == 0) { if (st == 0) {
cerr << statement_->get_line() << ": error: Unable to elaborate " cerr << statement_->get_line() << ": error: Unable to elaborate "
"statement in function " << def->name() << "." << endl; "statement in function " << scope->basename() << "." << endl;
des->errors += 1; des->errors += 1;
return; return;
} }
@ -2868,7 +2869,7 @@ void PTask::elaborate(Design*des, NetScope*task) const
st = statement_->elaborate(des, task); st = statement_->elaborate(des, task);
if (st == 0) { if (st == 0) {
cerr << statement_->get_line() << ": Unable to elaborate " cerr << statement_->get_line() << ": Unable to elaborate "
"statement in task " << task->name() "statement in task " << scope_path(task)
<< " at " << get_line() << "." << endl; << " at " << get_line() << "." << endl;
return; return;
} }
@ -3226,7 +3227,8 @@ bool Module::elaborate(Design*des, NetScope*scope) const
for (mfunc_it_t cur = funcs_.begin() for (mfunc_it_t cur = funcs_.begin()
; cur != funcs_.end() ; cur ++) { ; cur != funcs_.end() ; cur ++) {
NetScope*fscope = scope->child((*cur).first); hname_t use_name ( (*cur).first );
NetScope*fscope = scope->child(use_name);
assert(fscope); assert(fscope);
(*cur).second->elaborate(des, 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() for (mtask_it_t cur = tasks_.begin()
; cur != tasks_.end() ; cur ++) { ; cur != tasks_.end() ; cur ++) {
NetScope*tscope = scope->child((*cur).first); hname_t use_name ( (*cur).first );
NetScope*tscope = scope->child(use_name);
assert(tscope); assert(tscope);
(*cur).second->elaborate(des, tscope); (*cur).second->elaborate(des, tscope);
} }
@ -3287,7 +3290,7 @@ bool PGenerate::elaborate(Design*des) const
if (debug_elaborate) if (debug_elaborate)
cerr << get_line() << ": debug: Elaborate in " cerr << get_line() << ": debug: Elaborate in "
<< "scope " << (*cur)->name() << endl; << "scope " << scope_path(*cur) << endl;
flag = elaborate_(des, *cur) & flag; flag = elaborate_(des, *cur) & flag;
} }
@ -3417,6 +3420,9 @@ Design* elaborate(list<perm_string>roots)
/* /*
* $Log: elaborate.cc,v $ * $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 * Revision 1.371 2007/05/24 04:07:11 steve
* Rework the heirarchical identifier parse syntax and pform * Rework the heirarchical identifier parse syntax and pform
* to handle more general combinations of heirarch and bit selects. * to handle more general combinations of heirarch and bit selects.

View File

@ -17,7 +17,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/ */
#ifdef HAVE_CVS_IDENT #ifdef HAVE_CVS_IDENT
#ident "$Id: 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 #endif
# include "config.h" # include "config.h"
@ -1212,7 +1212,7 @@ NetExpr* NetEParam::eval_tree(int prune_to_width)
if (expr == 0) { if (expr == 0) {
cerr << get_line() << ": internal error: Unable to match " cerr << get_line() << ": internal error: Unable to match "
<< "parameter " << name_ << " in scope " << "parameter " << name_ << " in scope "
<< scope_->name() << endl; << scope_path(scope_) << endl;
return 0; return 0;
} }
@ -1655,6 +1655,9 @@ NetEConst* NetEUReduce::eval_tree(int prune_to_width)
/* /*
* $Log: eval_tree.cc,v $ * $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 * Revision 1.76 2007/05/31 18:36:06 steve
* Fix warning (ldolittle) * Fix warning (ldolittle)
* *

View File

@ -17,7 +17,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/ */
#ifdef HAVE_CVS_IDENT #ifdef HAVE_CVS_IDENT
#ident "$Id: 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 #endif
# include "config.h" # include "config.h"
@ -92,7 +92,6 @@ NetNet* NetEBBits::synthesize(Design*des)
NetScope*scope = lsig->scope(); NetScope*scope = lsig->scope();
assert(scope); assert(scope);
string path = des->local_symbol(scope->name());
if (lsig->vector_width() != rsig->vector_width()) { if (lsig->vector_width() != rsig->vector_width()) {
cerr << get_line() << ": internal error: bitwise (" << op_ cerr << get_line() << ": internal error: bitwise (" << op_
@ -871,6 +870,9 @@ NetNet* NetESignal::synthesize(Design*des)
/* /*
* $Log: expr_synth.cc,v $ * $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 * Revision 1.86 2007/04/15 01:37:29 steve
* Allow bit/part select of vectors in continuous assignments. * Allow bit/part select of vectors in continuous assignments.
* *

View File

@ -17,7 +17,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/ */
#ifdef HAVE_CVS_IDENT #ifdef HAVE_CVS_IDENT
#ident "$Id: net_design.cc,v 1.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 #endif
# include "config.h" # include "config.h"
@ -32,6 +32,7 @@
# include "netlist.h" # include "netlist.h"
# include "util.h" # include "util.h"
# include "compiler.h" # include "compiler.h"
# include "netmisc.h"
# include <sstream> # include <sstream>
Design:: Design() Design:: Design()
@ -84,7 +85,7 @@ uint64_t Design::scale_to_precision(uint64_t val,
NetScope* Design::make_root_scope(perm_string root) NetScope* Design::make_root_scope(perm_string root)
{ {
NetScope *root_scope_; 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 /* This relies on the fact that the basename return value is
permallocated. */ permallocated. */
root_scope_->set_module_name(root_scope_->basename()); 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 * more step down the tree until the name runs out or the search
* fails. * 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()) if (path.empty())
return 0; return 0;
@ -123,17 +124,16 @@ NetScope* Design::find_scope(const pform_name_t&path) const
; scope != root_scopes_.end(); scope++) { ; scope != root_scopes_.end(); scope++) {
NetScope*cur = *scope; NetScope*cur = *scope;
if (strcmp(peek_head_name(path), cur->basename()) != 0) if (path.front() != cur->fullname())
continue; continue;
pform_name_t tmp = path; std::list<hname_t> tmp = path;
tmp.pop_front(); tmp.pop_front();
while (cur) { while (cur) {
if (tmp.empty()) return cur; if (tmp.empty()) return cur;
perm_string name = peek_head_name(tmp); cur = cur->child( tmp.front() );
cur = cur->child(name);
tmp.pop_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 * 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. * 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); assert(scope);
if (path.empty()) if (path.empty())
@ -157,19 +157,15 @@ NetScope* Design::find_scope(NetScope*scope, const pform_name_t&path) const
for ( ; scope ; scope = scope->parent()) { for ( ; scope ; scope = scope->parent()) {
pform_name_t tmp = path; std::list<hname_t> tmp = path;
name_component_t name_front = tmp.front();
perm_string key = name_front.name;
NetScope*cur = scope; NetScope*cur = scope;
do { do {
cur = cur->child(key); hname_t key = tmp.front();
cur = cur->child( key );
if (cur == 0) break; if (cur == 0) break;
tmp.pop_front(); tmp.pop_front();
if (tmp.empty()) break; } while (!tmp.empty());
name_front = tmp.front();
key = name_front.name;
} while (key);
if (cur) return cur; if (cur) return cur;
} }
@ -209,9 +205,11 @@ void NetScope::run_defparams(Design*des)
perm_string perm_name = peek_tail_name(path); perm_string perm_name = peek_tail_name(path);
path.pop_back(); 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 /* If there is no path on the name, then the targ_scope
is the current 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) { if (targ_scope == 0) {
cerr << val->get_line() << ": warning: scope of " << cerr << val->get_line() << ": warning: scope of " <<
path << "." << perm_name << " not found." << endl; path << "." << perm_name << " not found." << endl;
@ -222,7 +220,7 @@ void NetScope::run_defparams(Design*des)
if (! flag) { if (! flag) {
cerr << val->get_line() << ": warning: parameter " cerr << val->get_line() << ": warning: parameter "
<< perm_name << " not found in " << 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); perm_string key = peek_tail_name(path);
path.pop_back(); path.pop_back();
if (! path.empty()) if (! path.empty()) {
scope = find_scope(scope, path); list<hname_t> eval_path = eval_scope_path(this, scope, path);
scope = find_scope(scope, eval_path);
}
while (scope) { while (scope) {
if (NetNet*net = scope->find_signal(key)) 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) NetFuncDef* Design::find_function(NetScope*scope, const pform_name_t&name)
{ {
assert(scope); assert(scope);
NetScope*func = find_scope(scope, name);
if (func && (func->type() == NetScope::FUNC))
return func->func_def();
return 0; std::list<hname_t> eval_path = eval_scope_path(this, scope, name);
} NetScope*func = find_scope(scope, eval_path);
NetFuncDef* Design::find_function(const pform_name_t&key)
{
NetScope*func = find_scope(key);
if (func && (func->type() == NetScope::FUNC)) if (func && (func->type() == NetScope::FUNC))
return func->func_def(); 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* Design::find_task(NetScope*scope, const pform_name_t&name)
{ {
NetScope*task = find_scope(scope, name); 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)) if (task && (task->type() == NetScope::TASK))
return task; return task;
return 0; 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) void Design::add_node(NetNode*net)
{ {
assert(net->design_ == 0); assert(net->design_ == 0);
@ -565,6 +548,9 @@ void Design::delete_process(NetProcTop*top)
/* /*
* $Log: net_design.cc,v $ * $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 * Revision 1.52 2007/05/24 04:07:12 steve
* Rework the heirarchical identifier parse syntax and pform * Rework the heirarchical identifier parse syntax and pform
* to handle more general combinations of heirarch and bit selects. * to handle more general combinations of heirarch and bit selects.

View File

@ -17,7 +17,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/ */
#ifdef HAVE_CVS_IDENT #ifdef HAVE_CVS_IDENT
#ident "$Id: net_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 #endif
# include "config.h" # include "config.h"
@ -56,10 +56,10 @@ perm_string NetEvent::name() const
return name_; return name_;
} }
string NetEvent::full_name() const NetScope* NetEvent::scope()
{ {
assert(scope_); assert(scope_);
return scope_->name() + "." + string(name_); return scope_;
} }
const NetScope* NetEvent::scope() const const NetScope* NetEvent::scope() const
@ -449,6 +449,9 @@ NetProc* NetEvWait::statement()
/* /*
* $Log: net_event.cc,v $ * $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 * Revision 1.26 2004/10/04 01:10:54 steve
* Clean up spurious trailing white space. * Clean up spurious trailing white space.
* *

View File

@ -17,7 +17,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/ */
#ifdef HAVE_CVS_IDENT #ifdef HAVE_CVS_IDENT
#ident "$Id: net_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 #endif
# include "config.h" # include "config.h"
@ -95,13 +95,13 @@ bool PECallFunction::check_call_matches_definition_(Design*des, NetScope*dscope)
if (dscope->type() != NetScope::FUNC) { if (dscope->type() != NetScope::FUNC) {
cerr << get_line() << ": error: Attempt to call scope " cerr << get_line() << ": error: Attempt to call scope "
<< dscope->name() << " as a function." << endl; << scope_path(dscope) << " as a function." << endl;
des->errors += 1; des->errors += 1;
return false; return false;
} }
if (parms_count != dscope->func_def()->port_count()) { 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()) << " expects " << (dscope->func_def()->port_count())
<< " arguments, you passed " << parms_count << "." << " arguments, you passed " << parms_count << "."
<< endl; << endl;
@ -149,6 +149,9 @@ unsigned NetSysFunc::vector_width() const
/* /*
* $Log: net_func.cc,v $ * $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 * Revision 1.9 2007/04/17 04:17:47 steve
* Fix argument count in function error message. * Fix argument count in function error message.
* *

View File

@ -17,7 +17,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/ */
#ifdef HAVE_CVS_IDENT #ifdef HAVE_CVS_IDENT
#ident "$Id: net_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 #endif
# include "config.h" # include "config.h"
@ -391,7 +391,7 @@ const char* Nexus::name() const
} }
assert(sig); assert(sig);
ostringstream tmp; ostringstream tmp;
tmp << sig->scope()->name() << "." << sig->name(); tmp << scope_path(sig->scope()) << "." << sig->name();
if (sig->pin_count() > 1) if (sig->pin_count() > 1)
tmp << "<" << pin << ">"; tmp << "<" << pin << ">";
@ -525,6 +525,9 @@ bool NexusSet::intersect(const NexusSet&that) const
/* /*
* $Log: net_link.cc,v $ * $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 * Revision 1.20 2007/03/26 18:17:50 steve
* Remove pretense of general use for t_cookie. * Remove pretense of general use for t_cookie.
* *

View File

@ -17,7 +17,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/ */
#ifdef HAVE_CVS_IDENT #ifdef HAVE_CVS_IDENT
#ident "$Id: net_scope.cc,v 1.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 #endif
# include "config.h" # include "config.h"
@ -35,7 +35,7 @@
* in question. * 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) : type_(t), up_(up), sib_(0), sub_(0)
{ {
signals_ = 0; signals_ = 0;
@ -241,15 +241,7 @@ NetNet::Type NetScope::default_nettype() const
perm_string NetScope::basename() const perm_string NetScope::basename() const
{ {
return name_; return name_.peek_name();
}
string NetScope::name() const
{
if (up_)
return up_->name() + "." + string(name_);
else
return string(name_);
} }
void NetScope::add_event(NetEvent*ev) 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 * This method locates a child scope by name. The name is the simple
* name of the child, no hierarchy is searched. * name of the child, no hierarchy is searched.
*/ */
NetScope* NetScope::child(const char*name) NetScope* NetScope::child(const hname_t&name)
{ {
if (sub_ == 0) return 0; if (sub_ == 0) return 0;
NetScope*cur = sub_; NetScope*cur = sub_;
while (strcmp(cur->name_, name) != 0) { while (cur->name_ != name) {
if (cur->sib_ == 0) return 0; if (cur->sib_ == 0) return 0;
cur = cur->sib_; cur = cur->sib_;
} }
@ -353,12 +345,12 @@ NetScope* NetScope::child(const char*name)
return cur; return cur;
} }
const NetScope* NetScope::child(const char*name) const const NetScope* NetScope::child(const hname_t&name) const
{ {
if (sub_ == 0) return 0; if (sub_ == 0) return 0;
NetScope*cur = sub_; NetScope*cur = sub_;
while (strcmp(cur->name_, name) != 0) { while (cur->name_ != name) {
if (cur->sib_ == 0) return 0; if (cur->sib_ == 0) return 0;
cur = cur->sib_; cur = cur->sib_;
} }
@ -382,15 +374,18 @@ perm_string NetScope::local_symbol()
res << "_s" << (lcounter_++); res << "_s" << (lcounter_++);
return lex_strings.make(res.str()); return lex_strings.make(res.str());
} }
#if 0
string NetScope::local_hsymbol() string NetScope::local_hsymbol()
{ {
return string(name()) + "." + string(local_symbol()); return string(name()) + "." + string(local_symbol());
} }
#endif
/* /*
* $Log: net_scope.cc,v $ * $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 * Revision 1.37 2007/04/26 03:06:22 steve
* Rework hname_t to use perm_strings. * Rework hname_t to use perm_strings.
* *

View File

@ -17,7 +17,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/ */
#ifdef HAVE_CVS_IDENT #ifdef HAVE_CVS_IDENT
#ident "$Id: 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 #endif
# include "config.h" # include "config.h"
@ -1770,11 +1770,16 @@ NetFuncDef::NetFuncDef(NetScope*s, NetNet*result, const svector<NetNet*>&po)
NetFuncDef::~NetFuncDef() NetFuncDef::~NetFuncDef()
{ {
} }
#if 0
const string NetFuncDef::name() const const string NetFuncDef::name() const
{ {
return scope_->name(); return scope_->name();
} }
#endif
const NetScope* NetFuncDef::scope() const
{
return scope_;
}
void NetFuncDef::set_proc(NetProc*st) void NetFuncDef::set_proc(NetProc*st)
{ {
@ -1850,12 +1855,12 @@ NetEUFunc::~NetEUFunc()
for (unsigned idx = 0 ; idx < parms_.count() ; idx += 1) for (unsigned idx = 0 ; idx < parms_.count() ; idx += 1)
delete parms_[idx]; delete parms_[idx];
} }
#if 0
const string NetEUFunc::name() const const string NetEUFunc::name() const
{ {
return func_->name(); return func_->name();
} }
#endif
const NetESignal*NetEUFunc::result_sig() const const NetESignal*NetEUFunc::result_sig() const
{ {
return result_sig_; return result_sig_;
@ -1893,12 +1898,12 @@ NetUTask::NetUTask(NetScope*def)
NetUTask::~NetUTask() NetUTask::~NetUTask()
{ {
} }
#if 0
const string NetUTask::name() const const string NetUTask::name() const
{ {
return task_->name(); return task_->name();
} }
#endif
const NetScope* NetUTask::task() const const NetScope* NetUTask::task() const
{ {
return task_; return task_;
@ -2286,8 +2291,8 @@ unsigned NetUReduce::width() const
return width_; return width_;
} }
NetTaskDef::NetTaskDef(const string&n, const svector<NetNet*>&po) NetTaskDef::NetTaskDef(NetScope*n, const svector<NetNet*>&po)
: name_(n), proc_(0), ports_(po) : scope_(n), proc_(0), ports_(po)
{ {
} }
@ -2312,11 +2317,16 @@ NetNet* NetTaskDef::port(unsigned idx)
assert(idx < ports_.count()); assert(idx < ports_.count());
return ports_[idx]; return ports_[idx];
} }
#if 0
const string& NetTaskDef::name() const const string& NetTaskDef::name() const
{ {
return name_; return name_;
} }
#endif
const NetScope* NetTaskDef::scope() const
{
return scope_;
}
const NetProc*NetTaskDef::proc() const const NetProc*NetTaskDef::proc() const
{ {
@ -2325,6 +2335,9 @@ const NetProc*NetTaskDef::proc() const
/* /*
* $Log: netlist.cc,v $ * $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 * Revision 1.257 2007/04/02 01:12:34 steve
* Seperate arrayness from word count * Seperate arrayness from word count
* *

View File

@ -19,7 +19,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/ */
#ifdef HAVE_CVS_IDENT #ifdef HAVE_CVS_IDENT
#ident "$Id: netlist.h,v 1.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 #endif
/* /*
@ -2060,7 +2060,6 @@ class NetEvent : public LineInfo {
~NetEvent(); ~NetEvent();
perm_string name() const; perm_string name() const;
string full_name() const;
// Get information about probes connected to me. // Get information about probes connected to me.
unsigned nprobe() const; unsigned nprobe() const;
@ -2267,8 +2266,9 @@ class NetFuncDef {
void set_proc(NetProc*st); void set_proc(NetProc*st);
const string name() const; //const string name() const;
const NetProc*proc() const; const NetProc*proc() const;
const NetScope*scope() const;
NetScope*scope(); NetScope*scope();
unsigned port_count() const; unsigned port_count() const;
@ -2406,12 +2406,13 @@ class NetSTask : public NetProc {
class NetTaskDef { class NetTaskDef {
public: public:
NetTaskDef(const string&n, const svector<NetNet*>&po); NetTaskDef(NetScope*n, const svector<NetNet*>&po);
~NetTaskDef(); ~NetTaskDef();
void set_proc(NetProc*p); void set_proc(NetProc*p);
const string& name() const; //const string& name() const;
const NetScope* scope() const;
const NetProc*proc() const; const NetProc*proc() const;
unsigned port_count() const; unsigned port_count() const;
@ -2420,7 +2421,7 @@ class NetTaskDef {
void dump(ostream&, unsigned) const; void dump(ostream&, unsigned) const;
private: private:
string name_; NetScope*scope_;
NetProc*proc_; NetProc*proc_;
svector<NetNet*>ports_; svector<NetNet*>ports_;
@ -2437,11 +2438,9 @@ class NetTaskDef {
class NetEUFunc : public NetExpr { class NetEUFunc : public NetExpr {
public: public:
NetEUFunc(NetScope*, NetESignal*, svector<NetExpr*>&); NetEUFunc(NetScope*, NetESignal*, svector<NetExpr*>&);
~NetEUFunc(); ~NetEUFunc();
const string name() const;
const NetESignal*result_sig() const; const NetESignal*result_sig() const;
unsigned parm_count() 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 /* Create a new scope, and attach it to the given parent. The
name is expected to have been permallocated. */ 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(); ~NetScope();
/* Parameters exist within a scope, and these methods allow /* 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 /* The parent and child() methods allow users of NetScope
objects to locate nearby scopes. */ objects to locate nearby scopes. */
NetScope* parent(); NetScope* parent();
NetScope* child(const char*name); NetScope* child(const hname_t&name);
const NetScope* parent() const; const NetScope* parent() const;
const NetScope* child(const char*name) const; const NetScope* child(const hname_t&name) const;
TYPE type() const; TYPE type() const;
@ -3267,7 +3266,7 @@ class NetScope : public Attrib {
name, whereas the basename is just my name within my parent name, whereas the basename is just my name within my parent
scope. */ scope. */
perm_string basename() const; perm_string basename() const;
string name() const; const hname_t& fullname() const { return name_; }
void run_defparams(class Design*); void run_defparams(class Design*);
void evaluate_parameters(class Design*); void evaluate_parameters(class Design*);
@ -3275,9 +3274,6 @@ class NetScope : public Attrib {
/* This method generates a non-hierarchical name that is /* This method generates a non-hierarchical name that is
guaranteed to be unique within this scope. */ guaranteed to be unique within this scope. */
perm_string local_symbol(); 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 dump(ostream&) const;
void emit_scope(struct target_t*tgt) const; void emit_scope(struct target_t*tgt) const;
@ -3328,7 +3324,7 @@ class NetScope : public Attrib {
private: private:
TYPE type_; TYPE type_;
perm_string name_; hname_t name_;
signed char time_unit_, time_prec_; signed char time_unit_, time_prec_;
NetNet::Type default_nettype_; NetNet::Type default_nettype_;
@ -3392,8 +3388,8 @@ class Design {
path is taken as an absolute scope name. Otherwise, the path is taken as an absolute scope name. Otherwise, the
scope is located starting at the passed scope and working scope is located starting at the passed scope and working
up if needed. */ up if needed. */
NetScope* find_scope(const pform_name_t&path) const; NetScope* find_scope(const std::list<hname_t>&path) const;
NetScope* find_scope(NetScope*, const pform_name_t&path) const; NetScope* find_scope(NetScope*, const std::list<hname_t>&path) const;
// PARAMETERS // PARAMETERS
@ -3409,11 +3405,9 @@ class Design {
// Functions // Functions
NetFuncDef* find_function(NetScope*scope, const pform_name_t&key); NetFuncDef* find_function(NetScope*scope, const pform_name_t&key);
NetFuncDef* find_function(const pform_name_t&path);
// Tasks // Tasks
NetScope* find_task(NetScope*scope, const pform_name_t&name); NetScope* find_task(NetScope*scope, const pform_name_t&name);
NetScope* find_task(const pform_name_t&key);
// NODES // NODES
void add_node(NetNode*); void add_node(NetNode*);
@ -3499,8 +3493,24 @@ inline ostream& operator << (ostream&o, const NetExpr&exp)
extern ostream& operator << (ostream&, NetNet::Type); 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 $ * $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 * Revision 1.379 2007/05/24 04:07:12 steve
* Rework the heirarchical identifier parse syntax and pform * Rework the heirarchical identifier parse syntax and pform
* to handle more general combinations of heirarch and bit selects. * to handle more general combinations of heirarch and bit selects.

View File

@ -17,7 +17,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/ */
#ifdef HAVE_CVS_IDENT #ifdef HAVE_CVS_IDENT
#ident "$Id: 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 #endif
# include "config.h" # include "config.h"
@ -25,6 +25,8 @@
# include "netlist.h" # include "netlist.h"
# include "netmisc.h" # include "netmisc.h"
# include "PExpr.h" # include "PExpr.h"
# include "pform_types.h"
# include "ivl_assert.h"
NetNet* add_to_net(Design*des, NetNet*sig, long val) NetNet* add_to_net(Design*des, NetNet*sig, long val)
{ {
@ -138,9 +140,44 @@ NetExpr* elab_and_eval(Design*des, NetScope*scope,
return tmp; return tmp;
} }
std::list<hname_t> eval_scope_path(Design*des, NetScope*scope,
const pform_name_t&path)
{
list<hname_t> 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<NetEConst*>(tmp)) {
res.push_back(hname_t(comp.name, ctmp->value().as_long()));
delete ctmp;
continue;
}
return res;
}
return res;
}
/* /*
* $Log: netmisc.cc,v $ * $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 * Revision 1.13 2007/03/08 05:30:03 steve
* Limit the calculated widths of constants. * 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 * Remove the NetEBitSel and combine all bit/part select
* behavior into the NetESelect node and IVL_EX_SELECT * behavior into the NetESelect node and IVL_EX_SELECT
* ivl_target expression type. * 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.
*
*/ */

View File

@ -19,7 +19,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/ */
#ifdef HAVE_CVS_IDENT #ifdef HAVE_CVS_IDENT
#ident "$Id: 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 #endif
# include "netlist.h" # include "netlist.h"
@ -39,14 +39,14 @@
* ex2 is the lsb expression for the range. If there is no range, then * ex2 is the lsb expression for the range. If there is no range, then
* these values are set to 0. * 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, NetScope*start, pform_name_t path,
NetNet*&net, /* net/reg */ NetNet*&net, /* net/reg */
const NetExpr*&par,/* parameter */ const NetExpr*&par,/* parameter */
NetEvent*&eve, /* named event */ NetEvent*&eve, /* named event */
const NetExpr*&ex1, const NetExpr*&ex2); 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, NetScope*start, const pform_name_t&path,
NetNet*&net, /* net/reg */ NetNet*&net, /* net/reg */
const NetExpr*&par,/* parameter */ const NetExpr*&par,/* parameter */
@ -123,8 +123,14 @@ extern NetExpr* elab_and_eval(Design*des, NetScope*scope,
const PExpr*pe, int expr_wid, const PExpr*pe, int expr_wid,
int prune_width =-1); int prune_width =-1);
extern std::list<hname_t> eval_scope_path(Design*des, NetScope*scope,
const pform_name_t&path);
/* /*
* $Log: netmisc.h,v $ * $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 * Revision 1.30 2007/05/24 04:07:12 steve
* Rework the heirarchical identifier parse syntax and pform * Rework the heirarchical identifier parse syntax and pform
* to handle more general combinations of heirarch and bit selects. * to handle more general combinations of heirarch and bit selects.

View File

@ -17,7 +17,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/ */
#ifdef HAVE_CVS_IDENT #ifdef HAVE_CVS_IDENT
#ident "$Id: pform.cc,v 1.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 #endif
# include "config.h" # include "config.h"
@ -348,7 +348,7 @@ void pform_start_generate_for(const struct vlltype&li,
gen->set_lineno(li.first_line); gen->set_lineno(li.first_line);
// For now, assume that generates do not nest. // 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 = gen;
pform_cur_generate->scheme_type = PGenerate::GS_LOOP; pform_cur_generate->scheme_type = PGenerate::GS_LOOP;
@ -375,8 +375,13 @@ void pform_endgenerate()
assert(pform_cur_generate != 0); assert(pform_cur_generate != 0);
assert(pform_cur_module); assert(pform_cur_module);
pform_cur_module->generate_schemes.push_back(pform_cur_generate); PGenerate*cur = pform_cur_generate;
pform_cur_generate = 0; 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) bool pform_expression_is_constant(const PExpr*ex)
@ -1773,6 +1778,9 @@ int pform_parse(const char*path, FILE*file)
/* /*
* $Log: pform.cc,v $ * $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 * Revision 1.146 2007/05/24 04:07:12 steve
* Rework the heirarchical identifier parse syntax and pform * Rework the heirarchical identifier parse syntax and pform
* to handle more general combinations of heirarch and bit selects. * to handle more general combinations of heirarch and bit selects.

View File

@ -17,7 +17,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/ */
#ifdef HAVE_CVS_IDENT #ifdef HAVE_CVS_IDENT
#ident "$Id: pform_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 #endif
# include "config.h" # include "config.h"
@ -817,9 +817,9 @@ void PSpecPath::dump(std::ostream&out, unsigned ind) const
out << ");" << endl; 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) { switch (scheme_type) {
case GS_NONE: case GS_NONE:
@ -844,17 +844,22 @@ void PGenerate::dump(ostream&out) const
for (map<pform_name_t,PWire*>::const_iterator idx = wires.begin() for (map<pform_name_t,PWire*>::const_iterator idx = wires.begin()
; idx != wires.end() ; idx++) { ; idx != wires.end() ; idx++) {
(*idx).second->dump(out, 6); (*idx).second->dump(out, indent+2);
} }
for (list<PGate*>::const_iterator idx = gates.begin() for (list<PGate*>::const_iterator idx = gates.begin()
; idx != gates.end() ; idx++) { ; idx != gates.end() ; idx++) {
(*idx)->dump(out, 6); (*idx)->dump(out, indent+2);
} }
for (list<PProcess*>::const_iterator idx = behaviors.begin() for (list<PProcess*>::const_iterator idx = behaviors.begin()
; idx != behaviors.end() ; idx++) { ; idx != behaviors.end() ; idx++) {
(*idx)->dump(out, 6); (*idx)->dump(out, indent+2);
}
for (list<PGenerate*>::const_iterator idx = generates.begin()
; idx != generates.end() ; idx++) {
(*idx)->dump(out, indent+2);
} }
out << " endgenerate" << endl; out << " endgenerate" << endl;
@ -934,7 +939,7 @@ void Module::dump(ostream&out) const
typedef list<PGenerate*>::const_iterator genscheme_iter_t; typedef list<PGenerate*>::const_iterator genscheme_iter_t;
for (genscheme_iter_t cur = generate_schemes.begin() for (genscheme_iter_t cur = generate_schemes.begin()
; cur != generate_schemes.end() ; cur++) { ; cur != generate_schemes.end() ; cur++) {
(*cur)->dump(out); (*cur)->dump(out, 4);
} }
typedef map<perm_string,PExpr*>::const_iterator specparm_iter_t; typedef map<perm_string,PExpr*>::const_iterator specparm_iter_t;
@ -1062,6 +1067,9 @@ void PUdp::dump(ostream&out) const
/* /*
* $Log: pform_dump.cc,v $ * $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 * Revision 1.99 2007/05/31 18:35:50 steve
* Missing return value to perm_string dump * Missing return value to perm_string dump
* *

View File

@ -17,17 +17,18 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/ */
#ifdef HAVE_CVS_IDENT #ifdef HAVE_CVS_IDENT
#ident "$Id: symbol_search.cc,v 1.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 #endif
# include "netlist.h" # include "netlist.h"
# include "netmisc.h"
# include <assert.h> # include <assert.h>
/* /*
* Search for the hierarchical name. * 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, NetNet*&net,
const NetExpr*&par, const NetExpr*&par,
NetEvent*&eve, 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 /* If the path has a scope part, then search for the specified
scope that we are supposed to search. */ scope that we are supposed to search. */
if (! path.empty()) if (! path.empty()) {
scope = des->find_scope(scope, path); list<hname_t> path_list = eval_scope_path(des, scope, path);
assert(path_list.size() == path.size());
scope = des->find_scope(scope, path_list);
}
while (scope) { while (scope) {
if ( (net = scope->find_signal(key)) ) if ( (net = scope->find_signal(key)) )
@ -68,8 +72,12 @@ NetScope*symbol_search(const Design*des, NetScope*scope, pform_name_t path,
return 0; return 0;
} }
/* /*
* $Log: symbol_search.cc,v $ * $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 * Revision 1.6 2007/05/24 04:07:12 steve
* Rework the heirarchical identifier parse syntax and pform * Rework the heirarchical identifier parse syntax and pform
* to handle more general combinations of heirarch and bit selects. * to handle more general combinations of heirarch and bit selects.

View File

@ -18,7 +18,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/ */
#ifdef HAVE_CVS_IDENT #ifdef HAVE_CVS_IDENT
#ident "$Id: 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 #endif
# include "config.h" # include "config.h"
@ -131,7 +131,7 @@ bool dll_target::func_def(const NetScope*net)
} }
cerr << "?:0" << ": internal error: " cerr << "?:0" << ": internal error: "
<< "Function " << net->name() << " has a return type" << "Function " << net->basename() << " has a return type"
<< " that I do not understand." << endl; << " that I do not understand." << endl;
return false; return false;
@ -641,6 +641,8 @@ bool dll_target::proc_wait(const NetEvWait*net)
ivl_scope_t ev_scope = lookup_scope_(ev->scope()); ivl_scope_t ev_scope = lookup_scope_(ev->scope());
ivl_event_t ev_tmp=0; ivl_event_t ev_tmp=0;
assert(ev_scope);
assert(ev_scope->nevent_ > 0);
for (unsigned idx = 0 ; idx < ev_scope->nevent_ ; idx += 1) { for (unsigned idx = 0 ; idx < ev_scope->nevent_ ; idx += 1) {
const char*ename = ivl_event_basename(ev_scope->event_[idx]); const char*ename = ivl_event_basename(ev_scope->event_[idx]);
if (strcmp(ev->name(), ename) == 0) { if (strcmp(ev->name(), ename) == 0) {
@ -735,6 +737,9 @@ void dll_target::proc_while(const NetWhile*net)
/* /*
* $Log: t-dll-proc.cc,v $ * $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 * Revision 1.70 2007/04/04 01:50:38 steve
* t-dll should not canonicalize word addresses, elaboration already does it. * t-dll should not canonicalize word addresses, elaboration already does it.
* *

103
t-dll.cc
View File

@ -17,7 +17,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/ */
#ifdef HAVE_CVS_IDENT #ifdef HAVE_CVS_IDENT
#ident "$Id: 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 #endif
# include "config.h" # include "config.h"
@ -134,6 +134,17 @@ inline static const char *basename(ivl_scope_t scope, const char *inst)
return inst+1; 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 struct dll_target dll_target_obj;
static void drive_from_link(const Link&lnk, ivl_drive_t&drv0, ivl_drive_t&drv1) 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) static ivl_scope_t find_scope_from_root(ivl_scope_t root, const NetScope*cur)
{ {
ivl_scope_t parent, tmp; ivl_scope_t parent, tmp;
perm_string cur_name = make_scope_name(cur->fullname());
if (const NetScope*par = cur->parent()) { if (const NetScope*par = cur->parent()) {
parent = find_scope_from_root(root, par); 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; return 0;
for (tmp = parent->child_ ; tmp ; tmp = tmp->sibling_) for (tmp = parent->child_ ; tmp ; tmp = tmp->sibling_)
if (strcmp(tmp->name_, cur->basename()) == 0) if (strcmp(tmp->name_, cur_name) == 0)
return tmp; return tmp;
} else { } else {
if (strcmp(root->name_, cur->basename()) == 0) if (strcmp(root->name_, cur_name) == 0)
return root; 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) 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) { if (scope->nparam_ == 0) {
scope->param_ = 0; scope->param_ = 0;
return; return;
@ -462,37 +474,52 @@ void dll_target::make_scope_parameters(ivl_scope_t scope, const NetScope*net)
cur_par->scope = scope; cur_par->scope = scope;
NetExpr*etmp = (*cur_pit).second.expr; NetExpr*etmp = (*cur_pit).second.expr;
make_scope_param_expr(cur_par, etmp);
if (const NetEConst*e = dynamic_cast<const NetEConst*>(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<const NetECReal*>(etmp)) {
expr_creal(e);
assert(expr_);
assert(expr_->type_ == IVL_EX_REALNUM);
expr_->u_.real_.parameter = cur_par;
}
cur_par->value = expr_;
expr_ = 0;
idx += 1; 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<const NetEConst*>(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<const NetECReal*>(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) 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); assert(scope);
} else { } else {
perm_string sname = make_scope_name(net->fullname());
scope = new struct ivl_scope_s; scope = new struct ivl_scope_s;
scope->name_ = net->basename(); scope->name_ = sname;
scope->child_ = 0; scope->child_ = 0;
scope->sibling_ = 0; scope->sibling_ = 0;
scope->parent = find_scope(des_, net->parent()); scope->parent = find_scope(des_, net->parent());
@ -1985,12 +2013,12 @@ void dll_target::scope(const NetScope*net)
} }
assert(def); assert(def);
scope->type_ = IVL_SCT_TASK; scope->type_ = IVL_SCT_TASK;
scope->tname_ = strings_.make(def->name().c_str()); scope->tname_ = def->scope()->basename();
break; break;
} }
case NetScope::FUNC: case NetScope::FUNC:
scope->type_ = IVL_SCT_FUNCTION; scope->type_ = IVL_SCT_FUNCTION;
scope->tname_ = strings_.make(net->func_def()->name().c_str()); scope->tname_ = net->func_def()->scope()->basename();
break; break;
case NetScope::BEGIN_END: case NetScope::BEGIN_END:
scope->type_ = IVL_SCT_BEGIN; scope->type_ = IVL_SCT_BEGIN;
@ -2227,6 +2255,9 @@ extern const struct target tgt_dll = { "dll", &dll_target_obj };
/* /*
* $Log: t-dll.cc,v $ * $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 * Revision 1.170 2007/04/02 01:12:34 steve
* Seperate arrayness from word count * Seperate arrayness from word count
* *

View File

@ -19,7 +19,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/ */
#ifdef HAVE_CVS_IDENT #ifdef HAVE_CVS_IDENT
#ident "$Id: 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 #endif
# include "target.h" # 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_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_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); static ivl_expr_t expr_from_value_(const verinum&that);
}; };
@ -679,6 +680,9 @@ struct ivl_statement_s {
/* /*
* $Log: t-dll.h,v $ * $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 * Revision 1.142 2007/04/02 01:12:34 steve
* Seperate arrayness from word count * Seperate arrayness from word count
* *

View File

@ -17,7 +17,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/ */
#ifdef HAVE_CVS_IDENT #ifdef HAVE_CVS_IDENT
#ident "$Id: 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 #endif
# include "config.h" # include "config.h"
@ -38,7 +38,7 @@ void target_t::scope(const NetScope*)
void target_t::event(const NetEvent*ev) void target_t::event(const NetEvent*ev)
{ {
cerr << ev->get_line() << ": error: target (" << typeid(*this).name() 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*) bool target_t::signal_paths(const NetNet*)
@ -429,6 +429,9 @@ void expr_scan_t::expr_binary(const NetEBinary*ex)
/* /*
* $Log: target.cc,v $ * $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 * Revision 1.80 2007/01/16 05:44:16 steve
* Major rework of array handling. Memories are replaced with the * Major rework of array handling. Memories are replaced with the
* more general concept of arrays. The NetMemory and NetEMemory * more general concept of arrays. The NetMemory and NetEMemory