From e77b7427b49c7b9c02935f46208eed451bdfe3fd Mon Sep 17 00:00:00 2001 From: Wilson Snyder Date: Tue, 10 Jun 2014 19:13:55 -0400 Subject: [PATCH] Fix shift corner-case, bug 774. --- Changes | 2 +- src/V3Expand.cpp | 4 ++-- test_regress/t/t_math_signed5.v | 10 ++++++++-- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/Changes b/Changes index e261897e5..3ee8cd4ee 100644 --- a/Changes +++ b/Changes @@ -21,7 +21,7 @@ indicates the contributor was also the author of the fix; Thanks! **** Fix pattern assignment to conditionals, bug769. [Jie Xu] -**** Fix shift corner-cases, bug765, bug766, bug768, bug772, bug776. [Clifford Wolf] +**** Fix shift corner-cases, bug765, bug766, bug768, bug772, bug774, bug776. [Clifford Wolf] **** Fix C compiler interpreting signing, bug773. [Clifford Wolf] diff --git a/src/V3Expand.cpp b/src/V3Expand.cpp index bb7293e52..f2a7fbf82 100644 --- a/src/V3Expand.cpp +++ b/src/V3Expand.cpp @@ -448,8 +448,8 @@ private: AstNode* newp = new AstShiftR (nodep->fileline(), fromp, dropCondBound(lsbp), - nodep->width()); - newp->dtypeFrom(nodep); + fromp->width()); // {large}>>32 requires 64-bit shift operation; then cast + newp->dtypeFrom(fromp); if (!nodep->isQuad() && fromp->isQuad()) { newp = new AstCCast (newp->fileline(), newp, nodep); } diff --git a/test_regress/t/t_math_signed5.v b/test_regress/t/t_math_signed5.v index 0f4585066..3bd62b75e 100644 --- a/test_regress/t/t_math_signed5.v +++ b/test_regress/t/t_math_signed5.v @@ -147,11 +147,17 @@ `endif // bug773 - w5_u = `c(31, "31"); + w5_u = `c(31, 31); w5_s = w5_u >> ((w5_u ? 1 : 2) << w5_u); `checkh(w5_s, 5'b0); - //bug776 + // bug774 + w4_u = `c(4, 5); + w6_u = `c(6, 35); + w4_u = 64'd0 | (w4_u << w6_u); + `checkh(w4_u, 0); + + // bug776 w4_u = `c(4, 1); w4_u = (w4_u >> w4_u) ^~ (w4_u >> w4_u); `checkh(w4_u, 4'b1111);