-
Notifications
You must be signed in to change notification settings - Fork 523
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add regression tests for checking constant function call scopes.
- Loading branch information
1 parent
f3092bb
commit 5cbdff2
Showing
8 changed files
with
124 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,3 @@ | ||
ivltests/constfunccall3.v:21: error: A function invoked by a constant function must be a constant function local to the current module or provided by a package. | ||
ivltests/constfunccall3.v:26: error: `f2' is not a constant function. | ||
2 error(s) during elaboration. |
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,32 @@ | ||
// Check that a constant function call is permitted when the call is inside | ||
// a named block (issue #1141) | ||
|
||
module test; | ||
|
||
function integer f1(input integer i); | ||
|
||
begin | ||
f1 = i + 1; | ||
end | ||
|
||
endfunction | ||
|
||
function integer f2(input integer i); | ||
|
||
begin : b2 | ||
f2 = f1(i); | ||
end | ||
|
||
endfunction | ||
|
||
localparam p = f2(1); | ||
|
||
initial begin | ||
$display(p); | ||
if (p === 2) | ||
$display("PASSED"); | ||
else | ||
$display("FAILED"); | ||
end | ||
|
||
endmodule |
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,36 @@ | ||
// Check that a constant function call is permitted when the function is | ||
// provided by a package. | ||
|
||
package p1; | ||
|
||
function integer f1(input integer i); | ||
|
||
begin | ||
f1 = i + 1; | ||
end | ||
|
||
endfunction | ||
|
||
endpackage | ||
|
||
module test; | ||
|
||
function integer f2(input integer i); | ||
|
||
begin | ||
f2 = p1::f1(i); | ||
end | ||
|
||
endfunction | ||
|
||
localparam p = f2(1); | ||
|
||
initial begin | ||
$display(p); | ||
if (p === 2) | ||
$display("PASSED"); | ||
else | ||
$display("FAILED"); | ||
end | ||
|
||
endmodule |
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,36 @@ | ||
// Check that a constant function call is permitted when the function is | ||
// provided by a package. | ||
|
||
module m1; | ||
|
||
function integer f1(input integer i); | ||
|
||
begin | ||
f1 = i + 1; | ||
end | ||
|
||
endfunction | ||
|
||
endmodule | ||
|
||
module test; | ||
|
||
function integer f2(input integer i); | ||
|
||
begin | ||
f2 = m1.f1(i); | ||
end | ||
|
||
endfunction | ||
|
||
localparam p = f2(1); | ||
|
||
initial begin | ||
$display(p); | ||
if (p === 2) | ||
$display("PASSED"); | ||
else | ||
$display("FAILED"); | ||
end | ||
|
||
endmodule |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"type" : "normal", | ||
"source" : "constfunccall1.v" | ||
} |
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,5 @@ | ||
{ | ||
"type" : "normal", | ||
"source" : "constfunccall2.v", | ||
"iverilog-args" : [ "-g2009" ] | ||
} |
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,5 @@ | ||
{ | ||
"type" : "CE", | ||
"source" : "constfunccall3.v", | ||
"gold" : "constfunccall3" | ||
} |