diff --git a/Changes b/Changes index ff6999eb6..0e5c75deb 100644 --- a/Changes +++ b/Changes @@ -27,7 +27,7 @@ indicates the contributor was also the author of the fix; Thanks! **** Fix signed extension problems with -Wno-WIDTH, bug729. [Clifford Wolf] -**** Fix power operator calculation, bug730. [Clifford Wolf] +**** Fix power operator calculation, bug730, bug735. [Clifford Wolf] **** Fix Mac OS-X test issues. [Holger Waechtler] diff --git a/src/V3Number.cpp b/src/V3Number.cpp index 217073d12..5b083e336 100644 --- a/src/V3Number.cpp +++ b/src/V3Number.cpp @@ -47,6 +47,7 @@ V3Number::V3Number(VerilogString, FileLine* fileline, const string& str) { } } } + opCleanThis(); } V3Number::V3Number (FileLine* fileline, const char* sourcep) { @@ -252,6 +253,7 @@ V3Number::V3Number (FileLine* fileline, const char* sourcep) { setBit(obit, bitIs(obit-1)); obit++; } + opCleanThis(); //printf("Dump \"%s\" CP \"%s\" B '%c' %d W %d\n", sourcep, value_startp, base, width(), m_value[0]); } @@ -276,11 +278,13 @@ V3Number& V3Number::setQuad(vluint64_t value) { for (int i=0; i>VL_ULL(32)) & VL_ULL(0xffffffff); + opCleanThis(); return *this; } V3Number& V3Number::setLong(uint32_t value) { for (int i=0; i> s) | (shift_mask & (un[i+1] << (32-s))); } for (int i=vw; i1, + ); + +ok(1); +1; diff --git a/test_regress/t/t_math_pow4.v b/test_regress/t/t_math_pow4.v new file mode 100644 index 000000000..392eb3f20 --- /dev/null +++ b/test_regress/t/t_math_pow4.v @@ -0,0 +1,68 @@ +// DESCRIPTION: Verilator: Verilog Test module +// +// This file ONLY is placed into the Public Domain, for any use, +// without warranty, 2014 by Clifford Wolf. + +module t (/*AUTOARG*/ + // Inputs + clk + ); + input clk; + + integer cyc=0; + + wire [31:0] y; + reg a; + test004 sub (/*AUTOINST*/ + // Outputs + .y (y[31:0]), + // Inputs + .a (a)); + + // Test loop + always @ (posedge clk) begin +`ifdef TEST_VERBOSE + $write("[%0t] cyc==%0d a=%x y=%x\n",$time, cyc, a, y); +`endif + cyc <= cyc + 1; + if (cyc==0) begin + a <= 0; + end + else if (cyc==1) begin + a <= 1; + if (y != 32'h0) $stop; + end + else if (cyc==2) begin + if (y != 32'h010000ff) $stop; + end + else if (cyc==99) begin + $write("*-* All Finished *-*\n"); + $finish; + end + end + +endmodule + +module test004(a, y); + input a; + output [31:0] y; + + wire [7:0] y0; + wire [7:0] y1; + wire [7:0] y2; + wire [7:0] y3; + assign y = {y0,y1,y2,y3}; + + localparam [7:0] v0 = +8'sd1 ** -8'sd2; //'h01 + localparam [7:0] v1 = +8'sd2 ** -8'sd2; //'h00 + localparam [7:0] v2 = -8'sd2 ** -8'sd3; //'h00 + localparam [7:0] v3 = -8'sd1 ** -8'sd3; //'hff + localparam [7:0] zero = 0; + + initial $display("v0=%x v1=%x v2=%x v3=%x", v0,v1,v2,v3); + + assign y0 = a ? v0 : zero; + assign y1 = a ? v1 : zero; + assign y2 = a ? v2 : zero; + assign y3 = a ? v3 : zero; +endmodule