Arturo, Your replay is a little confusing to me... Arturo Salz wrote: > Don, > > > > ... > > > First you note that "an extended class is not required to override a virtual method > As for your question. An extended class is not required to override > (or re-implement) a virtual method introduced by any of its ancestors. > Then you state that if the parent class is virtual with a virtual method, the exended class must provide an implementation for that virtual method.for the class to be come concrete. > If the parent class is virtual (i.e., abstract) and the virtual method > is undefined then the extended class must provide an implementation > for the virtual method in order for the class to become concrete - and > be able to create objects of that class. If, on the other hand, the > parent class is not virtual and does provide an implementation of the > virtual method then the extended class does not need to override the > virtual method; it will simply inherit the virtual method implemented > by its closest ancestor. Perhaps, if you provide an example we can > identify the exact problem you are seeing. > > > > Arturo > So, as I understand this, implementing virtual methods in extended classes are optional. Of course, if they are implemented, they must follow the prototype declared in the base class. Using (and modifying code from Gord's email) to elaborate module top; virtual class base; virtual task t; endtask // t virtual task t2; $display("in base::t2"); endtask // t2 virtual task t3; $display("in base::t3"); endtask // t3 endclass virtual class mid1 extends base; task t; $display("in mid1::t"); endtask // t endclass class mid2 extends base; task t2; $display("in mid2::t2"); endtask // t2 endclass class mid3 extends base; endclass // mid3 class bot extends mid1; endclass // bot // mid1 m1 = new; mid2 m2 = new; mid3 m3 = new; bot b = new; initial begin // m1.t; // prints: in mid1:t // m1.t2; // prints: in base:t2 $display("entering mid2"); m2.t; m2.t2; m2.t3; $display("leaving mid2"); $display; $display("entering mid3"); m3.t; m3.t2; m3.t3; $display("leavinging mid3"); $display; $display("entering bot"); b.t; b.t2; b.t3; $display("leavinging bot"); end endmodule The results from simulating the code above: # entering mid2 # in mid2::t2 # in base::t3 # leaving mid2 # # entering mid3 # in base::t2 # in base::t3 # leavinging mid3 # # entering bot # in mid1::t # in base::t2 # in base::t3 # leavinging bot My conclusions are, none of the extended classes mid1, mid2, mid3 are required to included and define the virtual task declared in virtual base classes. The reason I am asking all this is due to a sentence in section 7.19: "In general, if an abstract class has any virtual methods, all of the methods must be overridden (and provided with a method body) for the subclass to be instantiated." This implies to me that the virtual methods must be defined in the extended classes. Ummm, that is not what I am seeing from simulation. (Note that I did not make any of the task "pure".) -- ========================================================== Don Mills LCDM Engineering (Logic, Coding, & Design Methodology) mills@lcdm-eng.com www.lcdm-eng.com 801-282-6560 Office PHONE 801-641-5882 Mobile PHONE 4158 W. Ben Armine Cir., South Jordan, UT 84095-9101 ==========================================================Received on Fri Oct 20 07:49:37 2006
This archive was generated by hypermail 2.1.8 : Fri Oct 20 2006 - 07:50:06 PDT