SystemVerilog Scope Resolution Operator ::

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 packet;
         bit [31:0] addr;
  static bit [31:0] id;

  function display(bit [31:0] a,b);
    $display("Values are %0d %0d",a,b);

module sro_class;
  int id=10;
  initial begin
    packet p;
    p = new();
    packet::id = 20;

Simulator Output

Values are 20 10

Click to execute on

❮ Previous Next ❯