User guide

24-65
SystemVerilog Testbench Constructs
The following is another, complete, example.
program P;
class Demo;
integer x=4;
function integer send(integer x);
this.x = x*3;
endfunction
task show();
$display("The value of x in the object of
type Demo is = %d", send(this.x));
endtask
endclass
intial begin
integer x=5;
Demo D =new;
D.show();
$display("The value of the global variable x is
%0d", x);
end
endprogram
The output of this program is:
The value of x in the object of type Demo is = 12
The value of the global variable x is =5