Skip to content

Commit 4ae2eec

Browse files
committed
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 <[email protected]>
1 parent 1bf568d commit 4ae2eec

File tree

3 files changed

+61
-0
lines changed

3 files changed

+61
-0
lines changed

ivtest/ivltests/vams_abs3.v

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
// Check that VAMS `abs()` functions works if its argument is a function call
2+
3+
module main;
4+
5+
function reg signed [7:0] fv(input reg signed [7:0] x);
6+
fv = x;
7+
endfunction
8+
9+
function real fr(input real x);
10+
fr = x;
11+
endfunction
12+
13+
reg signed [7:0] a;
14+
wire signed [7:0] vala = abs(fv(a));
15+
16+
reg real b;
17+
wire real valb = abs(fr(b));
18+
19+
initial begin
20+
a = 0;
21+
b = 0;
22+
#1 if (vala !== 0) begin
23+
$display("FAILED -- a=%b, vala=%b", a, vala);
24+
$finish;
25+
end
26+
27+
#1 if (valb != 0) begin
28+
$display("FAILED -- b=%g valb=%g", b, valb);
29+
$finish;
30+
end
31+
32+
a = 1;
33+
b = 1;
34+
#1 if (vala !== 1) begin
35+
$display("FAILED -- a=%b, vala=%b", a, vala);
36+
$finish;
37+
end
38+
39+
#1 if (valb != 1) begin
40+
$display("FAILED -- b=%g valb=%g", b, valb);
41+
$finish;
42+
end
43+
44+
a = -1;
45+
b = -1;
46+
#1 if (vala !== 1) begin
47+
$display("FAILED -- a=%b, vala=%b", a, vala);
48+
$finish;
49+
end
50+
51+
#1 if (valb != 1) begin
52+
$display("FAILED -- b=%g valb=%g", b, valb);
53+
$finish;
54+
end
55+
56+
$display("PASSED");
57+
end
58+
59+
endmodule // main

ivtest/regress-vams.list

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ value_range2 normal,-gverilog-ams ivltests
8181
value_range3 CE,-gverilog-ams ivltests
8282
vams_abs1 normal,-gverilog-ams ivltests
8383
vams_abs2 normal,-gverilog-ams ivltests
84+
vams_abs3 normal,-gverilog-ams ivltests
8485
wreal normal,-gverilog-ams ivltests
8586
# Verilog functions added in a VAMS simulator
8687
constfunc6_ams normal ivltests

ivtest/regress-vlog95.list

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,7 @@ real_wire_force_rel CE ivltests
158158
tern8 CE ivltests
159159
v2005_math CE ivltests
160160
vams_abs2 CE,-gverilog-ams,-pallowsigned=1 ivltests
161+
vams_abs3 CE,-gverilog-ams,-pallowsigned=1 ivltests
161162
vhdl_real CE,-g2009,ivltests/vhdl_real.vhd ivltests
162163
vhdl_unbounded CE,-g2009,ivltests/vhdl_unbounded.vhd ivltests
163164
wreal CE ivltests

0 commit comments

Comments
 (0)