No need to keep excess width from an
unsigned constant value, if it can be trimmed safely.
This commit is contained in:
parent
2f88a631df
commit
de94d09706
73
net_expr.cc
73
net_expr.cc
|
|
@ -17,13 +17,79 @@
|
||||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||||
*/
|
*/
|
||||||
#ifdef HAVE_CVS_IDENT
|
#ifdef HAVE_CVS_IDENT
|
||||||
#ident "$Id: net_expr.cc,v 1.8 2002/10/19 22:59:49 steve Exp $"
|
#ident "$Id: net_expr.cc,v 1.9 2002/11/06 02:25:13 steve Exp $"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
# include "config.h"
|
# include "config.h"
|
||||||
# include "netlist.h"
|
# include "netlist.h"
|
||||||
# include <iostream>
|
# include <iostream>
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Create an add/sub node from the two operands. Make a best guess of
|
||||||
|
* the
|
||||||
|
*/
|
||||||
|
NetEBAdd::NetEBAdd(char op, NetExpr*l, NetExpr*r)
|
||||||
|
: NetEBinary(op, l, r)
|
||||||
|
{
|
||||||
|
NetEConst* tmp;
|
||||||
|
|
||||||
|
/* Catch the special case that one of the operands is an
|
||||||
|
unsized constant number. If so, then we should set the
|
||||||
|
width of that number to the size of the other operand, plus
|
||||||
|
one. This expands the expression to account for the largest
|
||||||
|
possible result.
|
||||||
|
|
||||||
|
The set_width applied to a constant value will only
|
||||||
|
truncate the constant so far as it can still hold its
|
||||||
|
logical value, so this is safe to do. */
|
||||||
|
if ( (tmp = dynamic_cast<NetEConst*>(r))
|
||||||
|
&& (! tmp->has_width())
|
||||||
|
&& (tmp->expr_width() > l->expr_width()) ) {
|
||||||
|
|
||||||
|
unsigned target_width = l->expr_width() + 1;
|
||||||
|
r->set_width(target_width);
|
||||||
|
|
||||||
|
/* Note: This constant value will not gain a defined
|
||||||
|
with from this. Make sure. */
|
||||||
|
assert(! r->has_width() );
|
||||||
|
|
||||||
|
} else if ( (tmp = dynamic_cast<NetEConst*>(l))
|
||||||
|
&& (! tmp->has_width())
|
||||||
|
&& (tmp->expr_width() > r->expr_width()) ) {
|
||||||
|
|
||||||
|
unsigned target_width = r->expr_width() + 1;
|
||||||
|
l->set_width(target_width);
|
||||||
|
|
||||||
|
/* Note: This constant value will not gain a defined
|
||||||
|
with from this. Make sure. */
|
||||||
|
assert(! l->has_width() );
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Now that we have the operand sizes the way we like, or as
|
||||||
|
good as we are going to get them, set the size of myself. */
|
||||||
|
if (r->expr_width() > l->expr_width()) {
|
||||||
|
|
||||||
|
expr_width(r->expr_width());
|
||||||
|
|
||||||
|
} else {
|
||||||
|
expr_width(l->expr_width());
|
||||||
|
}
|
||||||
|
|
||||||
|
cast_signed(l->has_sign() && r->has_sign());
|
||||||
|
}
|
||||||
|
|
||||||
|
NetEBAdd::~NetEBAdd()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
NetEBAdd* NetEBAdd::dup_expr() const
|
||||||
|
{
|
||||||
|
NetEBAdd*result = new NetEBAdd(op_, left_->dup_expr(),
|
||||||
|
right_->dup_expr());
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
NetEConcat::NetEConcat(unsigned cnt, NetExpr* r)
|
NetEConcat::NetEConcat(unsigned cnt, NetExpr* r)
|
||||||
: parms_(cnt), repeat_(r)
|
: parms_(cnt), repeat_(r)
|
||||||
{
|
{
|
||||||
|
|
@ -171,6 +237,11 @@ bool NetESelect::set_width(unsigned w)
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* $Log: net_expr.cc,v $
|
* $Log: net_expr.cc,v $
|
||||||
|
* Revision 1.9 2002/11/06 02:25:13 steve
|
||||||
|
* No need to keep excess width from an
|
||||||
|
* unsigned constant value, if it can
|
||||||
|
* be trimmed safely.
|
||||||
|
*
|
||||||
* Revision 1.8 2002/10/19 22:59:49 steve
|
* Revision 1.8 2002/10/19 22:59:49 steve
|
||||||
* Redo the parameter vector support to allow
|
* Redo the parameter vector support to allow
|
||||||
* parameter names in range expressions.
|
* parameter names in range expressions.
|
||||||
|
|
|
||||||
35
netlist.cc
35
netlist.cc
|
|
@ -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
|
||||||
*/
|
*/
|
||||||
#ifdef HAVE_CVS_IDENT
|
#ifdef HAVE_CVS_IDENT
|
||||||
#ident "$Id: netlist.cc,v 1.201 2002/10/23 01:47:17 steve Exp $"
|
#ident "$Id: netlist.cc,v 1.202 2002/11/06 02:25:13 steve Exp $"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
# include "config.h"
|
# include "config.h"
|
||||||
|
|
@ -1756,34 +1756,6 @@ bool NetExpr::has_width() const
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* Create a bitwise operator node from the opcode and the left and
|
|
||||||
* right expressions. Don't worry about the width of the expression
|
|
||||||
* yet, we'll get that from the l-value, whatever that turns out to
|
|
||||||
* be.
|
|
||||||
*/
|
|
||||||
NetEBAdd::NetEBAdd(char op, NetExpr*l, NetExpr*r)
|
|
||||||
: NetEBinary(op, l, r)
|
|
||||||
{
|
|
||||||
if (r->expr_width() > l->expr_width())
|
|
||||||
expr_width(r->expr_width());
|
|
||||||
else
|
|
||||||
expr_width(l->expr_width());
|
|
||||||
|
|
||||||
cast_signed(l->has_sign() && r->has_sign());
|
|
||||||
}
|
|
||||||
|
|
||||||
NetEBAdd::~NetEBAdd()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
NetEBAdd* NetEBAdd::dup_expr() const
|
|
||||||
{
|
|
||||||
NetEBAdd*result = new NetEBAdd(op_, left_->dup_expr(),
|
|
||||||
right_->dup_expr());
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Create a bitwise operator node from the opcode and the left and
|
* Create a bitwise operator node from the opcode and the left and
|
||||||
* right expressions. Don't worry about the width of the expression
|
* right expressions. Don't worry about the width of the expression
|
||||||
|
|
@ -2320,6 +2292,11 @@ const NetProc*NetTaskDef::proc() const
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* $Log: netlist.cc,v $
|
* $Log: netlist.cc,v $
|
||||||
|
* Revision 1.202 2002/11/06 02:25:13 steve
|
||||||
|
* No need to keep excess width from an
|
||||||
|
* unsigned constant value, if it can
|
||||||
|
* be trimmed safely.
|
||||||
|
*
|
||||||
* Revision 1.201 2002/10/23 01:47:17 steve
|
* Revision 1.201 2002/10/23 01:47:17 steve
|
||||||
* Fix synth2 handling of aset/aclr signals where
|
* Fix synth2 handling of aset/aclr signals where
|
||||||
* flip-flops are split by begin-end blocks.
|
* flip-flops are split by begin-end blocks.
|
||||||
|
|
|
||||||
11
set_width.cc
11
set_width.cc
|
|
@ -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
|
||||||
*/
|
*/
|
||||||
#ifdef HAVE_CVS_IDENT
|
#ifdef HAVE_CVS_IDENT
|
||||||
#ident "$Id: set_width.cc,v 1.23 2002/08/12 01:35:00 steve Exp $"
|
#ident "$Id: set_width.cc,v 1.24 2002/11/06 02:25:13 steve Exp $"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
# include "config.h"
|
# include "config.h"
|
||||||
|
|
@ -238,7 +238,7 @@ bool NetEConst::set_width(unsigned w)
|
||||||
if (value_.has_sign())
|
if (value_.has_sign())
|
||||||
pad = value_.get(value_.len()-1);
|
pad = value_.get(value_.len()-1);
|
||||||
|
|
||||||
verinum tmp (verinum::V0, w);
|
verinum tmp (verinum::V0, w, has_width());
|
||||||
for (unsigned idx = 0 ; idx < value_.len() ; idx += 1)
|
for (unsigned idx = 0 ; idx < value_.len() ; idx += 1)
|
||||||
tmp.set(idx, value_[idx]);
|
tmp.set(idx, value_[idx]);
|
||||||
for (unsigned idx = value_.len() ; idx < w ; idx += 1)
|
for (unsigned idx = value_.len() ; idx < w ; idx += 1)
|
||||||
|
|
@ -259,7 +259,7 @@ bool NetEConst::set_width(unsigned w)
|
||||||
if (value_[idx] != verinum::V0)
|
if (value_[idx] != verinum::V0)
|
||||||
use_w = idx+1;
|
use_w = idx+1;
|
||||||
|
|
||||||
verinum tmp (verinum::V0, use_w);
|
verinum tmp (verinum::V0, use_w, has_width());
|
||||||
for (unsigned idx = 0 ; idx < use_w ; idx += 1)
|
for (unsigned idx = 0 ; idx < use_w ; idx += 1)
|
||||||
tmp.set(idx, value_[idx]);
|
tmp.set(idx, value_[idx]);
|
||||||
|
|
||||||
|
|
@ -357,6 +357,11 @@ bool NetEUReduce::set_width(unsigned w)
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* $Log: set_width.cc,v $
|
* $Log: set_width.cc,v $
|
||||||
|
* Revision 1.24 2002/11/06 02:25:13 steve
|
||||||
|
* No need to keep excess width from an
|
||||||
|
* unsigned constant value, if it can
|
||||||
|
* be trimmed safely.
|
||||||
|
*
|
||||||
* Revision 1.23 2002/08/12 01:35:00 steve
|
* Revision 1.23 2002/08/12 01:35:00 steve
|
||||||
* conditional ident string using autoconfig.
|
* conditional ident string using autoconfig.
|
||||||
*
|
*
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue