From df226c5d13e06a8d312f484651eaaa5071430030 Mon Sep 17 00:00:00 2001 From: steve Date: Thu, 22 Dec 2005 15:43:47 +0000 Subject: [PATCH] pad_to_width handles signed expressions. --- pad_to_width.cc | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/pad_to_width.cc b/pad_to_width.cc index 44dac2578..efd10fc6e 100644 --- a/pad_to_width.cc +++ b/pad_to_width.cc @@ -17,7 +17,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ #ifdef HAVE_CVS_IDENT -#ident "$Id: pad_to_width.cc,v 1.19 2005/07/07 16:22:49 steve Exp $" +#ident "$Id: pad_to_width.cc,v 1.20 2005/12/22 15:43:47 steve Exp $" #endif # include "config.h" @@ -56,18 +56,10 @@ NetExpr*pad_to_width(NetExpr*expr, unsigned wid) return tmp; } - /* Do it the hard way, with a concatenation. */ - verinum pad(verinum::V0, wid - expr->expr_width()); - NetEConst*co = new NetEConst(pad); - co->set_line(*expr); - NetEConcat*cc = new NetEConcat(2); - cc->set_line(*expr); - cc->set(0, co); - cc->set(1, expr); - cc->set_width(wid); - expr = cc; - - return expr; + NetESelect*tmp = new NetESelect(expr, 0, wid); + tmp->set_line(*expr); + tmp->cast_signed(expr->has_sign()); + return tmp; } /* @@ -159,6 +151,9 @@ NetNet*crop_to_width(Design*des, NetNet*net, unsigned wid) /* * $Log: pad_to_width.cc,v $ + * Revision 1.20 2005/12/22 15:43:47 steve + * pad_to_width handles signed expressions. + * * Revision 1.19 2005/07/07 16:22:49 steve * Generalize signals to carry types. *