Below we have two packages that contain a class called test. In the testbench, pkg1 is imported using a wildcard import while pkg2 is referenced explicitly. My expectation would be that test from pkg1 would run. However we get a UVM warning that ‘test’ is already registered with the factory, and test from pkg2 gets run by Questa. I understand that once we reference something in pkg2 it “exists” but I did not expect its unreferenced class to dominate the scope as it is doing. Are my expectations incorrect, or is this to be expected?
package pkg1;
import uvm_pkg::*;
`include "uvm_macros.svh"
const int value = 1;
class test extends uvm_test;
`uvm_component_utils (test)
function new (string name, uvm_component parent);
super.new (name, parent);
endfunction : new
task run_phase (uvm_phase phase);
phase.raise_objection (this);
$display ("Running test 1.");
phase.drop_objection (this);
endtask
endclass
endpackage
package pkg2;
import uvm_pkg::*;
`include "uvm_macros.svh"
const int value = 2;
class test extends uvm_test;
`uvm_component_utils (test)
function new (string name, uvm_component parent);
super.new (name, parent);
endfunction : new
task run_phase (uvm_phase phase);
phase.raise_objection (this);
$display ("Running test 2.");
phase.drop_objection (this);
endtask
endclass
endpackage
module testbench;
import uvm_pkg::*;
import pkg1::*;
initial
begin
$display ("%d", pkg2::value);
run_test ("test");
end
endmodule