diff --git a/design_dump.cc b/design_dump.cc index 7f59480d1..c5a8ace6d 100644 --- a/design_dump.cc +++ b/design_dump.cc @@ -17,7 +17,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ #if !defined(WINNT) -#ident "$Id: design_dump.cc,v 1.46 1999/10/05 06:19:46 steve Exp $" +#ident "$Id: design_dump.cc,v 1.47 1999/10/06 05:06:16 steve Exp $" #endif /* @@ -130,7 +130,7 @@ void NetAddSub::dump_node(ostream&o, unsigned ind) const void NetAssign::dump_node(ostream&o, unsigned ind) const { o << setw(ind) << "" << "Procedural assign (NetAssign): " << - *rval_ << endl; + *rval() << endl; dump_node_pins(o, ind+4); } @@ -138,10 +138,10 @@ void NetAssignNB::dump_node(ostream&o, unsigned ind) const { if (bmux_) o << setw(ind) << "" << "Procedural NB assign (NetAssignNB): " - << name() << "[" << *bmux_ << "] <= " << *rval_ << endl; + << name() << "[" << *bmux_ << "] <= " << *rval() << endl; else o << setw(ind) << "" << "Procedural NB assign (NetAssignNB): " - << name() << " <= " << *rval_ << endl; + << name() << " <= " << *rval() << endl; dump_node_pins(o, ind+4); } @@ -340,10 +340,7 @@ void NetAssign::dump(ostream&o, unsigned ind) const o << sig->name() << "[" << msb; if (pin_count() > 1) o << ":" << lsb; - o << "] = "; - - rval_->dump(o); - o << ";" << endl; + o << "] = " << *rval() << ";" << endl; } void NetAssignNB::dump(ostream&o, unsigned ind) const @@ -354,13 +351,13 @@ void NetAssignNB::dump(ostream&o, unsigned ind) const o << name() << "[" << *bmux_ << "] <= "; if (rise_time()) o << "#" << rise_time() << " "; - o << *rval_ << ";" << endl; + o << *rval() << ";" << endl; } else { o << name() << " <= "; if (rise_time()) o << "#" << rise_time() << " "; - o << *rval_ << ";" << endl; + o << *rval() << ";" << endl; } } @@ -782,6 +779,9 @@ void Design::dump(ostream&o) const /* * $Log: design_dump.cc,v $ + * Revision 1.47 1999/10/06 05:06:16 steve + * Move the rvalue into NetAssign_ common code. + * * Revision 1.46 1999/10/05 06:19:46 steve * Add support for reduction NOR. * diff --git a/netlist.cc b/netlist.cc index c5c1dc1f1..65f464299 100644 --- a/netlist.cc +++ b/netlist.cc @@ -17,7 +17,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ #if !defined(WINNT) -#ident "$Id: netlist.cc,v 1.73 1999/10/05 04:02:10 steve Exp $" +#ident "$Id: netlist.cc,v 1.74 1999/10/06 05:06:16 steve Exp $" #endif # include @@ -382,7 +382,7 @@ NetObj::Link& NetAddSub::pin_Result(unsigned idx) } NetAssign_::NetAssign_(const string&n, unsigned w) -: NetNode(n, w) +: NetNode(n, w), rval_(0) { for (unsigned idx = 0 ; idx < pin_count() ; idx += 1) pin(idx).set_dir(NetObj::Link::OUTPUT); @@ -391,44 +391,63 @@ NetAssign_::NetAssign_(const string&n, unsigned w) NetAssign_::~NetAssign_() { + if (rval_) delete rval_; +} + +void NetAssign_::set_rval(NetExpr*r) +{ + rval_ = r; +} + +NetExpr* NetAssign_::rval() +{ + return rval_; +} + +const NetExpr* NetAssign_::rval() const +{ + return rval_; } NetAssign::NetAssign(const string&n, Design*des, unsigned w, NetExpr*rv) -: NetAssign_(n, w), rval_(rv) +: NetAssign_(n, w) { + set_rval(rv); } NetAssign::~NetAssign() { - delete rval_; } NetAssignNB::NetAssignNB(const string&n, Design*des, unsigned w, NetExpr*rv) -: NetAssign_(n, w), rval_(rv), bmux_(0) +: NetAssign_(n, w), bmux_(0) { - if (rval_->expr_width() < w) { + if (rv->expr_width() < w) { cerr << rv->get_line() << ": Expression bit width (" << - rval_->expr_width() << ") conflicts with l-value " + rv->expr_width() << ") conflicts with l-value " "bit width (" << w << ")." << endl; des->errors += 1; } + + set_rval(rv); } NetAssignNB::NetAssignNB(const string&n, Design*des, unsigned w, NetExpr*mu, NetExpr*rv) -: NetAssign_(n, w), rval_(rv), bmux_(mu) +: NetAssign_(n, w), bmux_(mu) { - bool flag = rval_->set_width(1); + bool flag = rv->set_width(1); if (flag == false) { cerr << rv->get_line() << ": Expression bit width" << " conflicts with l-value bit width." << endl; des->errors += 1; } + + set_rval(rv); } NetAssignNB::~NetAssignNB() { - delete rval_; delete bmux_; } @@ -1684,6 +1703,9 @@ NetNet* Design::find_signal(bool (*func)(const NetNet*)) /* * $Log: netlist.cc,v $ + * Revision 1.74 1999/10/06 05:06:16 steve + * Move the rvalue into NetAssign_ common code. + * * Revision 1.73 1999/10/05 04:02:10 steve * Relaxed width handling for <= assignment. * diff --git a/netlist.h b/netlist.h index b3c30ce27..6a42660cc 100644 --- a/netlist.h +++ b/netlist.h @@ -19,7 +19,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ #if !defined(WINNT) -#ident "$Id: netlist.h,v 1.76 1999/09/30 21:28:34 steve Exp $" +#ident "$Id: netlist.h,v 1.77 1999/10/06 05:06:16 steve Exp $" #endif /* @@ -615,9 +615,21 @@ class NetProc : public LineInfo { class NetAssign_ : public NetProc, public NetNode { + public: + + // This is the (procedural) value that is to be assigned when + // the assignment is executed. + NetExpr*rval(); + const NetExpr*rval() const; + protected: NetAssign_(const string&n, unsigned w); virtual ~NetAssign_() =0; + + void set_rval(NetExpr*); + + private: + NetExpr*rval_; }; class NetAssign : public NetAssign_ { @@ -625,9 +637,6 @@ class NetAssign : public NetAssign_ { explicit NetAssign(const string&, Design*des, unsigned w, NetExpr*rv); ~NetAssign(); - NetExpr*rval() { return rval_; } - const NetExpr*rval() const { return rval_; } - void find_lval_range(const NetNet*&net, unsigned&msb, unsigned&lsb) const; @@ -637,7 +646,6 @@ class NetAssign : public NetAssign_ { virtual void dump_node(ostream&, unsigned ind) const; private: - NetExpr* rval_; }; /* @@ -650,9 +658,6 @@ class NetAssignNB : public NetAssign_ { NetExpr*mux, NetExpr*rv); ~NetAssignNB(); - // This is the (procedural) value that is to be assigned when - // the assignment is executed. - const NetExpr*rval() const { return rval_; } // If this expression exists, then only a single bit is to be // set from the rval, and the value of this expression selects @@ -665,7 +670,6 @@ class NetAssignNB : public NetAssign_ { virtual void dump_node(ostream&, unsigned ind) const; private: - NetExpr* rval_; NetExpr* bmux_; }; @@ -1707,6 +1711,9 @@ extern ostream& operator << (ostream&, NetNet::Type); /* * $Log: netlist.h,v $ + * Revision 1.77 1999/10/06 05:06:16 steve + * Move the rvalue into NetAssign_ common code. + * * Revision 1.76 1999/09/30 21:28:34 steve * Handle mutual reference of tasks by elaborating * task definitions in two passes, like functions.