this: Reference to the current instance

System verilog has a default reference pointer to its own objects. 

we use the  "this"  syntax to refer to its own objects within the methods

e.g

         class animal;
                 int        age;
                 string   name;
                    function new (int age, string name);
                          this.age        =  age;
                          this.name     =  name;
                 endfunction
           endclass

          module top;
                   animal    a_h;
                  initial begin
                        a_h    = new(7, "lion");
                   end
           endmodule
 
 

 


Comments

Popular posts from this blog

What is Class based Randomization and how do we define ?

How Disable Constraints in SystemVerilog

How do we define Weighted Distribution Constraint in SystemVerilog