Scope Resolution Operator ::
The class scope operator :: is used to specify an identifier defined within the scope of a class.
- Classes and other scopes can have the same identifiers
- The scope resolution operator uniquely identifies a member of a particular class
Class Resolution operator allows access to static members (class properties and methods) from outside the class, as well as access to public or protected elements of super classes from within the derived classes.
Scope resolution operator example
In the Below example,
A static member of the class is accessed outside the class by using class resolution operator ::
//class class packet; bit [31:0] addr; static bit [31:0] id; function display(bit [31:0] a,b); $display("Values are %0d %0d",a,b); endfunction endclass module sro_class; int id=10; initial begin packet p; p = new(); packet::id = 20; p.display(packet::id,id); end endmodule
Values are 20 10