From 94e7d71b9761647f16430beecd9382376f7c7ad3 Mon Sep 17 00:00:00 2001 From: Stephen Williams Date: Mon, 27 Oct 2008 21:39:07 -0700 Subject: [PATCH] Make sure divide expressions are evaluated using the expression width. The operands of divide need to be at least the width of the expression when calculating a constant divide. The only matters for the special case where the result is x, because the verinum implementation of divide will get the result width from the left expression width. --- eval_tree.cc | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/eval_tree.cc b/eval_tree.cc index be195159f..40cdf517a 100644 --- a/eval_tree.cc +++ b/eval_tree.cc @@ -858,8 +858,10 @@ NetExpr* NetEBDiv::eval_tree(int prune_to_width) NetEConst*rc = dynamic_cast(right_); if (rc == 0) return 0; - verinum lval = lc->value(); - verinum rval = rc->value(); + // Make sure the expression is evaluated at the + // expression width. + verinum lval = pad_to_width(lc->value(), expr_width()); + verinum rval = pad_to_width(rc->value(), expr_width()); NetExpr*tmp = 0; switch (op_) {