RE: [sv-bc] import p::*


Subject: RE: [sv-bc] import p::*
From: David W. Smith (dwsmith@synopsys.com)
Date: Fri Jan 30 2004 - 13:02:31 PST


Hi Francoise,

Someone suggested that part of the concern was with what causes a declaration to come into existence. My understanding is the
following.

 

A hierarchical reference does NOT bring anything into existence. The hierarchical reference is only valid if the identifier was
already brought into existing in the scope to which the reference is made. If c is used within top and its definition comes from
package p then top.c is a legal hierarchical reference. If c is in package p and package p is imported into top but there is no use
of c in top then top.c is illegal.

 

This is my understanding from reading the text.

 

Regards

David

 

-----Original Message-----
From: Francoise Martinolle [mailto:fm@cadence.com]
Sent: Friday, January 30, 2004 6:52 AM
To: David.Smith@Synopsys.COM; 'Arturo Salz'; sv-bc@eda.org
Subject: RE: [sv-bc] import p::*

 

David,

The original intent is clear to me; it is even better now that Stu will change the wording.

If the following statement:
 Hierarchical references to imported identifiers are allowed as if they were defined in the importing scope.

means that if I have imported the declaration c from package p in the module top, I can refer to "c"as top.c and it would be the
same as p::c??

I really don't think we want to allow this.
I think that hierarchical references to declarations imported from packages should be using
the package name. p::c is a hierarchical reference.

Francoise
       '

At 02:29 PM 1/29/2004 -0800, David W. Smith wrote:

The intent in all of our discussions on the final proposal was that for all intents and purposes the name did not exist unless it
was used. Therefore it could not be referenced. The variable only is declared if it is actually imported from the package. It is
only imported from the package if it is visible and if it is used. If it is not used there is no declaration in the scope. The
question of import is defined in:

 

Hierarchical references to imported identifiers are allowed as if they were defined in the importing scope.

 

There is no way to make a hierarchical reference to an identifier in a package. At least I do not remember this ever being
suggested. Since modules and packages are in different name spaces I really hope that no one tries to create such a thing or we will
have a conflict.

 

Regards

David

 

 

-----Original Message-----
From: owner-sv-bc@eda.org [mailto:owner-sv-bc@eda.org] On Behalf Of Francoise Martinolle
Sent: Thursday, January 29, 2004 2:19 PM
To: Arturo Salz; sv-bc@eda.org
Subject: Re: [sv-bc] import p::*

 

In fact I think that someone could tell the difference of behaviour of the wildcard import in the following cases:
 1) If we can refer to the imported items by hierarchical names relative to the importing module (I don't know if you can,
clarification is expected in SV LRM, I think that the pakcages imported items can only have hierarchical package scoped names)

Then suppose one of the sub-instances of the importing module has a hierarchical name reference to a declared item in package p,
if the effect of the wildcard import is that only referenced items are imported, then the hierarchical reference top.c is undefined;
if the effect of the wildcard import is that all items are imported regardless of their use, then top.c is defined.
ex:
package p
reg c = 0;
endpackage

import p::*;
module top
 bot u1();
endmodule

module bot;
reg r = top.c; // where c is being imported through package p and is now a declaration inside module top
endmodule

2) a $dumpvars is supposed to dump all the variables in the module, I assume that this would also apply to imported items.
import p::*
module top
initial
$dumpvars(top);
endmodule

3) there is a non standard VXL rule for function look up which NC supports; the behaviour of the wildcard import would have some
implication on the resolution of the function declaration.
VXL allows to have simple reference to function in lower instances when the function is declared in a higher level module containing
this instance.
Depending on the behaviour of import p::*, you would either get p::f function or top.f function
in the following example.

package p
function f (input i);
begin
  $display("package p");
   f =1;
end
endfunction
endpackage

module top
function f(input i)
begin
  $display ("top.f");
 f = 0;
end
endfunction

 mid m1 ();
endmodule

import p::*;
module mid;
 bot b1();
endmodule

module bot
reg r;
initial
  r = f(); // which f is referenced?
endmodule

At 11:28 AM 1/29/2004 -0800, Arturo Salz wrote:

Francoise,
 
The interpretation of the person in your group is not semantically incorrect. This is kind of Heisenberg's uncertainty principle. If
everything in the package is imported (except for those identifiers explicitly imported or declared) then a simple reference to any
identifier from the package will work (i.e., the identifier is imported). If, however, an identifier is not referenced in the
importing scope then it is irrelevant whether the identifier is actually imported or not. Basically, the effect of an identifier not
being imported is not visible.
I do agree with you that the original intent may be better captured by the following change:
 
A wildcard import makes each identifier within the package a candidate for import. Each such identifier is imported only when it is
referenced in the importing scope and it is neither declared nor explicitly imported into the scope. Similarly, a wildcard import of
an identifier is overridden by a subsequent declaration of the same identifier in the same scope.
    Arturo
 
----- Original Message -----
From: Francoise Martinolle <mailto:fm@cadence.com>
To: sv-bc@eda.org
Sent: Thursday, January 29, 2004 9:27 AM
Subject: [sv-bc] import p::*

The LRM is not clear on the semantics of the p::*.
Somebody from my group read the LRM and from his reading he implied that the p::*
will import everything in the package except if there is already a explicit declaration
of the same name.
The LRM extract is:
Copyright 2003 Accellera. All rights reserved.269
A wildcard import makes each identifier within the package a candidate for import. Each such identifier is imported only when it is
neither declared nor explicitly imported into the scope. Similarly, a wildcard import of an identifier is overridden by a subsequent
declaration of the same identifier in the same scope.

I though that the interpretation (also suggested by the example below the table where it is said that it "forces the import") was
that the package declaration items are candidate for import,
and are only imported if there is a simple reference to that declaration item. This was my understanding of what was intended.

for example:
import p::*;
module top;
// nothing from package p is imported
endmodule

import p::*
module top;
reg r = p::c; // nothing from package p is imported, p::c is a hierarchical reference
endmodule

import p::*;
module top
reg r = c; // c and only c from package p is imported.
endmodule

can you please let me know which interpretation is correct and fix the wording if necessary.



This archive was generated by hypermail 2b28 : Fri Jan 30 2004 - 13:13:10 PST