Class resolution 1
Class resolution 1
modue test;
import my_types::* ; //importing whole package
import my_types::state_e; //importing specific type
initial begin
state_e my_state;
end
endmodule
Extern keyword
• If the definition of the method written outside the body of the class, then the method is called an
external method.
• external task. The definition of the task written outside the class body is referred to as an external
task
• to do this, need to declare the method (Function/Task) with an externkeyword in the class body
along with
• any qualifiers (local, protected or virtual)
• full argument list
• The extern qualifier indicates that the body of the method (its implementation) is to be found
outside the class declaration
• Before the method name, the class name should be specified with a class resolution operator to
specify to which class the method corresponds to.
• Note -: Number of arguments, arguments name and argument type should match between method
declaration and method definition
• syntax -: extern function void disp();
Use from outside the class -:
Function void scope :: disp()
Typedef classes
• A typedefis used to provide a forward declaration of the
class.
In some cases, the class needs to be instantiated before
the class declaration. In these kinds of situations,
the typedef is used to provide a forward declaration of
the class.
• Syntax -:
typedef class class_name;
Example
typedef child;
class parent;
child c;
endclass
class child;
parent p;
endclass
module tb();
parent pa_ha;
child ch_ha;
initial begin
pa_ha = new();
ch_ha = new();
end
endmodule