diff --git a/Changes b/Changes index ffcf180ce..45d1dd76b 100644 --- a/Changes +++ b/Changes @@ -7,6 +7,8 @@ indicates the contributor was also the author of the fix; Thanks! **** Fix generate unrolling with function call, bug830. [Steven Slatter] +**** Fix cast-to-size context-determined sizing, bug828. [Geoff Barrett] + * Verilator 3.864 2014-09-21 diff --git a/src/V3Width.cpp b/src/V3Width.cpp index 62bdb3e40..2a8fd9dd3 100644 --- a/src/V3Width.cpp +++ b/src/V3Width.cpp @@ -931,7 +931,7 @@ private: : nodep->findBitDType(width, width, underDtp->numeric())); nodep->dtypep(newDtp); // We ignore warnings as that is sort of the point of a cast - iterateCheck(nodep,"Cast LHS",nodep->lhsp(),SELF,FINAL,newDtp,EXTEND_EXP,false); + iterateCheck(nodep,"Cast LHS",nodep->lhsp(),CONTEXT,FINAL,newDtp,EXTEND_EXP,false); } if (vup->c()->final()) { // CastSize not needed once sizes determined diff --git a/test_regress/t/t_math_signed5.v b/test_regress/t/t_math_signed5.v index 3bd62b75e..f8d170080 100644 --- a/test_regress/t/t_math_signed5.v +++ b/test_regress/t/t_math_signed5.v @@ -26,6 +26,7 @@ reg [5:0] w6_u; reg [15:0] w16a_u; reg [15:0] w16_u; + reg [31:0] w32_u; real r; reg signed [4:0] bug754_a; @@ -162,6 +163,16 @@ w4_u = (w4_u >> w4_u) ^~ (w4_u >> w4_u); `checkh(w4_u, 4'b1111); + // bug828 + // verilator lint_off WIDTH + w32_u = 32'(signed'({4'b0001,5'b10000}) << 3); + `checkh(w32_u, 32'h0000_0180); + w32_u = 32'(signed'({4'b0011,5'b10000}) << 3); + `checkh(w32_u, 32'h0000_0380); + // verilator lint_on WIDTH + w32_u = 32'(signed'({4'b0011,5'b10000})) << 3; // Check no width warning + `checkh(w32_u, 32'h0000_0380); + if (fail) $stop; $write("*-* All Finished *-*\n"); $finish;