From 3c5bf034ca1c2475c74024462b6d0b73e3c21ed5 Mon Sep 17 00:00:00 2001 From: Larry Doolittle Date: Mon, 12 May 2008 09:12:07 -0700 Subject: [PATCH 1/6] One more signed vs unsigned comparison fix Fix elab_expr.cc:1561: warning: comparison between signed and unsigned integer expressions caused by revised prototype of NetNet::sb_to_idx() in commit dfb7bf52115e39dc53d48e71847acc9767f1cc47 --- elab_expr.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/elab_expr.cc b/elab_expr.cc index 508617b35..28f0595d0 100644 --- a/elab_expr.cc +++ b/elab_expr.cc @@ -1558,7 +1558,8 @@ NetExpr* PEIdent::elaborate_expr_net_idx_do_(Design*des, NetScope*scope, // If the part select covers exactly the entire // vector, then do not bother with it. Return the // signal itself. - if (net->sig()->sb_to_idx(lsv) == (wid-1) && wid == net->vector_width()) + long l = net->sig()->sb_to_idx(lsv); + if (l >= 0 && (unsigned) l == (wid-1) && wid == net->vector_width()) return net; // Otherwise, make a part select that covers the right range. From add84b153c24a01d6fc06130b804501d5d51ce3e Mon Sep 17 00:00:00 2001 From: Cary R Date: Mon, 12 May 2008 17:55:10 -0700 Subject: [PATCH 2/6] Make sure stringify_flag is initialized. stringify_flag should not be used uninitialized. Found with valgrind. --- ivlpp/lexor.lex | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ivlpp/lexor.lex b/ivlpp/lexor.lex index 1d24e698d..08bdc3f66 100644 --- a/ivlpp/lexor.lex +++ b/ivlpp/lexor.lex @@ -1471,6 +1471,7 @@ static void do_include() fprintf(yyout, "\n`line %u \"%s\" 1\n", istack->lineno+1, standby->path); standby->next = istack; + standby->stringify_flag = 0; istack->yybs = YY_CURRENT_BUFFER; istack = standby; @@ -1710,6 +1711,7 @@ void reset_lexor(FILE* out, char* paths[]) isp->str = 0; isp->ebs = 0; isp->lineno = 0; + isp->stringify_flag = 0; if (isp->file == 0) { From 2b4f7f8aed757020e8c27ae8abf58c7aba07044b Mon Sep 17 00:00:00 2001 From: Stephen Williams Date: Tue, 13 May 2008 10:58:33 -0700 Subject: [PATCH 3/6] Revert "One more signed vs unsigned comparison fix" This reverts commit 3c5bf034ca1c2475c74024462b6d0b73e3c21ed5. A latter patch is more complete. --- elab_expr.cc | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/elab_expr.cc b/elab_expr.cc index 28f0595d0..508617b35 100644 --- a/elab_expr.cc +++ b/elab_expr.cc @@ -1558,8 +1558,7 @@ NetExpr* PEIdent::elaborate_expr_net_idx_do_(Design*des, NetScope*scope, // If the part select covers exactly the entire // vector, then do not bother with it. Return the // signal itself. - long l = net->sig()->sb_to_idx(lsv); - if (l >= 0 && (unsigned) l == (wid-1) && wid == net->vector_width()) + if (net->sig()->sb_to_idx(lsv) == (wid-1) && wid == net->vector_width()) return net; // Otherwise, make a part select that covers the right range. From a6dd97a5a66b95b8b96e2c7108830a819d7d7ca1 Mon Sep 17 00:00:00 2001 From: Cary R Date: Tue, 13 May 2008 11:04:56 -0700 Subject: [PATCH 4/6] Fix comparisons that use sb_to_idx() A recent change to sb_to_idx() made it return a signed value where it previously returned an unsigned value. This patch adds explicit casts to remove the two signed vs unsigned comparison warning messages. --- elab_expr.cc | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/elab_expr.cc b/elab_expr.cc index 508617b35..90c1937fc 100644 --- a/elab_expr.cc +++ b/elab_expr.cc @@ -1449,7 +1449,7 @@ NetExpr* PEIdent::elaborate_expr_net_part_(Design*des, NetScope*scope, } - if (net->sig()->sb_to_idx(msv) >= net->vector_width()) { + if (net->sig()->sb_to_idx(msv) >= (signed) net->vector_width()) { cerr << get_fileline() << ": error: part select [" << msv << ":" << lsv << "] out of range." << endl; des->errors += 1; @@ -1558,7 +1558,8 @@ NetExpr* PEIdent::elaborate_expr_net_idx_do_(Design*des, NetScope*scope, // If the part select covers exactly the entire // vector, then do not bother with it. Return the // signal itself. - if (net->sig()->sb_to_idx(lsv) == (wid-1) && wid == net->vector_width()) + if (net->sig()->sb_to_idx(lsv) == (signed) (wid-1) && + wid == net->vector_width()) return net; // Otherwise, make a part select that covers the right range. From 6b908aeec30c0a8fe06c85c0b5068a41e43bd515 Mon Sep 17 00:00:00 2001 From: Stephen Williams Date: Wed, 14 May 2008 11:51:53 -0700 Subject: [PATCH 5/6] Arithmetic operands can do unsigned work and have signed result. It is a quirk of the $signed() system function that the argument is converted to signed, but the operation that is performed is not changed. So arithmetic operators on unsigned arguments inside a $signed() expression still perform unsigned arithmetic. --- tgt-vvp/eval_expr.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tgt-vvp/eval_expr.c b/tgt-vvp/eval_expr.c index bca49cc0a..f7c5ed27d 100644 --- a/tgt-vvp/eval_expr.c +++ b/tgt-vvp/eval_expr.c @@ -1246,7 +1246,7 @@ static struct vector_info draw_binary_expr_arith(ivl_expr_t exp, unsigned wid) struct vector_info lv; struct vector_info rv; - const char*sign_string = ivl_expr_signed(exp)? "/s" : ""; + const char*sign_string = ivl_expr_signed(le) && ivl_expr_signed(re)? "/s" : ""; if ((ivl_expr_opcode(exp) == '+') && (ivl_expr_type(le) == IVL_EX_SIGNAL) From 2934ceb548e1cfac9b04dda936efd0caec2a85b5 Mon Sep 17 00:00:00 2001 From: Cary R Date: Wed, 14 May 2008 11:36:18 -0700 Subject: [PATCH 6/6] A constant thread vector is binary. Thread vectors can be treated as constants the problem was that they did not set a constant type. They now return vpiBinaryConst. --- vvp/vpi_vthr_vector.cc | 3 +++ 1 file changed, 3 insertions(+) diff --git a/vvp/vpi_vthr_vector.cc b/vvp/vpi_vthr_vector.cc index b58352978..72a043fe5 100644 --- a/vvp/vpi_vthr_vector.cc +++ b/vvp/vpi_vthr_vector.cc @@ -85,6 +85,9 @@ static int vthr_vec_get(int code, vpiHandle ref) case vpiSigned: return rfp->signed_flag; + case vpiConstType: + return vpiBinaryConst; // If this is a constant it is Binary. + case vpiSize: return rfp->wid;