How can i make a common interface

Hello,

i have an agent i created in a package and some verification environment use this agent (instance this agent).

i want to add an interface to this agent - since the environments that use this agent need this interface.

however as i know i can’t put an interface in a package…

what can i do in order to make this interface available to all who use this agent ?

Thanks !

In reply to snognogt:

S SystemVerilog interface is a static construct and not a class. For this reason you cannot put it into a package. It has to be compiled and can be used after it is available in your compiled library.
But it should be part of your agent’s database.
A good approach is to compile this interface together with your package.
This is how it looks like in my Environment:

  package apb_pkg;

    `include "apb.svh"

  endpackage : apb_pkg

  `include "apb_if.sv"

where apb.svh is a file which includes all class-based constructs and apb_if.sv contains the SV interface.

In reply to chr_sue:

In reply to snognogt:
S SystemVerilog interface is a static construct and not a class. For this reason you cannot put it into a package. It has to be compiled and can be used after it is available in your compiled library.
But it should be part of your agent’s database.
A good approach is to compile this interface together with your package.
This is how it looks like in my Environment:

  package apb_pkg;
`include "apb.svh"
endpackage : apb_pkg
`include "apb_if.sv"

where apb.svh is a file which includes all class-based constructs and apb_if.sv contains the SV interface.

Hi

Thanks for the answer.
However, if i want to instance the interface in my driver (that is in the agent, in the pkg) for example - how can i do that ? the agent and driver are in the pkg and the interface is not…

Thanks !

In reply to snognogt:

This is exactly the solution for your Problem. Try-out.

In reply to snognogt:

Modules, interfaces, and packages are known as design units exist in a global namespace. That means once you compile them, they become visible to all. Module and interfaces do not need to be compiled in any specific order — they get bound by instantiation in a later elaboration step.