Fix evaluation of compare to constant expression.

This commit is contained in:
steve 2004-02-15 04:23:48 +00:00
parent 081a6a4088
commit 2f8a40b159
2 changed files with 36 additions and 6 deletions

View File

@ -17,7 +17,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#ifdef HAVE_CVS_IDENT
#ident "$Id: elab_net.cc,v 1.122 2003/10/30 04:31:34 steve Exp $"
#ident "$Id: elab_net.cc,v 1.123 2004/02/15 04:23:48 steve Exp $"
#endif
# include "config.h"
@ -408,21 +408,44 @@ NetNet* PEBinary::elaborate_net_cmp_(Design*des, NetScope*scope,
unsigned long fall,
unsigned long decay) const
{
NetNet*lsig = left_->elaborate_net(des, scope, 0, 0, 0, 0),
*rsig = right_->elaborate_net(des, scope, 0, 0, 0, 0);
if (lsig == 0) {
/* Elaborate the operands of the compare first as expressions
(so that the eval_tree method can reduce constant
expressions, including parameters) then turn those results
into synthesized nets. */
NetExpr*lexp = left_->elaborate_expr(des, scope);
if (lexp == 0) {
cerr << get_line() << ": error: Cannot elaborate ";
left_->dump(cerr);
cerr << endl;
return 0;
}
if (rsig == 0) {
if (NetExpr*tmp = lexp->eval_tree()) {
delete lexp;
lexp = tmp;
}
NetNet*lsig = lexp->synthesize(des);
assert(lsig);
delete lexp;
NetExpr*rexp = right_->elaborate_expr(des, scope);
if (rexp == 0) {
cerr << get_line() << ": error: Cannot elaborate ";
right_->dump(cerr);
cerr << endl;
return 0;
}
if (NetExpr*tmp = rexp->eval_tree()) {
delete rexp;
rexp = tmp;
}
NetNet*rsig = rexp->synthesize(des);
assert(rsig);
delete rexp;
unsigned dwidth = lsig->pin_count();
if (rsig->pin_count() > dwidth) dwidth = rsig->pin_count();
@ -2403,6 +2426,9 @@ NetNet* PEUnary::elaborate_net(Design*des, NetScope*scope,
/*
* $Log: elab_net.cc,v $
* Revision 1.123 2004/02/15 04:23:48 steve
* Fix evaluation of compare to constant expression.
*
* Revision 1.122 2003/10/30 04:31:34 steve
* Catch real variables in net expressions.
*

View File

@ -17,7 +17,7 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*/
#ifdef HAVE_CVS_IDENT
#ident "$Id: expr_synth.cc,v 1.52 2003/11/10 19:39:20 steve Exp $"
#ident "$Id: expr_synth.cc,v 1.53 2004/02/15 04:23:48 steve Exp $"
#endif
# include "config.h"
@ -584,6 +584,7 @@ NetNet* NetEConst::synthesize(Design*des)
NetNet*osig = new NetNet(scope, path, NetNet::IMPLICIT, width);
osig->local_flag(true);
osig->set_signed(has_sign());
NetConst*con = new NetConst(scope, scope->local_symbol(), value());
for (unsigned idx = 0 ; idx < width; idx += 1)
connect(osig->pin(idx), con->pin(idx));
@ -827,6 +828,9 @@ NetNet* NetESignal::synthesize(Design*des)
/*
* $Log: expr_synth.cc,v $
* Revision 1.53 2004/02/15 04:23:48 steve
* Fix evaluation of compare to constant expression.
*
* Revision 1.52 2003/11/10 19:39:20 steve
* Remove redundant scope tokens.
*