Detect part select errors on l-values.

This commit is contained in:
steve 2000-12-01 02:55:37 +00:00
parent ef49fc127f
commit 4eed86d519
2 changed files with 39 additions and 7 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: elab_lval.cc,v 1.6 2000/10/31 17:49:02 steve Exp $"
#ident "$Id: elab_lval.cc,v 1.7 2000/12/01 02:55:37 steve Exp $"
#endif
# include "PExpr.h"
@ -265,14 +265,31 @@ NetAssign_* PEIdent::elaborate_lval(Design*des, NetScope*scope) const
/* If the bit/part select is constant, then make the
NetAssign_ only as wide as it needs to be and connect
only to the selected bits of the reg. */
unsigned wid = (msb >= lsb)? (msb-lsb+1) : (lsb-msb+1);
assert(wid <= reg->pin_count());
unsigned loff = reg->sb_to_idx(lsb);
unsigned moff = reg->sb_to_idx(msb);
unsigned wid = moff - loff + 1;
lv = new NetAssign_(des->local_symbol(scope->name()), wid);
unsigned off = reg->sb_to_idx(lsb);
assert((off+wid) <= reg->pin_count());
if (moff < loff) {
cerr << get_line() << ": error: part select "
<< reg->name() << "[" << msb<<":"<<lsb<<"]"
<< " is reversed." << endl;
des->errors += 1;
return 0;
}
if (wid > reg->pin_count()) {
cerr << get_line() << ": error: part select "
<< reg->name() << "[" << msb<<":"<<lsb<<"]"
<< " is out of range." << endl;
des->errors += 1;
return 0;
}
assert(moff < reg->pin_count());
for (unsigned idx = 0 ; idx < wid ; idx += 1)
connect(lv->pin(idx), reg->pin(idx+off));
connect(lv->pin(idx), reg->pin(idx+loff));
}
@ -284,6 +301,9 @@ NetAssign_* PEIdent::elaborate_lval(Design*des, NetScope*scope) const
/*
* $Log: elab_lval.cc,v $
* Revision 1.7 2000/12/01 02:55:37 steve
* Detect part select errors on l-values.
*
* Revision 1.6 2000/10/31 17:49:02 steve
* Support time variables.
*

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: elab_net.cc,v 1.54 2000/11/04 05:06:04 steve Exp $"
#ident "$Id: elab_net.cc,v 1.55 2000/12/01 02:55:37 steve Exp $"
#endif
# include "PExpr.h"
@ -1234,6 +1234,15 @@ NetNet* PEIdent::elaborate_lnet(Design*des, const string&path) const
} else {
NetTmp*tmp = new NetTmp(scope, des->local_symbol(path),
lidx-midx+1);
if (tmp->pin_count() > sig->pin_count()) {
cerr << get_line() << ": error: "
<< "part select out of range for "
<< sig->name() << "." << endl;
des->errors += 1;
return sig;
}
assert(tmp->pin_count() <= sig->pin_count());
for (unsigned idx = lidx ; idx >= midx ; idx -= 1)
connect(tmp->pin(idx-midx), sig->pin(idx));
@ -1749,6 +1758,9 @@ NetNet* PEUnary::elaborate_net(Design*des, const string&path,
/*
* $Log: elab_net.cc,v $
* Revision 1.55 2000/12/01 02:55:37 steve
* Detect part select errors on l-values.
*
* Revision 1.54 2000/11/04 05:06:04 steve
* pad different width inputs to muxes. (PR#14)
*