What is Shallow Object copy in Systemverilog

SystemVerilog allows us to have a Shallow copy for a particular object

  • A New object can be constructed that is a copy of the values/properties of an existing object
For e.g

              class    animal;
                         int       age;
                         string  name;
              endclass

              module test;
                            animal  a_h, b_h;            // Two separate handles
                            initial     begin
                                       a_h           = new (10, "Tiger");  // construct an animal object
                                       b_h           = new a_h;                // construct b_h and copy the values from a_h
                                       b_h.age    = 6; 
                                       $display (a_h.age, b_h.age);     // a_h & b_h refer to two separte objects
                             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