Support bool expressions and compares handle them optimally.
This commit is contained in:
parent
b9c0b8aa79
commit
9fd16575d9
20
elab_expr.cc
20
elab_expr.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: elab_expr.cc,v 1.95 2005/09/01 04:10:47 steve Exp $"
|
#ident "$Id: elab_expr.cc,v 1.96 2005/09/14 02:53:13 steve Exp $"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
# include "config.h"
|
# include "config.h"
|
||||||
|
|
@ -887,6 +887,19 @@ NetEConst* PEString::elaborate_expr(Design*des, NetScope*, bool) const
|
||||||
return tmp;
|
return tmp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static bool test_ternary_operand_compat(ivl_variable_type_t l,
|
||||||
|
ivl_variable_type_t r)
|
||||||
|
{
|
||||||
|
if (l == IVL_VT_LOGIC && r == IVL_VT_BOOL)
|
||||||
|
return true;
|
||||||
|
if (l == IVL_VT_BOOL && r == IVL_VT_LOGIC)
|
||||||
|
return true;
|
||||||
|
if (l == r)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Elaborate the Ternary operator. I know that the expressions were
|
* Elaborate the Ternary operator. I know that the expressions were
|
||||||
* parsed so I can presume that they exist, and call elaboration
|
* parsed so I can presume that they exist, and call elaboration
|
||||||
|
|
@ -915,7 +928,7 @@ NetETernary*PETernary::elaborate_expr(Design*des, NetScope*scope, bool) const
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tru->expr_type() != fal->expr_type()) {
|
if (! test_ternary_operand_compat(tru->expr_type(), fal->expr_type())) {
|
||||||
cerr << get_line() << ": error: Data types "
|
cerr << get_line() << ": error: Data types "
|
||||||
<< tru->expr_type() << " and "
|
<< tru->expr_type() << " and "
|
||||||
<< fal->expr_type() << " of ternary"
|
<< fal->expr_type() << " of ternary"
|
||||||
|
|
@ -1035,6 +1048,9 @@ NetExpr* PEUnary::elaborate_expr(Design*des, NetScope*scope, bool) const
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* $Log: elab_expr.cc,v $
|
* $Log: elab_expr.cc,v $
|
||||||
|
* Revision 1.96 2005/09/14 02:53:13 steve
|
||||||
|
* Support bool expressions and compares handle them optimally.
|
||||||
|
*
|
||||||
* Revision 1.95 2005/09/01 04:10:47 steve
|
* Revision 1.95 2005/09/01 04:10:47 steve
|
||||||
* Check operand types for compatibility.
|
* Check operand types for compatibility.
|
||||||
*
|
*
|
||||||
|
|
|
||||||
|
|
@ -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: elaborate.cc,v 1.328 2005/08/06 17:58:16 steve Exp $"
|
#ident "$Id: elaborate.cc,v 1.329 2005/09/14 02:53:13 steve Exp $"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
# include "config.h"
|
# include "config.h"
|
||||||
|
|
@ -1476,7 +1476,9 @@ NetProc* PAssignNB::elaborate(Design*des, NetScope*scope) const
|
||||||
|
|
||||||
If in this case the l-val is a variable (i.e. real) then
|
If in this case the l-val is a variable (i.e. real) then
|
||||||
the width to pad to will be 0, so this code is harmless. */
|
the width to pad to will be 0, so this code is harmless. */
|
||||||
if (rv->expr_type() == IVL_VT_LOGIC) {
|
if (rv->expr_type() == IVL_VT_REAL) {
|
||||||
|
|
||||||
|
} else {
|
||||||
unsigned wid = count_lval_width(lv);
|
unsigned wid = count_lval_width(lv);
|
||||||
rv->set_width(wid);
|
rv->set_width(wid);
|
||||||
rv = pad_to_width(rv, wid);
|
rv = pad_to_width(rv, wid);
|
||||||
|
|
@ -3019,6 +3021,9 @@ Design* elaborate(list<perm_string>roots)
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* $Log: elaborate.cc,v $
|
* $Log: elaborate.cc,v $
|
||||||
|
* Revision 1.329 2005/09/14 02:53:13 steve
|
||||||
|
* Support bool expressions and compares handle them optimally.
|
||||||
|
*
|
||||||
* Revision 1.328 2005/08/06 17:58:16 steve
|
* Revision 1.328 2005/08/06 17:58:16 steve
|
||||||
* Implement bi-directional part selects.
|
* Implement bi-directional part selects.
|
||||||
*
|
*
|
||||||
|
|
|
||||||
|
|
@ -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: eval_tree.cc,v 1.64 2005/07/11 16:56:50 steve Exp $"
|
#ident "$Id: eval_tree.cc,v 1.65 2005/09/14 02:53:14 steve Exp $"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
# include "config.h"
|
# include "config.h"
|
||||||
|
|
@ -851,6 +851,7 @@ NetExpr* NetEBMult::eval_tree_real_()
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
case IVL_VT_BOOL:
|
||||||
case IVL_VT_LOGIC: {
|
case IVL_VT_LOGIC: {
|
||||||
NetEConst*lc = dynamic_cast<NetEConst*>(left_);
|
NetEConst*lc = dynamic_cast<NetEConst*>(left_);
|
||||||
if (lc == 0) return 0;
|
if (lc == 0) return 0;
|
||||||
|
|
@ -871,6 +872,7 @@ NetExpr* NetEBMult::eval_tree_real_()
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
case IVL_VT_BOOL:
|
||||||
case IVL_VT_LOGIC: {
|
case IVL_VT_LOGIC: {
|
||||||
NetEConst*rc = dynamic_cast<NetEConst*>(right_);
|
NetEConst*rc = dynamic_cast<NetEConst*>(right_);
|
||||||
if (rc == 0) return 0;
|
if (rc == 0) return 0;
|
||||||
|
|
@ -1182,6 +1184,7 @@ NetExpr* NetEParam::eval_tree()
|
||||||
|
|
||||||
switch (res->expr_type()) {
|
switch (res->expr_type()) {
|
||||||
|
|
||||||
|
case IVL_VT_BOOL:
|
||||||
case IVL_VT_LOGIC:
|
case IVL_VT_LOGIC:
|
||||||
{ NetEConst*tmp = dynamic_cast<NetEConst*>(res);
|
{ NetEConst*tmp = dynamic_cast<NetEConst*>(res);
|
||||||
if (tmp == 0) {
|
if (tmp == 0) {
|
||||||
|
|
@ -1558,6 +1561,9 @@ NetEConst* NetEUReduce::eval_tree()
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* $Log: eval_tree.cc,v $
|
* $Log: eval_tree.cc,v $
|
||||||
|
* Revision 1.65 2005/09/14 02:53:14 steve
|
||||||
|
* Support bool expressions and compares handle them optimally.
|
||||||
|
*
|
||||||
* Revision 1.64 2005/07/11 16:56:50 steve
|
* Revision 1.64 2005/07/11 16:56:50 steve
|
||||||
* Remove NetVariable and ivl_variable_t structures.
|
* Remove NetVariable and ivl_variable_t structures.
|
||||||
*
|
*
|
||||||
|
|
|
||||||
|
|
@ -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: net_design.cc,v 1.46 2005/07/11 16:56:50 steve Exp $"
|
#ident "$Id: net_design.cc,v 1.47 2005/09/14 02:53:14 steve Exp $"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
# include "config.h"
|
# include "config.h"
|
||||||
|
|
@ -402,6 +402,7 @@ void NetScope::evaluate_parameters(Design*des)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case IVL_VT_LOGIC:
|
case IVL_VT_LOGIC:
|
||||||
|
case IVL_VT_BOOL:
|
||||||
if (! dynamic_cast<const NetEConst*>(expr)) {
|
if (! dynamic_cast<const NetEConst*>(expr)) {
|
||||||
|
|
||||||
// Try to evaluate the expression.
|
// Try to evaluate the expression.
|
||||||
|
|
@ -618,6 +619,9 @@ void Design::delete_process(NetProcTop*top)
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* $Log: net_design.cc,v $
|
* $Log: net_design.cc,v $
|
||||||
|
* Revision 1.47 2005/09/14 02:53:14 steve
|
||||||
|
* Support bool expressions and compares handle them optimally.
|
||||||
|
*
|
||||||
* Revision 1.46 2005/07/11 16:56:50 steve
|
* Revision 1.46 2005/07/11 16:56:50 steve
|
||||||
* Remove NetVariable and ivl_variable_t structures.
|
* Remove NetVariable and ivl_variable_t structures.
|
||||||
*
|
*
|
||||||
|
|
|
||||||
20
net_expr.cc
20
net_expr.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: net_expr.cc,v 1.24 2005/07/11 16:56:50 steve Exp $"
|
#ident "$Id: net_expr.cc,v 1.25 2005/09/14 02:53:14 steve Exp $"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
# include "config.h"
|
# include "config.h"
|
||||||
|
|
@ -164,6 +164,21 @@ bool NetEBComp::has_width() const
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ivl_variable_type_t NetEBComp::expr_type() const
|
||||||
|
{
|
||||||
|
// Case compare always returns BOOL
|
||||||
|
if (op() == 'E' || op() == 'N')
|
||||||
|
return IVL_VT_BOOL;
|
||||||
|
|
||||||
|
if (left()->expr_type() == IVL_VT_LOGIC)
|
||||||
|
return IVL_VT_LOGIC;
|
||||||
|
|
||||||
|
if (right()->expr_type() == IVL_VT_LOGIC)
|
||||||
|
return IVL_VT_LOGIC;
|
||||||
|
|
||||||
|
return IVL_VT_BOOL;
|
||||||
|
}
|
||||||
|
|
||||||
NetEBDiv::NetEBDiv(char op, NetExpr*l, NetExpr*r)
|
NetEBDiv::NetEBDiv(char op, NetExpr*l, NetExpr*r)
|
||||||
: NetEBinary(op, l, r)
|
: NetEBinary(op, l, r)
|
||||||
{
|
{
|
||||||
|
|
@ -519,6 +534,9 @@ ivl_variable_type_t NetESFunc::expr_type() const
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* $Log: net_expr.cc,v $
|
* $Log: net_expr.cc,v $
|
||||||
|
* Revision 1.25 2005/09/14 02:53:14 steve
|
||||||
|
* Support bool expressions and compares handle them optimally.
|
||||||
|
*
|
||||||
* Revision 1.24 2005/07/11 16:56:50 steve
|
* Revision 1.24 2005/07/11 16:56:50 steve
|
||||||
* Remove NetVariable and ivl_variable_t structures.
|
* Remove NetVariable and ivl_variable_t structures.
|
||||||
*
|
*
|
||||||
|
|
|
||||||
17
netlist.cc
17
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.247 2005/08/06 17:58:16 steve Exp $"
|
#ident "$Id: netlist.cc,v 1.248 2005/09/14 02:53:14 steve Exp $"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
# include "config.h"
|
# include "config.h"
|
||||||
|
|
@ -1888,6 +1888,18 @@ bool NetEConst::has_width() const
|
||||||
return value_.has_len();
|
return value_.has_len();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ivl_variable_type_t NetEConst::expr_type() const
|
||||||
|
{
|
||||||
|
if (value_.len() == 0)
|
||||||
|
return IVL_VT_LOGIC;
|
||||||
|
if (value_.is_string())
|
||||||
|
return IVL_VT_BOOL;
|
||||||
|
if (value_.is_defined())
|
||||||
|
return IVL_VT_BOOL;
|
||||||
|
|
||||||
|
return IVL_VT_LOGIC;
|
||||||
|
}
|
||||||
|
|
||||||
NetEConstParam::NetEConstParam(NetScope*s, perm_string n, const verinum&v)
|
NetEConstParam::NetEConstParam(NetScope*s, perm_string n, const verinum&v)
|
||||||
: NetEConst(v), scope_(s), name_(n)
|
: NetEConst(v), scope_(s), name_(n)
|
||||||
{
|
{
|
||||||
|
|
@ -2216,6 +2228,9 @@ const NetProc*NetTaskDef::proc() const
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* $Log: netlist.cc,v $
|
* $Log: netlist.cc,v $
|
||||||
|
* Revision 1.248 2005/09/14 02:53:14 steve
|
||||||
|
* Support bool expressions and compares handle them optimally.
|
||||||
|
*
|
||||||
* Revision 1.247 2005/08/06 17:58:16 steve
|
* Revision 1.247 2005/08/06 17:58:16 steve
|
||||||
* Implement bi-directional part selects.
|
* Implement bi-directional part selects.
|
||||||
*
|
*
|
||||||
|
|
|
||||||
|
|
@ -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
|
||||||
*/
|
*/
|
||||||
#ifdef HAVE_CVS_IDENT
|
#ifdef HAVE_CVS_IDENT
|
||||||
#ident "$Id: netlist.h,v 1.349 2005/09/01 04:11:37 steve Exp $"
|
#ident "$Id: netlist.h,v 1.350 2005/09/14 02:53:14 steve Exp $"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
@ -1109,6 +1109,7 @@ class NetEConst : public NetExpr {
|
||||||
virtual bool set_width(unsigned w);
|
virtual bool set_width(unsigned w);
|
||||||
|
|
||||||
virtual bool has_width() const;
|
virtual bool has_width() const;
|
||||||
|
virtual ivl_variable_type_t expr_type() const;
|
||||||
|
|
||||||
virtual void expr_scan(struct expr_scan_t*) const;
|
virtual void expr_scan(struct expr_scan_t*) const;
|
||||||
virtual void dump(ostream&) const;
|
virtual void dump(ostream&) const;
|
||||||
|
|
@ -2656,6 +2657,7 @@ class NetEBComp : public NetEBinary {
|
||||||
|
|
||||||
/* A compare expression has a definite width. */
|
/* A compare expression has a definite width. */
|
||||||
virtual bool has_width() const;
|
virtual bool has_width() const;
|
||||||
|
virtual ivl_variable_type_t expr_type() const;
|
||||||
virtual NetEBComp* dup_expr() const;
|
virtual NetEBComp* dup_expr() const;
|
||||||
virtual NetEConst* eval_tree();
|
virtual NetEConst* eval_tree();
|
||||||
|
|
||||||
|
|
@ -3442,6 +3444,9 @@ extern ostream& operator << (ostream&, NetNet::Type);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* $Log: netlist.h,v $
|
* $Log: netlist.h,v $
|
||||||
|
* Revision 1.350 2005/09/14 02:53:14 steve
|
||||||
|
* Support bool expressions and compares handle them optimally.
|
||||||
|
*
|
||||||
* Revision 1.349 2005/09/01 04:11:37 steve
|
* Revision 1.349 2005/09/01 04:11:37 steve
|
||||||
* Generate code to handle real valued muxes.
|
* Generate code to handle real valued muxes.
|
||||||
*
|
*
|
||||||
|
|
|
||||||
|
|
@ -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: t-dll-expr.cc,v 1.42 2005/07/13 04:51:36 steve Exp $"
|
#ident "$Id: t-dll-expr.cc,v 1.43 2005/09/14 02:53:15 steve Exp $"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
# include "config.h"
|
# include "config.h"
|
||||||
|
|
@ -227,7 +227,7 @@ void dll_target::expr_const(const NetEConst*net)
|
||||||
|
|
||||||
expr_ = (ivl_expr_t)calloc(1, sizeof(struct ivl_expr_s));
|
expr_ = (ivl_expr_t)calloc(1, sizeof(struct ivl_expr_s));
|
||||||
assert(expr_);
|
assert(expr_);
|
||||||
expr_->value_= IVL_VT_VECTOR;
|
expr_->value_= net->expr_type();
|
||||||
|
|
||||||
if (net->value().is_string()) {
|
if (net->value().is_string()) {
|
||||||
expr_->type_ = IVL_EX_STRING;
|
expr_->type_ = IVL_EX_STRING;
|
||||||
|
|
@ -473,6 +473,9 @@ void dll_target::expr_unary(const NetEUnary*net)
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* $Log: t-dll-expr.cc,v $
|
* $Log: t-dll-expr.cc,v $
|
||||||
|
* Revision 1.43 2005/09/14 02:53:15 steve
|
||||||
|
* Support bool expressions and compares handle them optimally.
|
||||||
|
*
|
||||||
* Revision 1.42 2005/07/13 04:51:36 steve
|
* Revision 1.42 2005/07/13 04:51:36 steve
|
||||||
* Functions get type from their output signal.
|
* Functions get type from their output signal.
|
||||||
*
|
*
|
||||||
|
|
|
||||||
|
|
@ -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: stub.c,v 1.132 2005/08/06 17:58:16 steve Exp $"
|
#ident "$Id: stub.c,v 1.133 2005/09/14 02:53:15 steve Exp $"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
# include "config.h"
|
# include "config.h"
|
||||||
|
|
@ -164,8 +164,11 @@ void show_expression(ivl_expr_t net, unsigned ind)
|
||||||
case IVL_VT_REAL:
|
case IVL_VT_REAL:
|
||||||
vt = "real";
|
vt = "real";
|
||||||
break;
|
break;
|
||||||
case IVL_VT_VECTOR:
|
case IVL_VT_BOOL:
|
||||||
vt = "vector";
|
vt = "bool";
|
||||||
|
break;
|
||||||
|
case IVL_VT_LOGIC:
|
||||||
|
vt = "logic";
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -197,7 +200,7 @@ void show_expression(ivl_expr_t net, unsigned ind)
|
||||||
for (idx = width ; idx > 0 ; idx -= 1)
|
for (idx = width ; idx > 0 ; idx -= 1)
|
||||||
fprintf(out, "%c", bits[idx-1]);
|
fprintf(out, "%c", bits[idx-1]);
|
||||||
|
|
||||||
fprintf(out, ", %s", sign);
|
fprintf(out, ", %s %s", sign, vt);
|
||||||
if (par != 0)
|
if (par != 0)
|
||||||
fprintf(out, ", parameter=%s",
|
fprintf(out, ", parameter=%s",
|
||||||
ivl_parameter_basename(par));
|
ivl_parameter_basename(par));
|
||||||
|
|
@ -1527,6 +1530,9 @@ int target_design(ivl_design_t des)
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* $Log: stub.c,v $
|
* $Log: stub.c,v $
|
||||||
|
* Revision 1.133 2005/09/14 02:53:15 steve
|
||||||
|
* Support bool expressions and compares handle them optimally.
|
||||||
|
*
|
||||||
* Revision 1.132 2005/08/06 17:58:16 steve
|
* Revision 1.132 2005/08/06 17:58:16 steve
|
||||||
* Implement bi-directional part selects.
|
* Implement bi-directional part selects.
|
||||||
*
|
*
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,7 @@
|
||||||
# 59 Temple Place - Suite 330
|
# 59 Temple Place - Suite 330
|
||||||
# Boston, MA 02111-1307, USA
|
# Boston, MA 02111-1307, USA
|
||||||
#
|
#
|
||||||
#ident "$Id: Makefile.in,v 1.23 2005/07/13 04:52:31 steve Exp $"
|
#ident "$Id: Makefile.in,v 1.24 2005/09/14 02:53:15 steve Exp $"
|
||||||
#
|
#
|
||||||
#
|
#
|
||||||
SHELL = /bin/sh
|
SHELL = /bin/sh
|
||||||
|
|
@ -51,7 +51,8 @@ dep:
|
||||||
$(CC) $(CPPFLAGS) $(CFLAGS) -MD -c $< -o $*.o
|
$(CC) $(CPPFLAGS) $(CFLAGS) -MD -c $< -o $*.o
|
||||||
mv $*.d dep
|
mv $*.d dep
|
||||||
|
|
||||||
O = vvp.o draw_mux.o draw_ufunc.o draw_vpi.o eval_expr.o eval_real.o vector.o \
|
O = vvp.o draw_mux.o draw_ufunc.o draw_vpi.o eval_bool.o eval_expr.o \
|
||||||
|
eval_real.o vector.o \
|
||||||
vvp_process.o vvp_scope.o
|
vvp_process.o vvp_scope.o
|
||||||
|
|
||||||
ifeq (@WIN32@,yes)
|
ifeq (@WIN32@,yes)
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,91 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2005 Stephen Williams (steve@icarus.com)
|
||||||
|
*
|
||||||
|
* This source code is free software; you can redistribute it
|
||||||
|
* and/or modify it in source code form under the terms of the GNU
|
||||||
|
* General Public License as published by the Free Software
|
||||||
|
* Foundation; either version 2 of the License, or (at your option)
|
||||||
|
* any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
|
||||||
|
*/
|
||||||
|
#ident "$Id: eval_bool.c,v 1.1 2005/09/14 02:53:15 steve Exp $"
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This file includes functions for evaluating REAL expressions.
|
||||||
|
*/
|
||||||
|
# include "config.h"
|
||||||
|
# include "vvp_priv.h"
|
||||||
|
# include <string.h>
|
||||||
|
#ifdef HAVE_MALLOC_H
|
||||||
|
# include <malloc.h>
|
||||||
|
#endif
|
||||||
|
# include <stdlib.h>
|
||||||
|
# include <stdint.h>
|
||||||
|
# include <math.h>
|
||||||
|
# include <assert.h>
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Evaluate the bool64 the hard way, by evaluating the logic vector
|
||||||
|
* and converting it to a bool64.
|
||||||
|
*/
|
||||||
|
static int eval_bool64_logic(ivl_expr_t exp)
|
||||||
|
{
|
||||||
|
int res;
|
||||||
|
struct vector_info tmp;
|
||||||
|
|
||||||
|
tmp = draw_eval_expr(exp, STUFF_OK_XZ);
|
||||||
|
res = allocate_word();
|
||||||
|
fprintf(vvp_out, " %%ix/get %d, %u, %u;\n", res, tmp.base, tmp.wid);
|
||||||
|
clr_vector(tmp);
|
||||||
|
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int draw_number_bool64(ivl_expr_t exp)
|
||||||
|
{
|
||||||
|
int res;
|
||||||
|
const char*bits = ivl_expr_bits(exp);
|
||||||
|
uint64_t val = 0;
|
||||||
|
unsigned long idx;
|
||||||
|
|
||||||
|
for (idx = 0 ; idx < ivl_expr_width(exp) ; idx += 1) {
|
||||||
|
if (bits[idx] == '1')
|
||||||
|
val |= 1UL << idx;
|
||||||
|
}
|
||||||
|
|
||||||
|
res = allocate_word();
|
||||||
|
fprintf(vvp_out, " %%ix/load %d, %lu;\n", res, val);
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
int draw_eval_bool64(ivl_expr_t exp)
|
||||||
|
{
|
||||||
|
int res;
|
||||||
|
|
||||||
|
switch (ivl_expr_type(exp)) {
|
||||||
|
case IVL_EX_NUMBER:
|
||||||
|
res = draw_number_bool64(exp);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
res = eval_bool64_logic(exp);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* $Log: eval_bool.c,v $
|
||||||
|
* Revision 1.1 2005/09/14 02:53:15 steve
|
||||||
|
* Support bool expressions and compares handle them optimally.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
@ -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: eval_expr.c,v 1.119 2005/07/13 04:52:31 steve Exp $"
|
#ident "$Id: eval_expr.c,v 1.120 2005/09/14 02:53:15 steve Exp $"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
# include "vvp_priv.h"
|
# include "vvp_priv.h"
|
||||||
|
|
@ -265,8 +265,10 @@ static struct vector_info draw_binary_expr_eq(ivl_expr_t exp,
|
||||||
&& number_is_immediate(re, 16))
|
&& number_is_immediate(re, 16))
|
||||||
return draw_eq_immediate(exp, ewid, le, re, stuff_ok_flag);
|
return draw_eq_immediate(exp, ewid, le, re, stuff_ok_flag);
|
||||||
|
|
||||||
assert(ivl_expr_value(le) == IVL_VT_VECTOR);
|
assert(ivl_expr_value(le) == IVL_VT_LOGIC
|
||||||
assert(ivl_expr_value(re) == IVL_VT_VECTOR);
|
|| ivl_expr_value(le) == IVL_VT_BOOL);
|
||||||
|
assert(ivl_expr_value(re) == IVL_VT_LOGIC
|
||||||
|
|| ivl_expr_value(re) == IVL_VT_BOOL);
|
||||||
|
|
||||||
wid = ivl_expr_width(le);
|
wid = ivl_expr_width(le);
|
||||||
if (ivl_expr_width(re) > wid)
|
if (ivl_expr_width(re) > wid)
|
||||||
|
|
@ -556,6 +558,63 @@ static struct vector_info draw_binary_expr_le_real(ivl_expr_t exp)
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static struct vector_info draw_binary_expr_le_bool(ivl_expr_t exp,
|
||||||
|
unsigned wid)
|
||||||
|
{
|
||||||
|
ivl_expr_t le = ivl_expr_oper1(exp);
|
||||||
|
ivl_expr_t re = ivl_expr_oper2(exp);
|
||||||
|
|
||||||
|
int lw, rw;
|
||||||
|
struct vector_info tmp;
|
||||||
|
|
||||||
|
char s_flag = (ivl_expr_signed(le) && ivl_expr_signed(re)) ? 's' : 'u';
|
||||||
|
|
||||||
|
assert(ivl_expr_value(le) == IVL_VT_BOOL);
|
||||||
|
assert(ivl_expr_value(re) == IVL_VT_BOOL);
|
||||||
|
|
||||||
|
lw = draw_eval_bool64(le);
|
||||||
|
rw = draw_eval_bool64(re);
|
||||||
|
|
||||||
|
switch (ivl_expr_opcode(exp)) {
|
||||||
|
case 'G':
|
||||||
|
fprintf(vvp_out, " %%cmp/w%c %u, %u;\n", s_flag, rw, lw);
|
||||||
|
fprintf(vvp_out, " %%or 5, 4, 1;\n");
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'L':
|
||||||
|
fprintf(vvp_out, " %%cmp/w%c %u, %u;\n", s_flag, lw, rw);
|
||||||
|
fprintf(vvp_out, " %%or 5, 4, 1;\n");
|
||||||
|
break;
|
||||||
|
|
||||||
|
case '<':
|
||||||
|
fprintf(vvp_out, " %%cmp/w%c %u, %u;\n", s_flag, lw, rw);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case '>':
|
||||||
|
fprintf(vvp_out, " %%cmp/w%c %u, %u;\n", s_flag, rw, lw);
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
assert(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
clr_word(lw);
|
||||||
|
clr_word(rw);
|
||||||
|
|
||||||
|
/* Move the result out out the 4-7 bit that the compare
|
||||||
|
uses. This is because that bit may be clobbered by other
|
||||||
|
expressions. */
|
||||||
|
{ unsigned base = allocate_vector(wid);
|
||||||
|
fprintf(vvp_out, " %%mov %u, 5, 1;\n", base);
|
||||||
|
tmp.base = base;
|
||||||
|
tmp.wid = wid;
|
||||||
|
if (wid > 1)
|
||||||
|
fprintf(vvp_out, " %%mov %u, 0, %u;\n", base+1, wid-1);
|
||||||
|
}
|
||||||
|
|
||||||
|
return tmp;
|
||||||
|
}
|
||||||
|
|
||||||
static struct vector_info draw_binary_expr_le(ivl_expr_t exp,
|
static struct vector_info draw_binary_expr_le(ivl_expr_t exp,
|
||||||
unsigned wid,
|
unsigned wid,
|
||||||
int stuff_ok_flag)
|
int stuff_ok_flag)
|
||||||
|
|
@ -578,8 +637,17 @@ static struct vector_info draw_binary_expr_le(ivl_expr_t exp,
|
||||||
if (ivl_expr_value(re) == IVL_VT_REAL)
|
if (ivl_expr_value(re) == IVL_VT_REAL)
|
||||||
return draw_binary_expr_le_real(exp);
|
return draw_binary_expr_le_real(exp);
|
||||||
|
|
||||||
assert(ivl_expr_value(le) == IVL_VT_VECTOR);
|
/* Detect the special case that we can do this with integers. */
|
||||||
assert(ivl_expr_value(re) == IVL_VT_VECTOR);
|
if (ivl_expr_value(le) == IVL_VT_BOOL
|
||||||
|
&& ivl_expr_value(re) == IVL_VT_BOOL
|
||||||
|
&& owid < 64) {
|
||||||
|
return draw_binary_expr_le_bool(exp, wid);
|
||||||
|
}
|
||||||
|
|
||||||
|
assert(ivl_expr_value(le) == IVL_VT_LOGIC
|
||||||
|
|| ivl_expr_value(le) == IVL_VT_BOOL);
|
||||||
|
assert(ivl_expr_value(re) == IVL_VT_LOGIC
|
||||||
|
|| ivl_expr_value(re) == IVL_VT_BOOL);
|
||||||
|
|
||||||
lv = draw_eval_expr_wid(le, owid, STUFF_OK_XZ);
|
lv = draw_eval_expr_wid(le, owid, STUFF_OK_XZ);
|
||||||
rv = draw_eval_expr_wid(re, owid, STUFF_OK_XZ);
|
rv = draw_eval_expr_wid(re, owid, STUFF_OK_XZ);
|
||||||
|
|
@ -1735,7 +1803,8 @@ static struct vector_info draw_sfunc_expr(ivl_expr_t exp, unsigned wid)
|
||||||
/* If the function has no parameters, then use this short-form
|
/* If the function has no parameters, then use this short-form
|
||||||
to draw the statement. */
|
to draw the statement. */
|
||||||
if (parm_count == 0) {
|
if (parm_count == 0) {
|
||||||
assert(ivl_expr_value(exp) == IVL_VT_VECTOR);
|
assert(ivl_expr_value(exp) == IVL_VT_LOGIC
|
||||||
|
|| ivl_expr_value(exp) == IVL_VT_BOOL);
|
||||||
res.base = allocate_vector(wid);
|
res.base = allocate_vector(wid);
|
||||||
res.wid = wid;
|
res.wid = wid;
|
||||||
fprintf(vvp_out, " %%vpi_func \"%s\", %u, %u;\n",
|
fprintf(vvp_out, " %%vpi_func \"%s\", %u, %u;\n",
|
||||||
|
|
@ -2030,6 +2099,9 @@ struct vector_info draw_eval_expr(ivl_expr_t exp, int stuff_ok_flag)
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* $Log: eval_expr.c,v $
|
* $Log: eval_expr.c,v $
|
||||||
|
* Revision 1.120 2005/09/14 02:53:15 steve
|
||||||
|
* Support bool expressions and compares handle them optimally.
|
||||||
|
*
|
||||||
* Revision 1.119 2005/07/13 04:52:31 steve
|
* Revision 1.119 2005/07/13 04:52:31 steve
|
||||||
* Handle functions with real values.
|
* Handle functions with real values.
|
||||||
*
|
*
|
||||||
|
|
|
||||||
|
|
@ -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
|
||||||
*/
|
*/
|
||||||
#ifdef HAVE_CVS_IDENT
|
#ifdef HAVE_CVS_IDENT
|
||||||
#ident "$Id: vvp_priv.h,v 1.33 2005/09/01 04:11:37 steve Exp $"
|
#ident "$Id: vvp_priv.h,v 1.34 2005/09/14 02:53:15 steve Exp $"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
# include "vvp_config.h"
|
# include "vvp_config.h"
|
||||||
|
|
@ -187,6 +187,15 @@ extern unsigned long get_number_immediate(ivl_expr_t ex);
|
||||||
*/
|
*/
|
||||||
extern int draw_eval_real(ivl_expr_t ex);
|
extern int draw_eval_real(ivl_expr_t ex);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* draw_eval_bool64 evaluates a bool expression. The return code from
|
||||||
|
* the function is the index of the word register that contains the
|
||||||
|
* result. The word is allocated widh allocate_word(), so the caller
|
||||||
|
* must arrange for it to be released with clr_word(). The width must
|
||||||
|
* be such that it fits in a 64bit word.
|
||||||
|
*/
|
||||||
|
extern int draw_eval_bool64(ivl_expr_t ex);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* These functions manage word register allocation.
|
* These functions manage word register allocation.
|
||||||
*/
|
*/
|
||||||
|
|
@ -201,6 +210,9 @@ extern unsigned thread_count;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* $Log: vvp_priv.h,v $
|
* $Log: vvp_priv.h,v $
|
||||||
|
* Revision 1.34 2005/09/14 02:53:15 steve
|
||||||
|
* Support bool expressions and compares handle them optimally.
|
||||||
|
*
|
||||||
* Revision 1.33 2005/09/01 04:11:37 steve
|
* Revision 1.33 2005/09/01 04:11:37 steve
|
||||||
* Generate code to handle real valued muxes.
|
* Generate code to handle real valued muxes.
|
||||||
*
|
*
|
||||||
|
|
|
||||||
|
|
@ -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: vvp_process.c,v 1.115 2005/07/11 16:56:51 steve Exp $"
|
#ident "$Id: vvp_process.c,v 1.116 2005/09/14 02:53:15 steve Exp $"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
# include "vvp_priv.h"
|
# include "vvp_priv.h"
|
||||||
|
|
@ -131,7 +131,6 @@ static void assign_to_lvector(ivl_lval_t lval, unsigned bit,
|
||||||
unsigned part_off = ivl_lval_part_off(lval);
|
unsigned part_off = ivl_lval_part_off(lval);
|
||||||
ivl_expr_t mux = ivl_lval_mux(lval);
|
ivl_expr_t mux = ivl_lval_mux(lval);
|
||||||
|
|
||||||
|
|
||||||
if (mux != 0) {
|
if (mux != 0) {
|
||||||
unsigned skip_assign = transient_id++;
|
unsigned skip_assign = transient_id++;
|
||||||
assert(dexp == 0);
|
assert(dexp == 0);
|
||||||
|
|
@ -914,7 +913,8 @@ static int show_stmt_delayx(ivl_statement_t net, ivl_scope_t sscope)
|
||||||
|
|
||||||
switch (ivl_expr_value(exp)) {
|
switch (ivl_expr_value(exp)) {
|
||||||
|
|
||||||
case IVL_VT_VECTOR: {
|
case IVL_VT_BOOL:
|
||||||
|
case IVL_VT_LOGIC: {
|
||||||
struct vector_info del = draw_eval_expr(exp, 0);
|
struct vector_info del = draw_eval_expr(exp, 0);
|
||||||
fprintf(vvp_out, " %%ix/get 0, %u, %u;\n",
|
fprintf(vvp_out, " %%ix/get 0, %u, %u;\n",
|
||||||
del.base, del.wid);
|
del.base, del.wid);
|
||||||
|
|
@ -1464,6 +1464,9 @@ int draw_func_definition(ivl_scope_t scope)
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* $Log: vvp_process.c,v $
|
* $Log: vvp_process.c,v $
|
||||||
|
* Revision 1.116 2005/09/14 02:53:15 steve
|
||||||
|
* Support bool expressions and compares handle them optimally.
|
||||||
|
*
|
||||||
* Revision 1.115 2005/07/11 16:56:51 steve
|
* Revision 1.115 2005/07/11 16:56:51 steve
|
||||||
* Remove NetVariable and ivl_variable_t structures.
|
* Remove NetVariable and ivl_variable_t structures.
|
||||||
*
|
*
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue