Class methods and Constraints can be defined in the following places:
inside a class.
outside a class in the same file.
outside a class in a separate file.
The process of declaring an out of block method involves:
declaring the method prototype or constraint within the class declaration with extern qualifier.
declaring the full method or constraint outside the class body.
The extern qualifier indicates that the body of the method (its implementation) or constraint block is to be found outside the declaration.
NOTE : class scope resolution operator :: should be used while defining.
EXAMPLE:
class B;
extern task printf();
endclass
task B::printf();
$display(" Hi ");
endtask
program main;
initial
begin
B b;
b = new();
b.printf();
end
endprogram
RESULT:
Hi
The process of declaring an out of block method involves:
The extern qualifier indicates that the body of the method (its implementation) or constraint block is to be found outside the declaration.
NOTE : class scope resolution operator :: should be used while defining.
EXAMPLE:
class B;
extern task printf();
endclass
task B::printf();
$display(" Hi ");
endtask
program main;
initial
begin
B b;
b = new();
b.printf();
end
endprogram
RESULT:
Hi
#from testbench.in