Overriding classes originating from different packages

In reply to dave_59:

I am doing the override in my build_phase of my uvm_test so it would look something like…:

UVM TEST


package my_test_pkg;
  import uvm_pkg::*;
  import class_inside_pkg::*;          // This is where class class_to_override exists
  import override_class_inside_pkg::*; // This is where class new_class exists

  class my_test extends uvm_test;
     ...

  function void build_phase(uvm_phase phase);
    super.build_phase(phase);
    // Suggested solution
    class_to_override#()::type_id::set_type_override( new_class#()::get_type(), 1 ); 
    ...
  endfunction : build_phase

endpackage

class_inside_pkg


class class_to_override #(type T = apples, type VI = some_if) extend uvm_monitor;
  ...
  virtual function void my_function_called_by_run_phase(void);
    // It does more functionalities but this is how I tell it's still being called
    `uvm_info("asdf", "hi", UVM_LOW)

override_class_inside_pkg


class new_class #(type T = apples, type VI = some_if) extend class_to_override;
  ...
  virtual function void my_function_called_by_run_phase(void);
    `uvm_info("asdf", "bye", UVM_LOW)

As an extra… if it matters, my testbench looks like this:


module my_tb;
  import uvm_pkg::*;
  import my_test_pkg::*;
  import class_inside_pkg::*;
  import override_class_inside_pkg::*; // EDIT: I actual do import this

  ...
  initial begin
    ...
    run_test();
  end
endmodule

Hopefully that is more clear

EDIT: and yes, I am making sure my_test is being ran and not some other test