[ovm-2.1] How to override all_dropped callback in ovm_test_done?

My intension is to print some messages after all objections dropped. and the menu said that I can use all_dropped callback. Browsing source code of ovm_objection and I do not think it looks like ovm_callbacks.

Could anyone give me a timely help? thanks!

sorry for replying the thread by myself, hope there could be some hint of how to do it.

First, create a subtype of ovm_test_done_objection:

class my_test_done_objection extends ovm_test_done_objection;
  ...
  virtual task all_dropped(...);
    // put your extended behavior here
  endtask
endclass

Then, you need to replace the ovm_test_done instance with an instance of your subtype before anybody starts to use ovm_test_done. Doing this before calling run_test() should do the trick:

initial begin
  my_test_done_objection my_test_done;
  my_test_done = new;
  ovm_test_done = my_test_done;
  run_test();
end

.

Thanks so much to Adam.

moreover, could you explain me why the factory could not work? I put this in my_ovm_test::build, between super.build() and ovm_env::type_id::create.

set_inst_override_by_type(“ovm_test_done”,
ovm_test_done_objection::get_type(), my_test_done::get_type()
);

or

set_type_override_by_type(
ovm_test_done_objection::get_type(), my_test_done::get_type(), 1
);

That’s because ovm_test_done is initialized before you have a chance to register your override. You could use the factory override mechanism, but then you’d have to re-initialize ovm_test_done:

set_type_override_by_type(ovm_test_done_objection::get_type(), my_test_done::get_type(), 1);  
ovm_test_done = ovm_test_done_objection::type_id::create("ovm_test_done");

Hi Adam,

you are right, it does work. Thanks a lot for the clear explanation.