-
Notifications
You must be signed in to change notification settings - Fork 533
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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]>
- Loading branch information
1 parent
1bf568d
commit 4ae2eec
Showing
3 changed files
with
61 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters