User guide
24-63
SystemVerilog Testbench Constructs
Accessing Properties
A property of an object can be accessed using the dot operator (.).
The handle name for the object precedes the dot, followed by the
qualifying property name (for example, address, command).
instance_name.property_name
Methods
Tasks or functions, known as “methods,” can be designated as
local, public, or protected. They are public by default.
Accessing Object Methods
An object´s methods can be accessed using the dot operator (.). The
handle for the object precedes the dot, followed by the method.
program access_object_method;
class B;
int q = 3;
function int send (int a);
send = a * 2;
endfunction
task show();
$display("q = %0d", q);
endtask
endclass
initial begin
B b1; //declare handle
b1 = new; // instantiate
b1.show(); //access show() of object b.1
$display("value returned by b1.send() = %0d",
b1.send(4));//access send()of object b.1
end
endprogram