get virtual interface once in package
<p>I try to write a package which include some common tasks and functions for test environment use.
For example,</p>

<pre><code>package test_misc_pkg;
`include "uvm_macros.svh"
import uvm_pkg::*;

task wait_rest();
  virtual test_if test_vif;
  if (!uvm_config_db #(virtual test_if)::get(null, "uvm_test_top.env", "test_vif", test_vif))
    `uvm_fatal("NOVIF", "virtual interface should be set")

  @(posedge test_vif.clk);
  //do something...
endtask

endpackage : test_misc_pkg
</code></pre>

<p>Then, test env can just call wait_rest() after import test_misc_pkg.</p>

<p>But, if there are other task use same test_vif, I still need to get db in the beginning of every tasks.
My question is, can we just get uvm_config_db once in the package, let all tasks can use test_vif directly?</p>

<p>Or, any better way to do this?</p>

<p>Thanks.</p>