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


Subject: Re: [sv-bc] import p::*
From: Francoise Martinolle (fm@cadence.com)
Date: Thu Jan 29 2004 - 14:18:41 PST


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: <mailto:fm@cadence.com>Francoise Martinolle
>To: <mailto:sv-bc@eda.org>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 : Thu Jan 29 2004 - 14:25:31 PST