RegisterLogin  
Update Profile
   
You are here: Forum  
Minimize 
SVUG Community Forum
Subject: Access types from within packages
Prev Next
You are not authorized to post a reply.

Author Messages
GHERVASEUser is Offline

Posts:2

11/28/2008 4:14 AM  
    Hello.

Does anyone know if there is a solution for accessing global types from within packages?

For example:

class Test;
endclass

package p;
    class MyTest extends Test;
    endclass
endpackage

I know there are constructs such as "$unit" and "$root" but these can't be used for accessing types.
Thank you very much.
SHALOMUser is Offline

Posts:43

11/30/2008 6:04 AM  
Who said $unit cannot be used for accessing types?

I know there are constructs such as "$unit" and "$root" but these can't be used for accessing types.


Shalom Bresticker
GHERVASEUser is Offline

Posts:2

12/02/2008 2:29 AM  
Hi.

$unit can't be used for accessing types from packages.

class Test;
endclass

package p;
    class MyTest extends $unit::Test;
    endclass
endpackage

I have tried both VCS (from Synopsis) and Questasim.
In VCS, $unit is not implemented, and in questasim I get "unit cannot be used from packages".
SHALOMUser is Offline

Posts:43

12/02/2008 3:19 AM  
The restriction that $unit cannot be accessed from packages was clarified in Mantis 1484 (http://www.eda-stds.org/svdb/view.php?id=1484 (login guest/guest)), and the draft of the new LRM says, "A package shall not refer to items defined in the compilation unit scope."

However, you could declare class Test in another package and then refer to it this way:

package q;
class Test;
endclass
endpackage

package p;
class MyTest extends q::Test;
endclass
endpackage

or this way:

package p;
import q::*;
class MyTest extends Test;
endclass
endpackage

Shalom
SHALOMUser is Offline

Posts:43

12/02/2008 3:20 AM  
However, in the general case, "$unit::" can be used to refer to a type name declared in $unit.

Shalom
You are not authorized to post a reply.
Forums > General Discussion > Main Discussion Area > Access types from within packages



ActiveForums 3.7
  

 Copyright 2008 by SystemVerilog User Group Contact Us    Privacy Statement