Add regression tests for unary real minus special values
Check that unary real minus preserves the sign or bit pattern for zero, NaN, and infinity. Each test starts with the positive value, negates it, and then negates the result back to the positive value. Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
This commit is contained in:
parent
5311c0cd38
commit
0e7c62d579
|
|
@ -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
|
||||
|
|
@ -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
|
||||
|
|
@ -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
|
||||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -0,0 +1,4 @@
|
|||
{
|
||||
"type" : "normal",
|
||||
"source" : "real_unary_minus_inf.v"
|
||||
}
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
{
|
||||
"type" : "normal",
|
||||
"source" : "real_unary_minus_nan.v"
|
||||
}
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
{
|
||||
"type" : "normal",
|
||||
"source" : "real_unary_minus_zero.v"
|
||||
}
|
||||
Loading…
Reference in New Issue