I have a uvm testbench that requires two agents. Both agents run the same sequence ( two different sequence instances run on two different sequencers). I created a package for each agent and included the sequence file in both similar to this code.
package agent1_pkg;
...
`include "my_sequence.sv"
...
endpackage
package agent2_pkg;
...
`include "my_sequence.sv"
...
endpackage
The agents packages are included in an env_pkg as well as in the main test_pkg along with the env_pkg.
package env_pkg;
...
import agent1_pkg::*;
import agent2_pkg::*;
...
endpackage
package test_pkg;
...
import agent1_pkg::*;
import agent2_pkg::*;
import env_pkg::*;
`include "my_test.sv"
...
endpackage
The test my_test tries to instantiate my_sequance. when compiling the test_pkg the following error shows up
** at my_test.sv(5): Type Identifier 'my_sequence' is not directly visible.
Found multiple Declaration of 'my_sequence' through wildcard imports from these packages : agent1_pkg, agent2_pkg, agent2_pkg
My explanation is that the package in systemverilog has its own scope and when we import it with ::* we can access it directly without the need of scope resolution. Now that both packages import the same class we can’t access my_sequence directly as it exist in two different scopes and the compiler doesn’t know which one to choose.
I have some questions
1- Is my explanation right?
2- Since env_pkg import the agent_pkg it should already have the scope of the agent_pkg so why do I need to import the agent_pkg again?
3- What are possible solutions to this problem and are their any better ways to do this structure?