From f8bd8e1bd61a86a42e875cc2f996155214763bac Mon Sep 17 00:00:00 2001 From: Stephen Williams Date: Sat, 16 Aug 2008 17:30:32 -0700 Subject: [PATCH] Unary minus and signed right shift need to extend their arguments. In signed contextx, the right shift and unary minus expressions need to be sign extended before they operate, otherwise there may be bad results in the high bits in the greater context. --- elab_expr.cc | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/elab_expr.cc b/elab_expr.cc index 2af5b86f8..fd033ab33 100644 --- a/elab_expr.cc +++ b/elab_expr.cc @@ -263,6 +263,8 @@ NetExpr* PEBinary::elaborate_expr_base_(Design*des, case 'r': // >> case 'R': // >>> + if (expr_wid > 0) + lp = pad_to_width(lp, expr_wid); tmp = new NetEBShift(op_, lp, rp); tmp->set_line(*this); break; @@ -2030,6 +2032,8 @@ NetExpr* PEUnary::elaborate_expr(Design*des, NetScope*scope, delete ip; } else { + if (expr_wid > 0) + ip = pad_to_width(ip, expr_wid); tmp = new NetEUnary(op_, ip); tmp->set_line(*this); }