Skip to content

Commit

Permalink
Add regression test for Verilog AMS abs() with function call argument
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
larsclausen committed Apr 12, 2022
1 parent 1bf568d commit 4ae2eec
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 0 deletions.
59 changes: 59 additions & 0 deletions ivtest/ivltests/vams_abs3.v
Original file line number Diff line number Diff line change
@@ -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
1 change: 1 addition & 0 deletions ivtest/regress-vams.list
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions ivtest/regress-vlog95.list
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 4ae2eec

Please sign in to comment.