quick.gif

space2.gif

space2.gif

space2.gif

space2.gif

space2.gif

space2.gif

space2.gif

   

space.gif

   

space.gif

  ../images/main/bulllet_4dots_orange.gif super

The super keyword is used from within a derived class to refer to properties of the parent class. It is necessary to use super when the property of the derived class has been overridden, and cannot be accessed directly.

   

space.gif

   

space.gif

  ../images/main/bullet_star_pink.gif Example - super
   

space.gif


  1 program class_super;
  2 
  3   class A ;
  4     integer j;
  5     function new();
  6       begin
  7         j = 10;
  8       end
  9     endfunction
 10     task print();
 11       begin
 12         $display("j is %0d",j);
 13       end
 14     endtask
 15   endclass
 16 
 17   class B extends A;
 18     integer i = 1;
 19     function new();
 20       begin
 21         // call the parent new
 22         super.new(); // constructor chaining
 23         $display("Done calling the parent new");
 24         i = 100;
 25       end
 26     endfunction
 27     // Override the parent class print
 28     task print();
 29       begin
 30         $display("i is %0d",i);
 31         $display("Call the parent print");
 32         super.print();
 33       end
 34     endtask
 35   endclass
 36   
 37   initial begin
 38     B b1;
 39     b1 = new;
 40     b1.print();
 41   end
 42 
 43 endprogram
You could download file class_super.sv here
   

space.gif

  ../images/main/bullet_star_pink.gif Simulation - super
   

space.gif

 Done calling the parent new
 i is 100
 Call the parent print
 j is 10
   

space.gif

   

space.gif

   

space.gif

   

space.gif

space2.gif

space2.gif

space2.gif

space2.gif

space2.gif

  

Copyright © 1998-2014

Deepak Kumar Tala - All rights reserved

Do you have any Comment? mail me at:deepak@asic-world.com