Files
iverilog/ivtest/ivltests/sv_ps_method2.v
T
Lars-Peter Clausen 535c09db62 Add regression test for package scoped method call
Check that it is possible to call a method on a package scoped identifier.
Both for built-in types as well as class objects.

Signed-off-by: Lars-Peter Clausen <[email protected]>
2023-01-08 07:59:20 -08:00

41 lines
735 B
Verilog

// Check that it is possible to perform method call on a package scoped
// identifier of a class object.
package P;
class C;
function int f1(int x);
return x + 1;
endfunction
function int f2();
return 10;
endfunction
endclass
C c = new;
endpackage
module test;
bit failed = 1'b0;
`define check(expr, val) \
if (val !== expr) begin \
$display("FAILED(%0d). `%s` got %b, expected %b.", `__LINE__, `"expr`", expr, val); \
failed = 1'b1; \
end
initial begin
`check(P::c.f1(10), 11)
`check(P::c.f2(), 10)
`check($bits(P::c.f1(10)), $bits(int))
`check($bits(P::c.f2()), $bits(int))
if (!failed) begin
$display("PASSED");
end
end
endmodule