Move the rvalue into NetAssign_ common code.

This commit is contained in:
steve 1999-10-06 05:06:16 +00:00
parent 492d76e71d
commit 1d215998b2
3 changed files with 58 additions and 29 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.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 #endif
/* /*
@ -130,7 +130,7 @@ void NetAddSub::dump_node(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 (NetAssign): " << o << setw(ind) << "" << "Procedural assign (NetAssign): " <<
*rval_ << endl; *rval() << endl;
dump_node_pins(o, ind+4); dump_node_pins(o, ind+4);
} }
@ -138,10 +138,10 @@ void NetAssignNB::dump_node(ostream&o, unsigned ind) const
{ {
if (bmux_) if (bmux_)
o << setw(ind) << "" << "Procedural NB assign (NetAssignNB): " o << setw(ind) << "" << "Procedural NB assign (NetAssignNB): "
<< name() << "[" << *bmux_ << "] <= " << *rval_ << endl; << name() << "[" << *bmux_ << "] <= " << *rval() << endl;
else else
o << setw(ind) << "" << "Procedural NB assign (NetAssignNB): " o << setw(ind) << "" << "Procedural NB assign (NetAssignNB): "
<< name() << " <= " << *rval_ << endl; << name() << " <= " << *rval() << endl;
dump_node_pins(o, ind+4); dump_node_pins(o, ind+4);
} }
@ -340,10 +340,7 @@ void NetAssign::dump(ostream&o, unsigned ind) const
o << sig->name() << "[" << msb; o << sig->name() << "[" << msb;
if (pin_count() > 1) if (pin_count() > 1)
o << ":" << lsb; o << ":" << lsb;
o << "] = "; o << "] = " << *rval() << ";" << endl;
rval_->dump(o);
o << ";" << endl;
} }
void NetAssignNB::dump(ostream&o, unsigned ind) const void NetAssignNB::dump(ostream&o, unsigned ind) const
@ -354,13 +351,13 @@ void NetAssignNB::dump(ostream&o, unsigned ind) const
o << name() << "[" << *bmux_ << "] <= "; o << name() << "[" << *bmux_ << "] <= ";
if (rise_time()) if (rise_time())
o << "#" << rise_time() << " "; o << "#" << rise_time() << " ";
o << *rval_ << ";" << endl; o << *rval() << ";" << endl;
} else { } else {
o << name() << " <= "; o << name() << " <= ";
if (rise_time()) if (rise_time())
o << "#" << 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 $ * $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 * Revision 1.46 1999/10/05 06:19:46 steve
* Add support for reduction NOR. * Add support for reduction NOR.
* *

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.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 #endif
# include <cassert> # include <cassert>
@ -382,7 +382,7 @@ NetObj::Link& NetAddSub::pin_Result(unsigned idx)
} }
NetAssign_::NetAssign_(const string&n, unsigned w) NetAssign_::NetAssign_(const string&n, unsigned w)
: NetNode(n, w) : NetNode(n, w), rval_(0)
{ {
for (unsigned idx = 0 ; idx < pin_count() ; idx += 1) for (unsigned idx = 0 ; idx < pin_count() ; idx += 1)
pin(idx).set_dir(NetObj::Link::OUTPUT); pin(idx).set_dir(NetObj::Link::OUTPUT);
@ -391,44 +391,63 @@ NetAssign_::NetAssign_(const string&n, unsigned w)
NetAssign_::~NetAssign_() 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::NetAssign(const string&n, Design*des, unsigned w, NetExpr*rv)
: NetAssign_(n, w), rval_(rv) : NetAssign_(n, w)
{ {
set_rval(rv);
} }
NetAssign::~NetAssign() NetAssign::~NetAssign()
{ {
delete rval_;
} }
NetAssignNB::NetAssignNB(const string&n, Design*des, unsigned w, NetExpr*rv) 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 (" << 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; "bit width (" << w << ")." << endl;
des->errors += 1; des->errors += 1;
} }
set_rval(rv);
} }
NetAssignNB::NetAssignNB(const string&n, Design*des, unsigned w, NetAssignNB::NetAssignNB(const string&n, Design*des, unsigned w,
NetExpr*mu, NetExpr*rv) 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) { if (flag == false) {
cerr << rv->get_line() << ": Expression bit width" << cerr << rv->get_line() << ": Expression bit width" <<
" conflicts with l-value bit width." << endl; " conflicts with l-value bit width." << endl;
des->errors += 1; des->errors += 1;
} }
set_rval(rv);
} }
NetAssignNB::~NetAssignNB() NetAssignNB::~NetAssignNB()
{ {
delete rval_;
delete bmux_; delete bmux_;
} }
@ -1684,6 +1703,9 @@ NetNet* Design::find_signal(bool (*func)(const NetNet*))
/* /*
* $Log: netlist.cc,v $ * $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 * Revision 1.73 1999/10/05 04:02:10 steve
* Relaxed width handling for <= assignment. * Relaxed width handling for <= assignment.
* *

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.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 #endif
/* /*
@ -615,9 +615,21 @@ class NetProc : public LineInfo {
class NetAssign_ : public NetProc, public NetNode { 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: protected:
NetAssign_(const string&n, unsigned w); NetAssign_(const string&n, unsigned w);
virtual ~NetAssign_() =0; virtual ~NetAssign_() =0;
void set_rval(NetExpr*);
private:
NetExpr*rval_;
}; };
class NetAssign : public NetAssign_ { class NetAssign : public NetAssign_ {
@ -625,9 +637,6 @@ class NetAssign : public NetAssign_ {
explicit NetAssign(const string&, Design*des, unsigned w, NetExpr*rv); explicit NetAssign(const string&, Design*des, unsigned w, NetExpr*rv);
~NetAssign(); ~NetAssign();
NetExpr*rval() { return rval_; }
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;
@ -637,7 +646,6 @@ class NetAssign : public NetAssign_ {
virtual void dump_node(ostream&, unsigned ind) const; virtual void dump_node(ostream&, unsigned ind) const;
private: private:
NetExpr* rval_;
}; };
/* /*
@ -650,9 +658,6 @@ class NetAssignNB : public NetAssign_ {
NetExpr*mux, NetExpr*rv); NetExpr*mux, NetExpr*rv);
~NetAssignNB(); ~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 // If this expression exists, then only a single bit is to be
// set from the rval, and the value of this expression selects // 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; virtual void dump_node(ostream&, unsigned ind) const;
private: private:
NetExpr* rval_;
NetExpr* bmux_; NetExpr* bmux_;
}; };
@ -1707,6 +1711,9 @@ extern ostream& operator << (ostream&, NetNet::Type);
/* /*
* $Log: netlist.h,v $ * $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 * Revision 1.76 1999/09/30 21:28:34 steve
* Handle mutual reference of tasks by elaborating * Handle mutual reference of tasks by elaborating
* task definitions in two passes, like functions. * task definitions in two passes, like functions.