diff --git a/ivtest/ivltests/real_unary_minus_inf.v b/ivtest/ivltests/real_unary_minus_inf.v new file mode 100644 index 000000000..543644d68 --- /dev/null +++ b/ivtest/ivltests/real_unary_minus_inf.v @@ -0,0 +1,31 @@ +// Check that unary real minus preserves infinities. + +module test; + + reg failed; + real inf; + real result; + + `define check(val, exp) \ + if (val !== exp) begin \ + $display("FAILED(%0d). '%s' expected %h, got %h", `__LINE__, \ + `"val`", exp, val); \ + failed = 1'b1; \ + end + + initial begin + failed = 1'b0; + inf = $bitstoreal(64'h7ff0000000000000); + + result = -inf; + `check($realtobits(result), 64'hfff0000000000000); + + result = -result; + `check($realtobits(result), 64'h7ff0000000000000); + + if (!failed) begin + $display("PASSED"); + end + end + +endmodule diff --git a/ivtest/ivltests/real_unary_minus_nan.v b/ivtest/ivltests/real_unary_minus_nan.v new file mode 100644 index 000000000..f9ea679aa --- /dev/null +++ b/ivtest/ivltests/real_unary_minus_nan.v @@ -0,0 +1,31 @@ +// Check that unary real minus preserves NaN bits. + +module test; + + reg failed; + real nan; + real result; + + `define check(val, exp) \ + if (val !== exp) begin \ + $display("FAILED(%0d). '%s' expected %h, got %h", `__LINE__, \ + `"val`", exp, val); \ + failed = 1'b1; \ + end + + initial begin + failed = 1'b0; + nan = $bitstoreal(64'h7ff8000000000001); + + result = -nan; + `check($realtobits(result), 64'hfff8000000000001); + + result = -result; + `check($realtobits(result), 64'h7ff8000000000001); + + if (!failed) begin + $display("PASSED"); + end + end + +endmodule diff --git a/ivtest/ivltests/real_unary_minus_zero.v b/ivtest/ivltests/real_unary_minus_zero.v new file mode 100644 index 000000000..1c92bc27d --- /dev/null +++ b/ivtest/ivltests/real_unary_minus_zero.v @@ -0,0 +1,31 @@ +// Check that unary real minus preserves the sign of zero. + +module test; + + reg failed; + real zero; + real result; + + `define check(val, exp) \ + if (val !== exp) begin \ + $display("FAILED(%0d). '%s' expected %h, got %h", `__LINE__, \ + `"val`", exp, val); \ + failed = 1'b1; \ + end + + initial begin + failed = 1'b0; + zero = 0.0; + + result = -zero; + `check($realtobits(result), 64'h8000000000000000); + + result = -result; + `check($realtobits(result), 64'h0000000000000000); + + if (!failed) begin + $display("PASSED"); + end + end + +endmodule diff --git a/ivtest/regress-vvp.list b/ivtest/regress-vvp.list index 7689bca81..9655c20df 100644 --- a/ivtest/regress-vvp.list +++ b/ivtest/regress-vvp.list @@ -214,6 +214,9 @@ pv_wr_fn_vec4 vvp_tests/pv_wr_fn_vec4.json queue_fail vvp_tests/queue_fail.json readmem-invalid vvp_tests/readmem-invalid.json real_negative_zero vvp_tests/real_negative_zero.json +real_unary_minus_inf vvp_tests/real_unary_minus_inf.json +real_unary_minus_nan vvp_tests/real_unary_minus_nan.json +real_unary_minus_zero vvp_tests/real_unary_minus_zero.json scaled_real vvp_tests/scaled_real.json scan-invalid vvp_tests/scan-invalid.json sdf_interconnect1 vvp_tests/sdf_interconnect1.json diff --git a/ivtest/vvp_tests/real_unary_minus_inf.json b/ivtest/vvp_tests/real_unary_minus_inf.json new file mode 100644 index 000000000..15f4203e7 --- /dev/null +++ b/ivtest/vvp_tests/real_unary_minus_inf.json @@ -0,0 +1,4 @@ +{ + "type" : "normal", + "source" : "real_unary_minus_inf.v" +} diff --git a/ivtest/vvp_tests/real_unary_minus_nan.json b/ivtest/vvp_tests/real_unary_minus_nan.json new file mode 100644 index 000000000..4dde327de --- /dev/null +++ b/ivtest/vvp_tests/real_unary_minus_nan.json @@ -0,0 +1,4 @@ +{ + "type" : "normal", + "source" : "real_unary_minus_nan.v" +} diff --git a/ivtest/vvp_tests/real_unary_minus_zero.json b/ivtest/vvp_tests/real_unary_minus_zero.json new file mode 100644 index 000000000..27bf853c9 --- /dev/null +++ b/ivtest/vvp_tests/real_unary_minus_zero.json @@ -0,0 +1,4 @@ +{ + "type" : "normal", + "source" : "real_unary_minus_zero.v" +}