Facebook/LinkedIn login is now deprecated, please disconnect our access to your social profile.
Let us contribute to a cleaner Earth, Go Green Updated: May 31, 2020

The this keyword is used to refer to class properties, parameters and methods of the current instance. It can only be used within non-static methods, constraints and covergroups. this is basically a pre-defined object handle that refers to the object that was used to invoke the method in which this is used.


A very common way of using this is within the initialization block.

class Packet;
  bit [31:0] addr;
  function new (bit [31:0] addr);
//    addr = addr;          //  Which addr should get assigned ?
    this.addr = addr;     //  addr variable in Packet class should be 
                          //  assigned with local variable addr in new()

Unless there is ambiguity in assignment, use of this keyword is not generally needed for specifying access to class members in methods.

You consent to our cookies if you continue to use our website. To know more about cookies, see our privacy policy. I accept cookies from this site.