Exressions are trees that can duplicate, and not DAGS.

This commit is contained in:
steve 1999-05-30 01:11:46 +00:00
parent 35893919e0
commit 982cce6086
5 changed files with 134 additions and 154 deletions

View File

@ -17,7 +17,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/ */
#if !defined(WINNT) #if !defined(WINNT)
#ident "$Id: design_dump.cc,v 1.24 1999/05/17 04:53:47 steve Exp $" #ident "$Id: design_dump.cc,v 1.25 1999/05/30 01:11:46 steve Exp $"
#endif #endif
/* /*
@ -123,7 +123,7 @@ void NetObj::dump_obj_attr(ostream&o, unsigned ind) const
void NetAssign::dump_node(ostream&o, unsigned ind) const void NetAssign::dump_node(ostream&o, unsigned ind) const
{ {
o << setw(ind) << "" << "Procedural assign: " << *rval_.ref() << endl; o << setw(ind) << "" << "Procedural assign: " << *rval_ << endl;
dump_node_pins(o, ind+4); dump_node_pins(o, ind+4);
} }
@ -330,12 +330,12 @@ void NetBlock::dump(ostream&o, unsigned ind) const
void NetCase::dump(ostream&o, unsigned ind) const void NetCase::dump(ostream&o, unsigned ind) const
{ {
o << setw(ind) << "" << "case (" << *expr_.ref() << ")" << endl; o << setw(ind) << "" << "case (" << *expr_ << ")" << endl;
for (unsigned idx = 0 ; idx < nitems_ ; idx += 1) { for (unsigned idx = 0 ; idx < nitems_ ; idx += 1) {
o << setw(ind+2) << ""; o << setw(ind+2) << "";
if (items_[idx].guard.ref()) if (items_[idx].guard)
o << *items_[idx].guard.ref() << ":"; o << *items_[idx].guard << ":";
else else
o << "default:"; o << "default:";
@ -421,12 +421,12 @@ void NetTask::dump(ostream&o, unsigned ind) const
if (nparms_ > 0) { if (nparms_ > 0) {
o << "("; o << "(";
if (parms_[0].ref()) if (parms_[0])
parms_[0]->dump(o); parms_[0]->dump(o);
for (unsigned idx = 1 ; idx < nparms_ ; idx += 1) { for (unsigned idx = 1 ; idx < nparms_ ; idx += 1) {
o << ", "; o << ", ";
if (parms_[idx].ref()) if (parms_[idx])
parms_[idx]->dump(o); parms_[idx]->dump(o);
} }
@ -437,7 +437,7 @@ void NetTask::dump(ostream&o, unsigned ind) const
void NetWhile::dump(ostream&o, unsigned ind) const void NetWhile::dump(ostream&o, unsigned ind) const
{ {
o << setw(ind) << "" << "while (" << *cond_.ref() << ")" << endl; o << setw(ind) << "" << "while (" << *cond_ << ")" << endl;
proc_->dump(o, ind+3); proc_->dump(o, ind+3);
} }
@ -549,11 +549,11 @@ void Design::dump(ostream&o) const
{ {
o << "ELABORATED PARAMETERS:" << endl; o << "ELABORATED PARAMETERS:" << endl;
{ {
map<string,NetExpr::REF>::const_iterator pp; map<string,NetExpr*>::const_iterator pp;
for (pp = parameters_.begin() for (pp = parameters_.begin()
; pp != parameters_.end() ; pp ++) { ; pp != parameters_.end() ; pp ++) {
o << " " << (*pp).first << " = " << o << " " << (*pp).first << " = " <<
*(*pp).second.ref() << ";" << endl; *(*pp).second << ";" << endl;
} }
} }
@ -598,6 +598,9 @@ void Design::dump(ostream&o) const
/* /*
* $Log: design_dump.cc,v $ * $Log: design_dump.cc,v $
* Revision 1.25 1999/05/30 01:11:46 steve
* Exressions are trees that can duplicate, and not DAGS.
*
* Revision 1.24 1999/05/17 04:53:47 steve * Revision 1.24 1999/05/17 04:53:47 steve
* translate the letter synonyms for operators. * translate the letter synonyms for operators.
* *

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
*/ */
#if !defined(WINNT) #if !defined(WINNT)
#ident "$Id: elaborate.cc,v 1.29 1999/05/29 02:36:17 steve Exp $" #ident "$Id: elaborate.cc,v 1.30 1999/05/30 01:11:46 steve Exp $"
#endif #endif
/* /*
@ -831,8 +831,8 @@ NetExpr*PEIdent::elaborate_expr(Design*des, const string&path) const
// If the identifier name a paramter name, then return // If the identifier name a paramter name, then return
// the expression that it represents. // the expression that it represents.
if (NetExpr*ex = des->get_parameter(name)) if (const NetExpr*ex = des->get_parameter(name))
return ex; return ex->dup_expr();
// If the identifier names a signal (a register or wire) // If the identifier names a signal (a register or wire)
// then create a NetESignal node to handle it. // then create a NetESignal node to handle it.
@ -1247,6 +1247,9 @@ Design* elaborate(const map<string,Module*>&modules,
/* /*
* $Log: elaborate.cc,v $ * $Log: elaborate.cc,v $
* Revision 1.30 1999/05/30 01:11:46 steve
* Exressions are trees that can duplicate, and not DAGS.
*
* Revision 1.29 1999/05/29 02:36:17 steve * Revision 1.29 1999/05/29 02:36:17 steve
* module parameter bind by name. * module parameter bind by name.
* *

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
*/ */
#if !defined(WINNT) #if !defined(WINNT)
#ident "$Id: eval.cc,v 1.2 1999/05/10 00:16:58 steve Exp $" #ident "$Id: eval.cc,v 1.3 1999/05/30 01:11:46 steve Exp $"
#endif #endif
# include "PExpr.h" # include "PExpr.h"
@ -59,9 +59,9 @@ verinum* PEBinary::eval_const(const Design*des, const string&path) const
verinum* PEIdent::eval_const(const Design*des, const string&path) const verinum* PEIdent::eval_const(const Design*des, const string&path) const
{ {
assert(msb_ == 0); assert(msb_ == 0);
NetExpr*expr = des->get_parameter(path + "." + text_); const NetExpr*expr = des->get_parameter(path + "." + text_);
if (expr == 0) return 0; if (expr == 0) return 0;
NetEConst*eval = dynamic_cast<NetEConst*>(expr); const NetEConst*eval = dynamic_cast<const NetEConst*>(expr);
assert(eval); assert(eval);
return new verinum(eval->value()); return new verinum(eval->value());
} }
@ -73,6 +73,9 @@ verinum* PENumber::eval_const(const Design*, const string&) const
/* /*
* $Log: eval.cc,v $ * $Log: eval.cc,v $
* Revision 1.3 1999/05/30 01:11:46 steve
* Exressions are trees that can duplicate, and not DAGS.
*
* Revision 1.2 1999/05/10 00:16:58 steve * Revision 1.2 1999/05/10 00:16:58 steve
* Parse and elaborate the concatenate operator * Parse and elaborate the concatenate operator
* in structural contexts, Replace vector<PExpr*> * in structural contexts, Replace vector<PExpr*>

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
*/ */
#if !defined(WINNT) #if !defined(WINNT)
#ident "$Id: netlist.cc,v 1.28 1999/05/27 04:13:08 steve Exp $" #ident "$Id: netlist.cc,v 1.29 1999/05/30 01:11:46 steve Exp $"
#endif #endif
# include <cassert> # include <cassert>
@ -358,7 +358,7 @@ void NetBlock::append(NetProc*cur)
NetCase::NetCase(NetExpr*ex, unsigned cnt) NetCase::NetCase(NetExpr*ex, unsigned cnt)
: expr_(ex), nitems_(cnt) : expr_(ex), nitems_(cnt)
{ {
assert(expr_.ref()); assert(expr_);
items_ = new Item[nitems_]; items_ = new Item[nitems_];
for (unsigned idx = 0 ; idx < nitems_ ; idx += 1) { for (unsigned idx = 0 ; idx < nitems_ ; idx += 1) {
items_[idx].statement = 0; items_[idx].statement = 0;
@ -367,9 +367,9 @@ NetCase::NetCase(NetExpr*ex, unsigned cnt)
NetCase::~NetCase() NetCase::~NetCase()
{ {
expr_.clr_and_delete(); delete expr_;
for (unsigned idx = 0 ; idx < nitems_ ; idx += 1) { for (unsigned idx = 0 ; idx < nitems_ ; idx += 1) {
items_[idx].guard.clr_and_delete(); delete items_[idx].guard;
if (items_[idx].statement) delete items_[idx].statement; if (items_[idx].statement) delete items_[idx].statement;
} }
delete[]items_; delete[]items_;
@ -380,14 +380,14 @@ void NetCase::set_case(unsigned idx, NetExpr*e, NetProc*p)
assert(idx < nitems_); assert(idx < nitems_);
items_[idx].guard = e; items_[idx].guard = e;
items_[idx].statement = p; items_[idx].statement = p;
if (items_[idx].guard.ref()) if (items_[idx].guard)
items_[idx].guard.ref()->set_width(expr_.ref()->expr_width()); items_[idx].guard->set_width(expr_->expr_width());
} }
NetTask::~NetTask() NetTask::~NetTask()
{ {
for (unsigned idx = 0 ; idx < nparms_ ; idx += 1) for (unsigned idx = 0 ; idx < nparms_ ; idx += 1)
parms_[idx].clr_and_delete(); delete parms_[idx];
delete[]parms_; delete[]parms_;
} }
@ -404,62 +404,15 @@ bool NetExpr::set_width(unsigned w)
return false; return false;
} }
void NetExpr::REF::clr() NetEBinary::NetEBinary(char op, NetExpr*l, NetExpr*r)
: op_(op), left_(l), right_(r)
{ {
if (ref_ == 0)
return;
NetExpr*ref = ref_;
ref_ = 0;
if (ref->reflist_ == this) {
ref->reflist_ = next_;
return;
}
NetExpr::REF*cur;
for (cur = ref->reflist_ ; cur->next_ != this ; cur = cur->next_) {
assert(cur->next_);
}
cur->next_ = next_;
}
void NetExpr::REF::set(NetExpr*that)
{
clr();
if (that == 0) return;
ref_ = that;
next_ = that->reflist_;
that->reflist_ = this;
}
void NetExpr::substitute(NetExpr*that)
{
if (reflist_ == 0)
return;
REF*cur = reflist_;
while (cur->next_) {
cur->ref_ = that;
cur = cur->next_;
}
cur->next_ = that->reflist_;
cur->ref_ = that;
that->reflist_ = reflist_;
reflist_ = 0;
} }
NetEBinary::~NetEBinary() NetEBinary::~NetEBinary()
{ {
left_.clr_and_delete(); delete left_;
right_.clr_and_delete(); delete right_;
}
NetEBinary::NetEBinary(char op, NetExpr*l, NetExpr*r)
: op_(op), left_(l), right_(r)
{
} }
bool NetEBinary::set_width(unsigned w) bool NetEBinary::set_width(unsigned w)
@ -510,6 +463,11 @@ bool NetEBinary::set_width(unsigned w)
return flag; return flag;
} }
NetEBinary* NetEBinary::dup_expr() const
{
assert(0);
}
NetEConst::~NetEConst() NetEConst::~NetEConst()
{ {
} }
@ -527,6 +485,18 @@ bool NetEConst::set_width(unsigned w)
return true; return true;
} }
NetEConst* NetEConst::dup_expr() const
{
NetEConst*tmp = new NetEConst(value_);
tmp->set_line(*this);
return tmp;
}
NetEIdent* NetEIdent::dup_expr() const
{
assert(0);
}
NetEMemory::NetEMemory(NetMemory*m, NetExpr*i) NetEMemory::NetEMemory(NetMemory*m, NetExpr*i)
: mem_(m), idx_(i) : mem_(m), idx_(i)
{ {
@ -549,6 +519,11 @@ bool NetEMemory::set_width(unsigned w)
return true; return true;
} }
NetEMemory* NetEMemory::dup_expr() const
{
assert(0);
}
NetESignal::NetESignal(NetNet*n) NetESignal::NetESignal(NetNet*n)
: NetExpr(n->pin_count()), NetNode(n->name(), n->pin_count()) : NetExpr(n->pin_count()), NetNode(n->name(), n->pin_count())
{ {
@ -573,6 +548,11 @@ bool NetESignal::set_width(unsigned w)
return true; return true;
} }
NetESignal* NetESignal::dup_expr() const
{
assert(0);
}
NetESubSignal::NetESubSignal(NetESignal*sig, NetExpr*ex) NetESubSignal::NetESubSignal(NetESignal*sig, NetExpr*ex)
: sig_(sig), idx_(ex) : sig_(sig), idx_(ex)
{ {
@ -580,12 +560,17 @@ NetESubSignal::NetESubSignal(NetESignal*sig, NetExpr*ex)
NetESubSignal::~NetESubSignal() NetESubSignal::~NetESubSignal()
{ {
idx_.clr_and_delete(); delete idx_;
}
NetESubSignal* NetESubSignal::dup_expr() const
{
assert(0);
} }
NetEUnary::~NetEUnary() NetEUnary::~NetEUnary()
{ {
expr_.clr_and_delete(); delete expr_;
} }
bool NetEUnary::set_width(unsigned w) bool NetEUnary::set_width(unsigned w)
@ -609,6 +594,11 @@ bool NetEUnary::set_width(unsigned w)
return flag; return flag;
} }
NetEUnary* NetEUnary::dup_expr() const
{
assert(0);
}
NetLogic::NetLogic(const string&n, unsigned pins, TYPE t) NetLogic::NetLogic(const string&n, unsigned pins, TYPE t)
: NetNode(n, pins), type_(t) : NetNode(n, pins), type_(t)
{ {
@ -892,13 +882,13 @@ void Design::set_parameter(const string&key, NetExpr*expr)
parameters_[key] = expr; parameters_[key] = expr;
} }
NetExpr* Design::get_parameter(const string&key) const const NetExpr* Design::get_parameter(const string&key) const
{ {
map<string,NetExpr::REF>::const_iterator cur = parameters_.find(key); map<string,NetExpr*>::const_iterator cur = parameters_.find(key);
if (cur == parameters_.end()) if (cur == parameters_.end())
return 0; return 0;
else else
return (*cur).second.ref(); return (*cur).second;
} }
string Design::get_flag(const string&key) const string Design::get_flag(const string&key) const
@ -1078,6 +1068,9 @@ NetNet* Design::find_signal(bool (*func)(const NetNet*))
/* /*
* $Log: netlist.cc,v $ * $Log: netlist.cc,v $
* Revision 1.29 1999/05/30 01:11:46 steve
* Exressions are trees that can duplicate, and not DAGS.
*
* Revision 1.28 1999/05/27 04:13:08 steve * Revision 1.28 1999/05/27 04:13:08 steve
* Handle expression bit widths with non-fatal errors. * Handle expression bit widths with non-fatal errors.
* *

128
netlist.h
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
*/ */
#if !defined(WINNT) #if !defined(WINNT)
#ident "$Id: netlist.h,v 1.32 1999/05/27 04:13:08 steve Exp $" #ident "$Id: netlist.h,v 1.33 1999/05/30 01:11:46 steve Exp $"
#endif #endif
/* /*
@ -322,15 +322,10 @@ class NetMemory {
* set_width() method is used to compel an expression to have a * set_width() method is used to compel an expression to have a
* certain width, and is used particulary when the expression is an * certain width, and is used particulary when the expression is an
* rvalue in an assignment statement. * rvalue in an assignment statement.
*
* The NetExpr::REF type can be used sort of like a pointer to
* NetExpr objects. The NetExpr uses this list to know if it is still
* being referenced, so can handle garbage collection. Also, this
* trick can be used to replace subexpressions.
*/ */
class NetExpr : public LineInfo { class NetExpr : public LineInfo {
public: public:
explicit NetExpr(unsigned w =0) : width_(w), reflist_(0) { } explicit NetExpr(unsigned w =0) : width_(w) { }
virtual ~NetExpr() =0; virtual ~NetExpr() =0;
virtual void expr_scan(struct expr_scan_t*) const =0; virtual void expr_scan(struct expr_scan_t*) const =0;
@ -343,42 +338,9 @@ class NetExpr : public LineInfo {
// coersion works, then return true. Otherwise, return false. // coersion works, then return true. Otherwise, return false.
virtual bool set_width(unsigned); virtual bool set_width(unsigned);
public: // Make a duplicate of myself, and subexpressions if I have
class REF { // any. This is a deep copy operation.
friend class NetExpr; virtual NetExpr*dup_expr() const =0;
public:
void clr();
void set(NetExpr*);
NetExpr*ref() const { return ref_; }
void clr_and_delete()
{ NetExpr*tmp = ref_;
clr();
if (tmp && tmp->is_referenced() == false)
delete tmp;
}
NetExpr*operator-> () const { return ref_; }
REF& operator=(NetExpr*that) { set(that); return *this; }
REF() : ref_(0), next_(0) { }
REF(NetExpr*that) : ref_(0), next_(0) { set(that); }
REF(const REF&that) : ref_(0), next_(0) { set(that.ref_); }
~REF() { clr(); }
private:
NetExpr*ref_;
REF*next_;
private:// not implemented
REF& operator=(const REF&);
};
friend class NetExpr::REF;
/* This method causes every item that references this object
to reference that object instead. When this complete,
no references to me will remain. */
void substitute(NetExpr*that);
bool is_referenced() const { return reflist_ != 0; }
protected: protected:
void expr_width(unsigned w) { width_ = w; } void expr_width(unsigned w) { width_ = w; }
@ -386,8 +348,6 @@ class NetExpr : public LineInfo {
private: private:
unsigned width_; unsigned width_;
REF*reflist_;
private: // not implemented private: // not implemented
NetExpr(const NetExpr&); NetExpr(const NetExpr&);
NetExpr& operator=(const NetExpr&); NetExpr& operator=(const NetExpr&);
@ -605,7 +565,7 @@ class NetAssign : public NetProc, public NetNode, public LineInfo {
explicit NetAssign(Design*des, NetNet*lv, NetExpr*rv); explicit NetAssign(Design*des, NetNet*lv, NetExpr*rv);
~NetAssign(); ~NetAssign();
const NetExpr*rval() const { return rval_.ref(); } const NetExpr*rval() const { return rval_; }
void find_lval_range(const NetNet*&net, unsigned&msb, void find_lval_range(const NetNet*&net, unsigned&msb,
unsigned&lsb) const; unsigned&lsb) const;
@ -616,7 +576,7 @@ class NetAssign : public NetProc, public NetNode, public LineInfo {
virtual void dump_node(ostream&, unsigned ind) const; virtual void dump_node(ostream&, unsigned ind) const;
private: private:
NetExpr::REF rval_; NetExpr* rval_;
}; };
/* /*
@ -630,16 +590,16 @@ class NetAssignMem : public NetProc, public LineInfo {
~NetAssignMem(); ~NetAssignMem();
const NetMemory*memory()const { return mem_; } const NetMemory*memory()const { return mem_; }
const NetExpr*index()const { return index_.ref(); } const NetExpr*index()const { return index_; }
const NetExpr*rval()const { return rval_.ref(); } const NetExpr*rval()const { return rval_; }
virtual void emit_proc(ostream&, struct target_t*) const; virtual void emit_proc(ostream&, struct target_t*) const;
virtual void dump(ostream&, unsigned ind) const; virtual void dump(ostream&, unsigned ind) const;
private: private:
NetMemory*mem_; NetMemory*mem_;
NetExpr::REF index_; NetExpr* index_;
NetExpr::REF rval_; NetExpr* rval_;
}; };
/* A block is stuff line begin-end blocks, that contain and ordered /* A block is stuff line begin-end blocks, that contain and ordered
@ -682,10 +642,10 @@ class NetCase : public NetProc {
void set_case(unsigned idx, NetExpr*ex, NetProc*st); void set_case(unsigned idx, NetExpr*ex, NetProc*st);
const NetExpr*expr() const { return expr_.ref(); } const NetExpr*expr() const { return expr_; }
unsigned nitems() const { return nitems_; } unsigned nitems() const { return nitems_; }
const NetExpr*expr(unsigned idx) const { return items_[idx].guard.ref();} const NetExpr*expr(unsigned idx) const { return items_[idx].guard;}
const NetProc*stat(unsigned idx) const { return items_[idx].statement; } const NetProc*stat(unsigned idx) const { return items_[idx].statement; }
virtual void emit_proc(ostream&, struct target_t*) const; virtual void emit_proc(ostream&, struct target_t*) const;
@ -694,11 +654,11 @@ class NetCase : public NetProc {
private: private:
struct Item { struct Item {
NetExpr::REF guard; NetExpr*guard;
NetProc*statement; NetProc*statement;
}; };
NetExpr::REF expr_; NetExpr* expr_;
unsigned nitems_; unsigned nitems_;
Item*items_; Item*items_;
}; };
@ -712,7 +672,7 @@ class NetCondit : public NetProc {
NetCondit(NetExpr*ex, NetProc*i, NetProc*e) NetCondit(NetExpr*ex, NetProc*i, NetProc*e)
: expr_(ex), if_(i), else_(e) { } : expr_(ex), if_(i), else_(e) { }
NetExpr*expr() const { return expr_.ref(); } const NetExpr*expr() const { return expr_; }
void emit_recurse_if(ostream&, struct target_t*) const; void emit_recurse_if(ostream&, struct target_t*) const;
void emit_recurse_else(ostream&, struct target_t*) const; void emit_recurse_else(ostream&, struct target_t*) const;
@ -720,7 +680,7 @@ class NetCondit : public NetProc {
virtual void dump(ostream&, unsigned ind) const; virtual void dump(ostream&, unsigned ind) const;
private: private:
NetExpr::REF expr_; NetExpr* expr_;
NetProc*if_; NetProc*if_;
NetProc*else_; NetProc*else_;
}; };
@ -805,7 +765,7 @@ class NetTask : public NetProc {
public: public:
NetTask(const string&na, unsigned np) NetTask(const string&na, unsigned np)
: name_(na), nparms_(np) : name_(na), nparms_(np)
{ parms_ = new NetExpr::REF[nparms_]; } { parms_ = new NetExpr*[nparms_]; }
~NetTask(); ~NetTask();
const string& name() const { return name_; } const string& name() const { return name_; }
@ -817,9 +777,9 @@ class NetTask : public NetProc {
parms_[idx] = p; parms_[idx] = p;
} }
NetExpr* parm(unsigned idx) const const NetExpr* parm(unsigned idx) const
{ assert(idx < nparms_); { assert(idx < nparms_);
return parms_[idx].ref(); return parms_[idx];
} }
virtual void emit_proc(ostream&, struct target_t*) const; virtual void emit_proc(ostream&, struct target_t*) const;
@ -828,7 +788,7 @@ class NetTask : public NetProc {
private: private:
string name_; string name_;
unsigned nparms_; unsigned nparms_;
NetExpr::REF*parms_; NetExpr**parms_;
}; };
/* /*
@ -842,7 +802,7 @@ class NetWhile : public NetProc {
NetWhile(NetExpr*c, NetProc*p) NetWhile(NetExpr*c, NetProc*p)
: cond_(c), proc_(p) { } : cond_(c), proc_(p) { }
const NetExpr*expr() const { return cond_.ref(); } const NetExpr*expr() const { return cond_; }
void emit_proc_recurse(ostream&, struct target_t*) const; void emit_proc_recurse(ostream&, struct target_t*) const;
@ -850,7 +810,7 @@ class NetWhile : public NetProc {
virtual void dump(ostream&, unsigned ind) const; virtual void dump(ostream&, unsigned ind) const;
private: private:
NetExpr::REF cond_; NetExpr* cond_;
NetProc*proc_; NetProc*proc_;
}; };
@ -909,20 +869,22 @@ class NetEBinary : public NetExpr {
NetEBinary(char op, NetExpr*l, NetExpr*r); NetEBinary(char op, NetExpr*l, NetExpr*r);
~NetEBinary(); ~NetEBinary();
const NetExpr*left() const { return left_.ref(); } const NetExpr*left() const { return left_; }
const NetExpr*right() const { return right_.ref(); } const NetExpr*right() const { return right_; }
char op() const { return op_; } char op() const { return op_; }
virtual bool set_width(unsigned w); virtual bool set_width(unsigned w);
virtual NetEBinary* dup_expr() const;
virtual void expr_scan(struct expr_scan_t*) const; virtual void expr_scan(struct expr_scan_t*) const;
virtual void dump(ostream&) const; virtual void dump(ostream&) const;
private: private:
char op_; char op_;
NetExpr::REF left_; NetExpr* left_;
NetExpr::REF right_; NetExpr* right_;
}; };
class NetEConst : public NetExpr { class NetEConst : public NetExpr {
@ -938,6 +900,8 @@ class NetEConst : public NetExpr {
virtual void expr_scan(struct expr_scan_t*) const; virtual void expr_scan(struct expr_scan_t*) const;
virtual void dump(ostream&) const; virtual void dump(ostream&) const;
virtual NetEConst* dup_expr() const;
private: private:
verinum value_; verinum value_;
}; };
@ -958,16 +922,18 @@ class NetEUnary : public NetExpr {
~NetEUnary(); ~NetEUnary();
char op() const { return op_; } char op() const { return op_; }
const NetExpr* expr() const { return expr_.ref(); } const NetExpr* expr() const { return expr_; }
virtual bool set_width(unsigned w); virtual bool set_width(unsigned w);
virtual NetEUnary* dup_expr() const;
virtual void expr_scan(struct expr_scan_t*) const; virtual void expr_scan(struct expr_scan_t*) const;
virtual void dump(ostream&) const; virtual void dump(ostream&) const;
private: private:
char op_; char op_;
NetExpr::REF expr_; NetExpr* expr_;
}; };
/* System identifiers are represented here. */ /* System identifiers are represented here. */
@ -979,6 +945,8 @@ class NetEIdent : public NetExpr {
const string& name() const { return name_; } const string& name() const { return name_; }
NetEIdent* dup_expr() const;
virtual void expr_scan(struct expr_scan_t*) const; virtual void expr_scan(struct expr_scan_t*) const;
virtual void dump(ostream&) const; virtual void dump(ostream&) const;
@ -996,15 +964,18 @@ class NetEMemory : public NetExpr {
virtual ~NetEMemory(); virtual ~NetEMemory();
const string& name () const { return mem_->name(); } const string& name () const { return mem_->name(); }
const NetExpr* index() const { return idx_.ref(); } const NetExpr* index() const { return idx_; }
virtual bool set_width(unsigned); virtual bool set_width(unsigned);
virtual NetEMemory*dup_expr() const;
virtual void expr_scan(struct expr_scan_t*) const; virtual void expr_scan(struct expr_scan_t*) const;
virtual void dump(ostream&) const; virtual void dump(ostream&) const;
private: private:
NetMemory*mem_; NetMemory*mem_;
NetExpr::REF idx_; NetExpr* idx_;
}; };
/* /*
@ -1025,6 +996,8 @@ class NetESignal : public NetExpr, public NetNode {
virtual bool set_width(unsigned); virtual bool set_width(unsigned);
virtual NetESignal* dup_expr() const;
virtual void expr_scan(struct expr_scan_t*) const; virtual void expr_scan(struct expr_scan_t*) const;
virtual void emit_node(ostream&, struct target_t*) const; virtual void emit_node(ostream&, struct target_t*) const;
virtual void dump(ostream&) const; virtual void dump(ostream&) const;
@ -1048,7 +1021,9 @@ class NetESubSignal : public NetExpr {
~NetESubSignal(); ~NetESubSignal();
const string&name() const { return sig_->name(); } const string&name() const { return sig_->name(); }
const NetExpr*index() const { return idx_.ref(); } const NetExpr*index() const { return idx_; }
NetESubSignal* dup_expr() const;
virtual void expr_scan(struct expr_scan_t*) const; virtual void expr_scan(struct expr_scan_t*) const;
virtual void dump(ostream&) const; virtual void dump(ostream&) const;
@ -1056,7 +1031,7 @@ class NetESubSignal : public NetExpr {
private: private:
// For now, only support single-bit selects of a signal. // For now, only support single-bit selects of a signal.
NetESignal*sig_; NetESignal*sig_;
NetExpr::REF idx_; NetExpr* idx_;
}; };
/* /*
@ -1082,7 +1057,7 @@ class Design {
// PARAMETERS // PARAMETERS
void set_parameter(const string&, NetExpr*); void set_parameter(const string&, NetExpr*);
NetExpr*get_parameter(const string&name) const; const NetExpr*get_parameter(const string&name) const;
// SIGNALS // SIGNALS
void add_signal(NetNet*); void add_signal(NetNet*);
@ -1123,7 +1098,7 @@ class Design {
private: private:
// List all the parameters in the design. This table includes // List all the parameters in the design. This table includes
// the parameters of instantiated modules in canonical names. // the parameters of instantiated modules in canonical names.
map<string,NetExpr::REF> parameters_; map<string,NetExpr*> parameters_;
// List all the signals in the design. // List all the signals in the design.
NetNet*signals_; NetNet*signals_;
@ -1190,6 +1165,9 @@ extern ostream& operator << (ostream&, NetNet::Type);
/* /*
* $Log: netlist.h,v $ * $Log: netlist.h,v $
* Revision 1.33 1999/05/30 01:11:46 steve
* Exressions are trees that can duplicate, and not DAGS.
*
* Revision 1.32 1999/05/27 04:13:08 steve * Revision 1.32 1999/05/27 04:13:08 steve
* Handle expression bit widths with non-fatal errors. * Handle expression bit widths with non-fatal errors.
* *