User guide
24-42
SystemVerilog Testbench Constructs
send = a * 2;
endfunction
task show();
$display("q = %0d", q);
endtask
endclass
initial begin
B b1; //declare handle, b1
b1 = new; //create an object by calling new
end
endprogram
The above two steps can be merged into one for instantiating a class
at the time of declaration:
class_name handle_name = new();
For example:
B b1 = new;
The new() method of the class is a method which is part of every
class. It has a default implementation which simply allocates memory
for the object and returns a handle to the object.
Constructors
You can declare your own new() method. In such a case, the
prototype that you must follow is:
function new([arguments]);
// body of method
endfunction
Use this syntax when using the user-defined constructor: