From 7f67afe9d577124495742f810158e8fdc0f10ea2 Mon Sep 17 00:00:00 2001 From: steve Date: Sat, 28 Aug 2004 15:42:11 +0000 Subject: [PATCH] Add support for $unsigned. --- elab_expr.cc | 19 ++++++++++++++++++- elab_net.cc | 20 +++++++++++++++++++- 2 files changed, 37 insertions(+), 2 deletions(-) diff --git a/elab_expr.cc b/elab_expr.cc index 9820d1a7b..ccebf60c0 100644 --- a/elab_expr.cc +++ b/elab_expr.cc @@ -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. * diff --git a/elab_net.cc b/elab_net.cc index bfeba7585..25531f1c4 100644 --- a/elab_net.cc +++ b/elab_net.cc @@ -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. *