RE: [sv-ec] reference to outer scope name from nested class

From: Mark Hartoog <Mark.Hartoog_at_.....>
Date: Sat Dec 15 2007 - 18:43:19 PST
> The main issues for above are:
>     - how to deal with multi intantation of module sub - 
> there will be multi class declaration each with separate 
> set of static variables? what about parametrized p declaration in each
instance?

Each module instance creates a new class type with its own static
members.
If you want all classes to share the same static values, you need to
define 
the class in a package and import it in each module.

>    - what happen if we use a class from module which is not 
> instantiated in the project? is it possible

You cannot use a class from a module that is not used in the design.
A class defined in a module is only visible in the module and in nested
modules. The module may pass the class to submodules through type
parameters,
but only if it is actually used in the design.

> Should non-static properties and function declared in outer 
> class be visible in inner class? 
> IMHO  in above only the static property 'si'  should be accesible 
> (like i C language) -  this should be clearly pointed out by LRM.
> If we allow reference to 'i' what will be the value if C::i not
exists?
 
I think only the static properties should be visible.
________________________________

From: owner-sv-ec@eda.org [mailto:owner-sv-ec@eda.org] On Behalf Of
danielm
Sent: Friday, December 14, 2007 8:03 AM
To: sv-ec@eda.org
Subject: [sv-ec] reference to outer scope name from nested class


1. Problem with classes declaration  nested in modules
 
module sub;
    reg a;
    parameter P=1;
    class C;
        bit [P:0] p;
        function new ();
            $display("test>>>>>>>>>>>>",a);  //reference to outter scope
variable a;
        endfunction
    endclass
    
    C c=new;
endmodule
 
In the LRM (chapter 7. classses) there is no single example of nesting
classes inside modules/programs/interfaces and resolving issues like
above.
 
The main issues for above are:
    - how to deal with multi intantation of module sub - there will be
multi class declaration each with separate set of static variables? what
about parametrized p declaration in each instance?
    - what happen if we use a class from module which is not
instantiated in the project? is it possible
This should be clearly described in LRM.
 
 
2. Problem with classes declaration nested in classes:
 
 
    class C;
        int i;
        static int si;
        class CC;
                function new();
                    $display(i,,si);
                endfunction
        endclass
    endclass
    
    C:CC cc=new;
 
Should non-static properties and function declared in outer class be
visible in inner class? 
IMHO  in above only the static property 'si'  should be accesible (like
i C language) -  this should be clearly pointed out by LRM.
If we allow reference to 'i' what will be the value if C::i not exists?
 
 
 
Daniel Mlynek

-- 
This message has been scanned for viruses and 
dangerous content by MailScanner <http://www.mailscanner.info/> , and is

believed to be clean. 

-- 
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.
Received on Sat Dec 15 18:43:42 2007

This archive was generated by hypermail 2.1.8 : Sat Dec 15 2007 - 18:43:51 PST