From 2ce98413540f4cfe6cb941ddb25279b5f102e9d0 Mon Sep 17 00:00:00 2001 From: Cary R Date: Wed, 26 Nov 2008 18:55:12 -0800 Subject: [PATCH] A power needs to use the signed (real pow) if either argument is signed. The power operator is different in that it uses the signed version if either of it's arguments are signed. This patch fixes the code generator to do this correctly. --- tgt-vvp/eval_expr.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/tgt-vvp/eval_expr.c b/tgt-vvp/eval_expr.c index 72f48ae62..1c22c394b 100644 --- a/tgt-vvp/eval_expr.c +++ b/tgt-vvp/eval_expr.c @@ -1469,8 +1469,13 @@ static struct vector_info draw_binary_expr_arith(ivl_expr_t exp, unsigned wid) break; case 'p': - fprintf(vvp_out, " %%pow%s %u, %u, %u;\n", sign_string, - lv.base, rv.base, wid); + if (ivl_expr_signed(le) || ivl_expr_signed(re)) { + fprintf(vvp_out, " %%pow/s %u, %u, %u;\n", + lv.base, rv.base, wid); + } else { + fprintf(vvp_out, " %%pow %u, %u, %u;\n", + lv.base, rv.base, wid); + } break; default: