Fix C compiler interpreting signing, bug773.

This commit is contained in:
Wilson Snyder 2014-05-24 08:00:01 -04:00
parent 91e706ec1f
commit f705f9b275
3 changed files with 16 additions and 5 deletions

View File

@ -11,6 +11,8 @@ indicates the contributor was also the author of the fix; Thanks!
**** Fix shift corner issues, bug765, bug766, bug768, bug772. [Clifford Wolf]
**** Fix C compiler interpreting signing, bug773. [Clifford Wolf]
**** Fix gate primitives with arrays and non-arrayed pins.
**** Fix ENDLABEL warnings on escaped identifiers.

View File

@ -622,8 +622,9 @@ public:
// Only 32 bits - llx + long long here just to appease CPP format warning
if (num<10) puts(cvtToStr(num));
else ofp()->printf("0x%" VL_PRI64 "x", (vluint64_t)num);
//Unneeded-Causes %lx format warnings:
// if (!nodep->num().isSigned() && (num & (1UL<<31))) puts("U");
// If signed, we'll do our own functions
// But must be here, or <= comparisons etc may end up signed
puts("U");
}
}
void emitSetVarConstant(const string& assignString, AstConst* constp) {

View File

@ -5,6 +5,11 @@
`define checkh(gotv,expv) do if ((gotv) !== (expv)) begin $write("%%Error: %s:%0d: got='h%x exp='h%x\n", `__FILE__,`__LINE__, (gotv), (expv)); fail='1; end while(0)
`define checkf(gotv,expv) do if ((gotv) !== (expv)) begin $write("%%Error: %s:%0d: got=%f exp=%f\n", `__FILE__,`__LINE__, (gotv), (expv)); fail='1; end while(0)
`ifdef VERILATOR
`define c(v,vs) ($c(vs)) // Don't constify a value
`else
`define c(v,vs) (v)
`endif
module t (/*AUTOARG*/);
@ -127,9 +132,7 @@
w4_s = 4'sd4;
w4_u = $signed(5'd1 > w4_s-w4_s);
`checkh(w4_u, 4'b1111);
`ifdef VERILATOR
w4_s = $c4("4"); // Eval at runtime
`endif
w4_s = `c(4,"4"); // Eval at runtime
w4_u = $signed(5'd1 > w4_s-w4_s);
`checkh(w4_u, 4'b1111);
@ -139,6 +142,11 @@
`checkh(w4_s, 4'bxxxx);
`endif
// bug773
w5_u = `c(31, "31");
w5_s = w5_u >> ((w5_u ? 1 : 2) << w5_u);
`checkh(w5_s, 5'b0);
if (fail) $stop;
$write("*-* All Finished *-*\n");
$finish;