[sv-ec] Cliff's 1308 email No-vote - See attached example

From: Clifford E. Cummings <cliffc_at_.....>
Date: Tue Mar 28 2006 - 13:16:35 PST
Cliff votes NO on the 1308 proposal as is. Friendly(?) amendments 
pending (to be proposed by Cliff)

Reason - not yet clear enough. I will propose additional 
clarifications to Dave's greatly-improved-wording after I understand 
the following example. In the following example, there are two levels 
of extension and an interesting mixture of virtual and non-virtual 
methods. Please examine the (untested) example (shown below and 
attached) and let me know if my reasoning is correct or not. The 
output lines with ??? are where I am most unsure.

Regards - Cliff

module virtualmenthods;
   //-------------------------------------------------------------
   class BasePacket;
     int A = 1;
     int B = 2;
     int C = 3;

     function void printA;
       $display("BasePacket::A is %d",A);
     endfunction : printA

     virtual function void printB;
       $display("BasePacket::B is %d",B);
     endfunction : printB

     virtual function void printC;
       $display("BasePacket::C is %d",C);
     endfunction : printC
   endclass : BasePacket
   //-------------------------------------------------------------
   class MyPacket1 extends BasePacket;
     int A = 4;
     int B = 5;
     int C = 6;

     function void printA;
       $display("MyPacket1::A  is %d",A);
     endfunction : printA

     function void printB;
       $display("MyPacket1::B  is %d",B);
     endfunction : printB

     virtual function void printC;
       $display("MyPacket1::C  is %d",C);
     endfunction : printC
   endclass : MyPacket1
   //-------------------------------------------------------------
   class ExtPacket extends MyPacket1;
     int A = 7;
     int B = 8;
     int C = 9;

     function void printA;
       $display("ExtPacket::A  is %d",A);
     endfunction : printA

     virtual function void printB;
       $display("ExtPacket::B  is %d",B);
     endfunction : printB

     // No printC function in ExtPacket
     // Inherit printC from MyPacket1
   endclass : ExtPacket
   //-------------------------------------------------------------

   BasePacket P1 = new;
   MyPacket1  P2 = new;
   ExtPacket  P3 = new;

   initial begin
     P1.printA; // displays 'BasePacket::A is 1'
     P1.printB; // displays 'BasePacket::B is 2'
     P1.printC; // displays 'BasePacket::C is 3'
     //-----------------------------------------------------------
     P1 = P2; // P1 has a handle to a MyPacket1 object

     P1.printA; // displays 'BasePacket::A is 1'
     P1.printB; // displays 'MyPacket1::B  is 5' - latest derived method
     P1.printC; // displays 'MyPacket1::C  is 6' - latest derived method

     P2.printA; // displays 'MyPacket1::A  is 4'
     P2.printB; // displays 'MyPacket1::B  is 5'
     P2.printC; // displays 'MyPacket1::C  is 6'
     //-----------------------------------------------------------
     P1 = P3; // P1 has a handle to an ExtPacket object
     P2 = P3; // P2 has a handle to an ExtPacket object

     P1.printA; // displays 'BasePacket::A is 1'
     P1.printB; // displays 'ExtPacket::B  is 8' - ???
     P1.printC; // displays 'MyPacket1::C  is 9' - ???

     P2.printA; // displays 'MyPacket1::A  is 4'
     P2.printB; // displays 'ExtPacket::B  is 8' - ??? (virtual again???)
     P2.printC; // displays 'MyPacket1::C  is 9' - ??? (9???)

     P3.printA; // displays 'ExtPacket::A  is 7'
     P3.printB; // displays 'ExtPacket::B  is 8'
     P3.printC; // displays 'MyPacket1::C  is 9' - ??? (9???)
     //-----------------------------------------------------------
   end
endmodule



----------------------------------------------------
Cliff Cummings - Sunburst Design, Inc.
14314 SW Allen Blvd., PMB 501, Beaverton, OR 97005
Phone: 503-641-8446 / FAX: 503-641-8486
cliffc@sunburst-design.com / www.sunburst-design.com
Expert Verilog, SystemVerilog, Synthesis and Verification Training


Received on Tue Mar 28 13:16:39 2006

This archive was generated by hypermail 2.1.8 : Tue Mar 28 2006 - 13:16:43 PST