Add support for $unsigned.

This commit is contained in:
steve 2004-08-28 15:42:11 +00:00
parent d76ad25778
commit 7f67afe9d5
2 changed files with 37 additions and 2 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_expr.cc,v 1.89 2004/08/26 03:52:07 steve Exp $"
#ident "$Id: elab_expr.cc,v 1.90 2004/08/28 15:42:11 steve Exp $"
#endif
# include "config.h"
@ -192,6 +192,20 @@ NetExpr* PECallFunction::elaborate_sfunc_(Design*des, NetScope*scope) const
sub->cast_signed(true);
return sub;
}
/* add $unsigned to match $signed */
if (strcmp(path_.peek_name(0), "$unsigned") == 0) {
if ((parms_.count() != 1) || (parms_[0] == 0)) {
cerr << get_line() << ": error: The $unsigned() function "
<< "takes exactly one(1) argument." << endl;
des->errors += 1;
return 0;
}
PExpr*expr = parms_[0];
NetExpr*sub = expr->elaborate_expr(des, scope, true);
sub->cast_signed(false);
return sub;
}
/* Interpret the internal $sizeof system function to return
the bit width of the sub-expression. The value of the
@ -991,6 +1005,9 @@ NetExpr* PEUnary::elaborate_expr(Design*des, NetScope*scope, bool) const
/*
* $Log: elab_expr.cc,v $
* Revision 1.90 2004/08/28 15:42:11 steve
* Add support for $unsigned.
*
* Revision 1.89 2004/08/26 03:52:07 steve
* Add the $is_signed function.
*

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.133 2004/06/30 02:16:26 steve Exp $"
#ident "$Id: elab_net.cc,v 1.134 2004/08/28 15:42:12 steve Exp $"
#endif
# include "config.h"
@ -1196,6 +1196,21 @@ NetNet* PECallFunction::elaborate_net(Design*des, NetScope*scope,
sub->set_signed(true);
return sub;
}
/* handle $unsigned like $signed */
if (strcmp(path_.peek_name(0), "$unsigned") == 0) {
if ((parms_.count() != 1) || (parms_[0] == 0)) {
cerr << get_line() << ": error: The $unsigned() function "
<< "takes exactly one(1) argument." << endl;
des->errors += 1;
return 0;
}
PExpr*expr = parms_[0];
NetNet*sub = expr->elaborate_net(des, scope, width, rise,
fall, decay, drive0, drive1);
sub->set_signed(false);
return sub;
}
/* Look up the function definition. */
NetFuncDef*def = des->find_function(scope, path_);
@ -2473,6 +2488,9 @@ NetNet* PEUnary::elaborate_net(Design*des, NetScope*scope,
/*
* $Log: elab_net.cc,v $
* Revision 1.134 2004/08/28 15:42:12 steve
* Add support for $unsigned.
*
* Revision 1.133 2004/06/30 02:16:26 steve
* Implement signed divide and signed right shift in nets.
*