Here is flow to register a sequence with uvm phase along with proper raise and drop objection mechanism inside sequence which is working and running properly :
Inside Test’s build phase , registering the sequence with particular UVM phase with help of uvm_config_db :
=======================================================================================
virtual function void build_phase(uvm_phase phase);
super.build_phase(phase);
uvm_config_db#(uvm_object_wrapper)::set(this,"my_tb.my_agent.my_seqr.pre_reset_phase","default_sequence",my_powergood_seq::type_id::get());
uvm_config_db#(uvm_object_wrapper)::set(this,"my_tb.my_agent.my_seqr.reset_phase","default_sequence",my_reset_seq::type_id::get());
uvm_config_db#(uvm_object_wrapper)::set(this,"my_tb.my_agent.my_seqr.configure_phase","default_sequence",my_cfg_seq::type_id::get());
uvm_config_db#(uvm_object_wrapper)::set(this,"my_tb.my_agent.my_seqr.main_phase","default_sequence",my_test_seq::type_id::get());
uvm_config_db#(uvm_object_wrapper)::set(this,"my_tb.my_agent.my_seqr.shutdown_phase","default_sequence",my_flush_seq::type_id::get());
Inside Base Sequence’s pre_body() and post_body() tasks for raise and drop objection mechanism :
=======================================================================================
virtual task pre_body();
if (starting_phase!=null) begin
`uvm_info(get_type_name(),
$sformatf("%s pre_body() raising %s objection",
get_sequence_path(),
starting_phase.get_name()), UVM_MEDIUM);
starting_phase.raise_objection(this);
end
endtask
// Drop the objection in the post_body so the objection is removed when
// the root sequence is complete.
virtual task post_body();
if (starting_phase!=null) begin
`uvm_info(get_type_name(),
$sformatf("%s post_body() dropping %s objection",
get_sequence_path(),
starting_phase.get_name()), UVM_MEDIUM);
starting_phase.drop_objection(this);
end
endtask