encapsulate access to the l-value expected width.

This commit is contained in:
steve 2000-09-07 00:06:53 +00:00
parent 24e46723b0
commit 49570b8cd9
3 changed files with 53 additions and 18 deletions

View File

@ -17,7 +17,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#if !defined(WINNT) && !defined(macintosh)
#ident "$Id: elaborate.cc,v 1.186 2000/09/03 17:58:35 steve Exp $"
#ident "$Id: elaborate.cc,v 1.187 2000/09/07 00:06:53 steve Exp $"
#endif
/*
@ -751,6 +751,16 @@ NetProc* PAssign::assign_to_memory_(NetMemory*mem, PExpr*ix,
* NetAssign_ node as a b_mux value. The target must interpret the
* presense of a bmux value as taking a single bit and assigning it to
* the bit selected by the bmux expression.
*
* If the l-value expression is non-trivial, but can be fully
* evaluated at compile time (meaning any bit selects are constant)
* then elaboration will make a single NetAssign_ that connects to a
* synthetic reg that in turn connects to all the proper pins of the
* l-value.
*
* This last case can turn up in statements like: {a, b[1]} = c;
* rather then create a NetAssign_ for each item in the contatenation,
* elaboration makes a single NetAssign_ and connects it up properly.
*/
NetAssign_* PAssign_::elaborate_lval(Design*des, NetScope*scope)const
{
@ -1036,11 +1046,10 @@ NetProc* PAssign::elaborate(Design*des, const string&path) const
return bl;
}
if (lv->bmux() == 0) {
rv->set_width(lv->pin_count());
rv = pad_to_width(rv, lv->pin_count());
assert(rv->expr_width() >= lv->pin_count());
{ unsigned wid = lv->lwidth();
rv->set_width(wid);
rv = pad_to_width(rv, wid);
assert(rv->expr_width() >= wid);
}
NetAssign*cur = new NetAssign(lv, rv);
@ -1118,12 +1127,9 @@ NetProc* PAssignNB::elaborate(Design*des, const string&path) const
assert(rv);
if (lv->bmux() == 0) {
unsigned wid = lv->pin_count();
{ unsigned wid = lv->lwidth();
rv->set_width(wid);
rv = pad_to_width(rv, wid);
}
@ -2394,6 +2400,9 @@ Design* elaborate(const map<string,Module*>&modules,
/*
* $Log: elaborate.cc,v $
* Revision 1.187 2000/09/07 00:06:53 steve
* encapsulate access to the l-value expected width.
*
* Revision 1.186 2000/09/03 17:58:35 steve
* Change elaborate_lval to return NetAssign_ objects.
*

View File

@ -17,7 +17,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#if !defined(WINNT) && !defined(macintosh)
#ident "$Id: net_assign.cc,v 1.2 2000/09/02 23:40:13 steve Exp $"
#ident "$Id: net_assign.cc,v 1.3 2000/09/07 00:06:53 steve Exp $"
#endif
# include "netlist.h"
@ -52,6 +52,12 @@ const NetExpr* NetAssign_::bmux() const
return bmux_;
}
unsigned NetAssign_::lwidth() const
{
if (bmux_) return 1;
else return pin_count();
}
NetAssignBase::NetAssignBase(NetAssign_*lv, NetExpr*rv)
: lval_(lv), rval_(rv)
{
@ -91,6 +97,12 @@ const NetAssign_* NetAssignBase::l_val(unsigned idx) const
return lval_;
}
unsigned NetAssignBase::lwidth() const
{
assert(lval_);
return lval_->lwidth();
}
NetAssign::NetAssign(NetAssign_*lv, NetExpr*rv)
: NetAssignBase(lv, rv)
@ -112,6 +124,9 @@ NetAssignNB::~NetAssignNB()
/*
* $Log: net_assign.cc,v $
* Revision 1.3 2000/09/07 00:06:53 steve
* encapsulate access to the l-value expected width.
*
* Revision 1.2 2000/09/02 23:40:13 steve
* Pull NetAssign_ creation out of constructors.
*

View File

@ -19,7 +19,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#if !defined(WINNT) && !defined(macintosh)
#ident "$Id: netlist.h,v 1.160 2000/09/02 23:40:13 steve Exp $"
#ident "$Id: netlist.h,v 1.161 2000/09/07 00:06:53 steve Exp $"
#endif
/*
@ -1124,9 +1124,9 @@ class NetProc : public LineInfo {
* in the NetProc behaviors.
*
* The l-value of the assignment is a collection of NetAssign_
* objects. These are nodes that connect to the structural netlist
* where the assignment has its effect. The NetAssign_ class is not to
* be derived from.
* objects that are connected to the structural netlist where the
* assignment has its effect. The NetAssign_ class is not to be
* derived from.
*
* NOTE: The elaborator will make an effort to match the width of the
* r-value to the with of the l-value, but targets and functions
@ -1144,9 +1144,13 @@ class NetAssign_ : public NetNode {
// the pin that gets the value.
const NetExpr*bmux() const;
void set_bmux(NetExpr*);
// Get the width of the r-value that this node expects. This
// method accounts for the presence of the mux, so it not
// nexessarily the same as the pin_count().
unsigned lwidth() const;
virtual bool emit_node(struct target_t*) const;
virtual void dump_node(ostream&, unsigned ind) const;
@ -1170,6 +1174,10 @@ class NetAssignBase : public NetProc {
NetAssign_* l_val(unsigned);
const NetAssign_* l_val(unsigned) const;
// This returns the total width of the accumulated l-value. It
// accounts for any grouping of NetAssign_ objects that might happen.
unsigned lwidth() const;
private:
NetAssign_*lval_;
NetExpr *rval_;
@ -2744,6 +2752,9 @@ extern ostream& operator << (ostream&, NetNet::Type);
/*
* $Log: netlist.h,v $
* Revision 1.161 2000/09/07 00:06:53 steve
* encapsulate access to the l-value expected width.
*
* Revision 1.160 2000/09/02 23:40:13 steve
* Pull NetAssign_ creation out of constructors.
*