I have second question on the same train of thought that Kakoli presented. If a virtual base class contains a virtual method, then when the base class is extended, is the extended child class required to include the virtual method? Or is the virtual method only a prototype if the child class wished to use that method? I assumed that base class virtual methods were required to exist and be defined in extended classes, but that is not the case with all simulators. Is my understanding wrong here?
-----Original Message-----
From: Kakoli Bhattacharya
Sent: Oct 19, 2006 6:07 AM
To: sv-ec@server.eda.org
Subject: [sv-ec] Query related to virtual methods in a class Hello, Consider the following code: virtual class Parent; integer it; int i; virtual task virtual_task(input reg rg); //This is the declaration endtask endclass class Child1 extends Parent; shortint si; longint li; virtual task virtual_task1(input reg rg1); endtask endclass class Child2 extends Child1; real r1; shortreal sr1; time t1; realtime rt1; task virtual_task(input reg rg1); // This is the redefinition it = rg1; i = rg1; si = rg1; li = rg1; endtask enclass My problem concerns the virtual task 'virtual_task'. When it has been declared in the parent class 'Parent' then it takes 'rg' as its argument. During its redefinition in the child class 'Child2' it takes 'rg1' as its argument. Is it necessary that the names of the variables also have to be identical? In LRM (1800-2005) Section 7.19 it is stated that "Virtual methods provide prototypes for subroutines, i.e., all of the information generally found on the first line of a method declaration: the encapsulation criteria, the type and number of arguments, and the return type if it is needed. Later, when subclasses override virtual methods, they must follow the prototype exactly." Prototype however do not mean identical variable name.But later on in the same section it is also stated that "Thus, all versions of the virtual method look identical in all subclasses" So what does the word 'identical' exactly mean overhere? Does it imply identical argument name also? Thanks, Kakoli
========================================================== Don Mills LCDM Engineering (Logic, Coding, & Design Methodology) mills@lcdm-eng.com www.lcdm-eng.com ==========================================================Received on Thu Oct 19 10:22:14 2006
This archive was generated by hypermail 2.1.8 : Thu Oct 19 2006 - 10:22:22 PDT