Daniel, The calls to t() are actually this::t(), so it makes sense that you always get the extended function. Even when you call the constructor for class A, the handle is of type B, so this::t() expands into B::t(). Here is a more complete example: class A; virtual function t; $display("base class A"); endfunction function new; $display("In %m"); t(); // This should call A::t or B::t because t() is virtual f(); endfunction function f(); $display("In %m"); t(); // This should call A::t or B::t because t() is virtual endfunction endclass class B extends A; virtual function t; $display("Extended class B"); endfunction function f(); $display("In %m"); t(); // this should call B::t bacause t is virtual endfunction endclass module top; initial begin A a; B b; $display("\nConstructing A"); a = new; $display("\nCalling a.f()"); a.f(); $display("\nCalling a.t()"); a.t(); $display("\nConstructing B"); b = new; $display("\nCalling b.f()"); b.f(); $display("\nCalling b.t()"); b.t(); end endmodule /********************************************************* Chris Spear Verification Specialist Synopsys, Inc. Phone 508-263-8114 .. __@ 377 Simarano Drive Fax 508-263-8123 _`\<,_ Marlboro, MA 01752 USA Cell 508-254-7223 .. (*)/ (*) Spear_ f rom _Synopsys.com http://Chris.Spear.net/systemverilog Just released: new edition of "SystemVerilog for Verification" *********************************************************/ -- This message has been scanned for viruses and dangerous content by MailScanner, and is believed to be clean.Received on Wed Jun 25 06:09:42 2008
This archive was generated by hypermail 2.1.8 : Wed Jun 25 2008 - 06:10:10 PDT