Re: [sv-bc] Clarification: import and visibility of imported symbols

From: Greg Jaxon <Greg.Jaxon@synopsys.com>
Date: Fri Jul 23 2004 - 13:30:20 PDT

Here is one opinion on this subject:

Names are not imported until they're used by syntax which refers to the
imported declaration. So the first case does not signal an error. Here, mylogic
appears in a declarative context which does not "need" the prior declaration.
The type global::mylogic might still be imported into this scope.
But the local name "mylogic" is not bound to that type, it is bound to a
logic variable inside module top.

Most parsers have a "soft reference" at the point of declaration
in order to properly detect name collisions. An "importable" meaning
of the name "mylogic" is visible at this point. The import statement must
make the global::* name bindings conditionally visible, i.e. only visible
if the first reference to them is not a re-declaration.
This means that the "soft reference" should ignore the imported name binding,
and allow the local declaration to shadow it.

I don't believe this prevents statements in this scope from using objects
which were declared with the global::mylogic typedef. These could still be
explicitly declared that way, or they might be imported into this scope via
names that have not been shadowed.

The second example is an error, independent of the presence of the
"import global::*" statement. In SV (unlike C), typedef identifiers live
in the same namespace as variable identifiers. Hence "mylogic" cannot appear
in both roles in the same scope

Greg Jaxon

Disclaimer: official SNPS opinion may differ (and sometimes it does).

Francoise Martinolle wrote:
> Should the following examples compile without any error?
> This seeks clarification on when a symbol coming from a import * is
> imported into the scope.
> import * makes symbols potentially visible, the question is when does a
> compiler make them
> visible?
>
>
> package globals;
> typedef logic mylogic;
> endpackage
>
> module top;
> import globals::*;
>
> logic mylogic; // attempt to declare a variable named mylogic of type logic
> // I think that should be allowed as
> globals::mylogic is only imported if used
> // in this particular case, the type is not
> imported as we are trying to declare
> // a variable
> endmodule
>
> What about if have :
> module top;
> import globals::*;
>
> logic mylogic; // attempt to declare a variable named mylogic of type logic
> // now I have declared a symbol mylogic in my scope
> hash table
>
> mylogic var; // attempt to declare a variable var of type mylogic
> // is this legal?
>
> endmodule
>
>
Received on Fri Jul 23 13:30:32 2004

This archive was generated by hypermail 2.1.8 : Fri Jul 23 2004 - 13:30:45 PDT