Accessing task/function via modport when function/tasks are imported in interface using package import

Hi,

I am a bit confused with the subroutine access via interface. Here i am mentioning the scenario.

Is it possible to access function “f” declared in package “p”, inside module “test” using interface instance “i1”?

package p;
   function f(input x);
      return ~x;
   endfunction
endpackage

interface intf;
   import p::*;
   modport mp(import f);
endinterface

module test(input d, output q);
   intf i1();
   assign q = i1.f(d);
endmodule

Your question has nothing to do with interfaces, and your example could have easily replaced the interface with a module.

Importing a symbol from a package only makes the symbol visible to the to the scope that imported the symbol. The LRM is very explicit about this.

The effect of importing an identifier into a scope makes that identifier visible without requiring access using
the scope resolution operator. Importing does not copy the declaration of that identifier into the importing
scope. The imported identifier shall not be visible outside that importing scope by hierarchical reference into
that scope or by interface port reference into that scope.

You need to explain the desired effect you are trying to achieve.

Thanks,

Do we have something like “package export” in case of interface too.

In case of packages, SV provides a method to make declarations imported from package P1, a part of package P2 “Exporting imported names from packages”.
++++++++++++++++++++++++++
package p1;
int x, y;
endpackage
package p2;
import p1::x;
export p1::*; // exports p1::x as the name “x”;
// p1::x and p2::x are the same declaration
Endpackage
++++++++++++++++++++++++++
Do we have similar thing in case of importing package in interface/module.

I want to access function/tasks via interface and without changing my interface code wanna add a new function. Package provides me the flexibility of adding a new function & importing that package in interface. But in this case i can’t access the package function outside interface.

Regards,
SG