Add regression test for Verilog AMS abs() with function call argument

Check that the behavior of the Verilog AMS `abs()` function is correct when
its argument is a function call. Check this for both vector as well as real
types.

This test is largely a copy of the existing vams_abs2 test, just replacing
the identifier argument with a function call argument.

Signed-off-by: Lars-Peter Clausen <lars@metafoo.de>
This commit is contained in:
Lars-Peter Clausen 2022-04-12 18:37:34 +02:00
parent 1bf568d808
commit 4ae2eec275
3 changed files with 61 additions and 0 deletions

View File

@ -0,0 +1,59 @@
// Check that VAMS `abs()` functions works if its argument is a function call
module main;
function reg signed [7:0] fv(input reg signed [7:0] x);
fv = x;
endfunction
function real fr(input real x);
fr = x;
endfunction
reg signed [7:0] a;
wire signed [7:0] vala = abs(fv(a));
reg real b;
wire real valb = abs(fr(b));
initial begin
a = 0;
b = 0;
#1 if (vala !== 0) begin
$display("FAILED -- a=%b, vala=%b", a, vala);
$finish;
end
#1 if (valb != 0) begin
$display("FAILED -- b=%g valb=%g", b, valb);
$finish;
end
a = 1;
b = 1;
#1 if (vala !== 1) begin
$display("FAILED -- a=%b, vala=%b", a, vala);
$finish;
end
#1 if (valb != 1) begin
$display("FAILED -- b=%g valb=%g", b, valb);
$finish;
end
a = -1;
b = -1;
#1 if (vala !== 1) begin
$display("FAILED -- a=%b, vala=%b", a, vala);
$finish;
end
#1 if (valb != 1) begin
$display("FAILED -- b=%g valb=%g", b, valb);
$finish;
end
$display("PASSED");
end
endmodule // main

View File

@ -81,6 +81,7 @@ value_range2 normal,-gverilog-ams ivltests
value_range3 CE,-gverilog-ams ivltests
vams_abs1 normal,-gverilog-ams ivltests
vams_abs2 normal,-gverilog-ams ivltests
vams_abs3 normal,-gverilog-ams ivltests
wreal normal,-gverilog-ams ivltests
# Verilog functions added in a VAMS simulator
constfunc6_ams normal ivltests

View File

@ -158,6 +158,7 @@ real_wire_force_rel CE ivltests
tern8 CE ivltests
v2005_math CE ivltests
vams_abs2 CE,-gverilog-ams,-pallowsigned=1 ivltests
vams_abs3 CE,-gverilog-ams,-pallowsigned=1 ivltests
vhdl_real CE,-g2009,ivltests/vhdl_real.vhd ivltests
vhdl_unbounded CE,-g2009,ivltests/vhdl_unbounded.vhd ivltests
wreal CE ivltests