RE: [sv-bc] Does importing a class type or class variable make the elements declared in the class also visible?

From: Logie Ramachandran <Logie.Ramachandran_at_.....>
Date: Thu Nov 24 2005 - 21:07:10 PST
Hi Francoise, 
 
I read your example as importing a class "declaration" from a package.
This should
mean that all members declared in the class become "visible" in the
current scope. 
Therefore newing such a class should be legal. Accessing all class
members should
be legal. 
 
 
Thanks
 
Logie. 
 
 
 

________________________________

From: owner-sv-bc@eda.org [mailto:owner-sv-bc@eda.org] On Behalf Of
Arturo Salz
Sent: Friday, November 18, 2005 2:00 PM
To: francoise martinolle; sv-bc@eda.org
Subject: RE: [sv-bc] Does importing a class type or class variable make
the elements declared in the class also visible?



Francoise,

 

My expectation would be that all class members (properties and methods)
are available in the importing scope. I'm not sure if the term visible
is appropriate here since each variable or method of the class must
still be qualified by an object of that class, either by using the LHS
context for the new operator, or using the dot notation with the proper
handle, or by the class name when using the :: operator.

 

Note that "new" is a reserved keyword so your last example is illegal in
SystemVerilog: new can only be used in the context of a class, a dynamic
array, or a covergoup.

 

            Arturo

 

________________________________

From: owner-sv-bc@eda.org [mailto:owner-sv-bc@eda.org] On Behalf Of
francoise martinolle
Sent: Friday, November 18, 2005 1:25 PM
To: sv-bc@eda.org
Subject: [sv-bc] Does importing a class type or class variable make the
elements declared in the class also visible?

 

Should an import of a class type or class variable declared in a package
make all members, methods and the constructor of that class

visible in the importing scope?

 

ex:

 

package p;

   class A;

       int m1;

       function new (input i);

       endfunction

 

       task t;

       endtask

 

   endclass

endpackage

 

module top;

 

  import p::A;

 

  A cp;

 

// Are the statements in the following initial block legal?

  initial begin

       cp = new;

       cp.t;

       cp.m1 = 1;

  end

 

endmodule

 

 

Is it illegal to redeclare a function new in the module scope while
importing the class A?

 

package p;

   class A;

       int m1;

       function new (input i);

       endfunction

 

       task t;

       endtask

 

   endclass

endpackage

 

module top;

 

  import p::A;

 

   function int new ;   

     return 0;    

   endfunction

 

 

  A cp;

 

  initial begin

       cp = new;

       cp.t;

       cp.m1 = 1;

  end

 

endmodule
Received on Thu Nov 24 21:07:39 2005

This archive was generated by hypermail 2.1.8 : Thu Nov 24 2005 - 21:11:37 PST