From f11757e43af3ad55b96e4aacd614ffe24b63cd3f Mon Sep 17 00:00:00 2001 From: Wilson Snyder Date: Mon, 12 Sep 2016 18:31:45 -0400 Subject: [PATCH] Fix error on wide shift, msg2005. --- Changes | 2 +- src/V3Width.cpp | 2 +- test_regress/t/t_math_shift.v | 8 ++++++-- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/Changes b/Changes index a62e994ce..223ad8ec9 100644 --- a/Changes +++ b/Changes @@ -10,7 +10,7 @@ indicates the contributor was also the author of the fix; Thanks! **** Fix SystemC compiles with VPI, bug1081. [Arthur Kahlich] -**** Fix error on wide numbers that represent small msb/lsb, msg1991. [Mandy Xu] +**** Fix error on wide numbers that represent msb/lsb or shifts, msg1991. [Mandy Xu] **** Improve Verilation performance on internal strings, msg1975. [Johan Bjork] diff --git a/src/V3Width.cpp b/src/V3Width.cpp index 5640b642d..b8b3227e8 100644 --- a/src/V3Width.cpp +++ b/src/V3Width.cpp @@ -2632,7 +2632,7 @@ private: AstNode* shiftp = nodep->rhsp(); nodep->rhsp()->replaceWith(new AstConst(shiftp->fileline(), num)); shiftp->deleteTree(); VL_DANGLING(shiftp); - } else { + } else if (!m_paramsOnly) { nodep->rhsp()->v3error("Unsupported: Shifting of by over 32-bit number isn't supported." <<" (This isn't a shift of 32 bits, but a shift of 2^32, or 4 billion!)\n"); } diff --git a/test_regress/t/t_math_shift.v b/test_regress/t/t_math_shift.v index 0770fd431..a2ca18556 100644 --- a/test_regress/t/t_math_shift.v +++ b/test_regress/t/t_math_shift.v @@ -13,10 +13,13 @@ module t (/*AUTOARG*/ input clk; output [31:0] ign; + parameter [95:0] P6 = 6; + localparam P64 = (1 << P6); + reg [31:0] right; reg [31:0] left; - reg [63:0] qright; - reg [63:0] qleft; + reg [P64-1:0] qright; + reg [P64-1:0] qleft; reg [31:0] amt; assign ign = {31'h0, clk} >>> 4'bx; // bug760 @@ -37,6 +40,7 @@ module t (/*AUTOARG*/ `endif if (cyc==1) begin amt <= 32'd0; + if (P64 != 64) $stop; if (5'b10110>>2 != 5'b00101) $stop; if (5'b10110>>>2 != 5'b00101) $stop; // Note it cares about sign-ness if (5'b10110<<2 != 5'b11000) $stop;