Welcome ! This website will help YOU (recent graduates/professionals) learn verification languages like SystemVerilog and UVM. Register for free and access more content !

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.

Was this article helpful ?

We use cookies to personalize content and ads, to provide social media features and to analyze our traffic. You consent to our cookies if you continue to use our website. To find out more about the cookies we use and how to delete them, see our privacy policy.

  I accept cookies from this site.
EU Cookie Directive plugin by www.channeldigital.co.uk