From 50a8c17cf88177a0cc7d430911f16d763da58014 Mon Sep 17 00:00:00 2001 From: Cary R Date: Fri, 13 Jun 2008 15:50:17 -0700 Subject: [PATCH] Comparison arguments are in a self determined context. This patch makes comparison arguments be evaluated in a self determined context. It also cleans up some other code items. --- elab_net.cc | 25 +++++++++++-------------- elaborate.cc | 2 +- 2 files changed, 12 insertions(+), 15 deletions(-) diff --git a/elab_net.cc b/elab_net.cc index c116c0ec7..8cbab1fdf 100644 --- a/elab_net.cc +++ b/elab_net.cc @@ -137,7 +137,7 @@ NetNet* PEBinary::elaborate_net_add_(Design*des, NetScope*scope, const NetExpr* decay) const { NetNet*lsig = left_->elaborate_net(des, scope, lwidth, 0, 0, 0), - *rsig = right_->elaborate_net(des, scope, lwidth, 0, 0, 0); + *rsig = right_->elaborate_net(des, scope, lwidth, 0, 0, 0); if (lsig == 0 || rsig == 0) return 0; @@ -449,26 +449,21 @@ NetNet* PEBinary::elaborate_net_cmp_(Design*des, NetScope*scope, const NetExpr* fall, const NetExpr* decay) const { - /* Elaborate the operands of the compare first as expressions (so that the eval_tree method can reduce constant expressions, including parameters) then turn those results into synthesized nets. */ - NetExpr*lexp = elab_and_eval(des, scope, left_, lwidth), - *rexp = elab_and_eval(des, scope, right_, lwidth); + NetExpr*lexp = elab_and_eval(des, scope, left_, -1), + *rexp = elab_and_eval(des, scope, right_, -1); if (lexp == 0 || rexp == 0) return 0; - unsigned operand_width; - bool real_arg = false; - if (lexp->expr_type() == IVL_VT_REAL || - rexp->expr_type() == IVL_VT_REAL) { - operand_width = 1; - real_arg = true; - } else { + bool real_arg = true; + if (lexp->expr_type() != IVL_VT_REAL && + rexp->expr_type() != IVL_VT_REAL) { /* Choose the operand width to be the width of the widest self-determined operand. */ - operand_width = lexp->expr_width(); + unsigned operand_width = lexp->expr_width(); if (rexp->expr_width() > operand_width) operand_width = rexp->expr_width(); @@ -476,6 +471,8 @@ NetNet* PEBinary::elaborate_net_cmp_(Design*des, NetScope*scope, lexp = pad_to_width(lexp, operand_width); rexp->set_width(operand_width); rexp = pad_to_width(rexp, operand_width); + + real_arg = false; } NetNet*lsig = 0; @@ -790,8 +787,8 @@ NetNet* PEBinary::elaborate_net_mod_(Design*des, NetScope*scope, const NetExpr* fall, const NetExpr* decay) const { - NetNet*lsig = left_->elaborate_net(des, scope, 0, 0, 0, 0), - *rsig = right_->elaborate_net(des, scope, 0, 0, 0, 0); + NetNet*lsig = left_->elaborate_net(des, scope, lwidth, 0, 0, 0), + *rsig = right_->elaborate_net(des, scope, lwidth, 0, 0, 0); if (lsig == 0 || rsig == 0) return 0; diff --git a/elaborate.cc b/elaborate.cc index 26740120e..3ab777c01 100644 --- a/elaborate.cc +++ b/elaborate.cc @@ -94,7 +94,7 @@ void PGAssign::elaborate(Design*des, NetScope*scope) const assert(lval->pin_count() == 1); if (debug_elaborate) { - cerr << get_fileline() << ": debug: PGassign: elaborated l-value" + cerr << get_fileline() << ": debug: PGAssign: elaborated l-value" << " width=" << lval->vector_width() << ", type=" << lval->data_type() << endl; }