UVM Instance override is not happening

Hi,
Anyone, please clarify my below issue. It looks very long because I have explained my issue in a very descriptive manner.
Attaching eda link of my example for refernce. MY_SMALL_UVM_TB

At the end of this post i have attached heirarchy of my TB.

I am trying to override my Parent_transaction with child_transaction. This is working with set_type_override_by_type and replacing parent_transaction with child_trans throughout testbench.


function void uvm_fifo_test::build_phase(uvm_phase phase);
        uvm_factory factory = uvm_factory::get();
        super.build_phase(phase);
        set_type_override_by_type(uvm_fifo_transaction::get_type(),child_fifo_transaction::get_type());   //overriding throught testbench        
        fifo_cfg = uvm_fifo_cfg :: type_id::create("fifo_cfg");
        fifo_env = uvm_fifo_env::type_id::create("fifo_env",this);
        uvm_config_db#(uvm_fifo_cfg)::set(this,"fifo_env.*","cfg",fifo_cfg);
        factory.print();
         
      endfunction

Result before overriding with child transaction.

Name                           Type                     Size  Value                                           
-----------------------------------------------------------------------------------------------------------
trans1                      **uvm_fifo_transaction**  -     @814                                            
  write_en                     integral                 1     'h1                                             
  read_en                      integral                 1     'h1                                             
  wdata                        integral                 16    'h1e6                                           
  rdata                        integral                 16    'h6939                                          
  begin_time                   time                     64    0                                               
  depth                        int                      32    'd2                                             
  parent sequence (name)       string                   8     fifo_seq                                        
  parent sequence (full name)  string                   48    uvm_test_top.fifo_env.fifo_agt.fifo_sqr.fifo_seq
  sequencer                    string                   39    uvm_test_top.fifo_env.fifo_agt.fifo_sqr         
-----------------------------------------------------------------------------------------------------------

The result after overriding parent_trans with child_trans.

Name                           Type                    Size  Value                                           
-------------------------------------------------------------------------------------------------------------
trans1                  **child_fifo_transaction**  -     @814                                            
  write_en                     integral                1     'h1                                             
  read_en                      integral                1     'h0                                             
  wdata                        integral                16    'h15                                            
  rdata                        integral                16    'hb96                                           
  begin_time                   time                    64    0                                               
  depth                        int                     32    'd2                                             
  parent sequence (name)       string                  8     fifo_seq                                        
  parent sequence (full name)  string                  48    uvm_test_top.fifo_env.fifo_agt.fifo_sqr.fifo_seq
  sequencer                    string                  39    uvm_test_top.fifo_env.fifo_agt.fifo_sqr         
-------------------------------------------------------------------------------------------------------------

But when i tried to make an instance overriding for only particular one agent component using set_inst_override_by_type. Parent_trans is not getting overriden with child_trans.


function void uvm_fifo_test::build_phase(uvm_phase phase);
        uvm_factory factory = uvm_factory::get();
        super.build_phase(phase);
        set_inst_override_by_type("uvm_test_top.fifo_env.fifo_agt1.*",uvm_fifo_transaction::get_type(),child_fifo_transaction::get_type());         
        fifo_cfg = uvm_fifo_cfg :: type_id::create("fifo_cfg");
        fifo_env = uvm_fifo_env::type_id::create("fifo_env",this);
        uvm_config_db#(uvm_fifo_cfg)::set(this,"fifo_env.*","cfg",fifo_cfg);
        factory.print();
         
      endfunction

Result before overriding with child transaction.

Name                           Type                     Size  Value                                           
-----------------------------------------------------------------------------------------------------------
trans1                      **uvm_fifo_transaction**  -     @814                                            
  write_en                     integral                 1     'h1                                             
  read_en                      integral                 1     'h1                                             
  wdata                        integral                 16    'h1e6                                           
  rdata                        integral                 16    'h6939                                          
  begin_time                   time                     64    0                                               
  depth                        int                      32    'd2                                             
  parent sequence (name)       string                   8     fifo_seq                                        
  parent sequence (full name)  string                   48    uvm_test_top.fifo_env.fifo_agt.fifo_sqr.fifo_seq
  sequencer                    string                   39    uvm_test_top.fifo_env.fifo_agt.fifo_sqr         
-----------------------------------------------------------------------------------------------------------

Result after instance overriding.

Name                           Type                     Size  Value                                           
-----------------------------------------------------------------------------------------------------------
trans1                      **uvm_fifo_transaction**  -     @814                                            
  write_en                     integral                 1     'h1                                             
  read_en                      integral                 1     'h1                                             
  wdata                        integral                 16    'h1e6                                           
  rdata                        integral                 16    'h6939                                          
  begin_time                   time                     64    0                                               
  depth                        int                      32    'd2                                             
  parent sequence (name)       string                   8     fifo_seq                                        
  parent sequence (full name)  string                   48    uvm_test_top.fifo_env.fifo_agt.fifo_sqr.fifo_seq
  sequencer                    string                   39    uvm_test_top.fifo_env.fifo_agt.fifo_sqr         
-----------------------------------------------------------------------------------------------------------

My TB heirarchy.

--------------------------------------------------------------
Name                       Type                    Size  Value
--------------------------------------------------------------
uvm_test_top               uvm_fifo_test           -     @342 
  fifo_env                 uvm_fifo_env            -     @358 
    fifo_agt               uvm_fifo_agent          -     @375 
      fifo_drvr            uvm_fifo_driver         -     @538 
        rsp_port           uvm_analysis_port       -     @557 
        seq_item_port      uvm_seq_item_pull_port  -     @547 
      fifo_mon             uvm_fifo_monitor        -     @569 
      fifo_sqr             uvm_fifo_sequencer      -     @399 
        rsp_export         uvm_analysis_export     -     @408 
        seq_item_export    uvm_seq_item_pull_imp   -     @526 
        arbitration_queue  array                   0     -    
        lock_queue         array                   0     -    
        num_last_reqs      integral                32    'd1  
        num_last_rsps      integral                32    'd1  
    fifo_agt1              uvm_fifo_agent          -     @386 
      fifo_drvr            uvm_fifo_driver         -     @730 
        rsp_port           uvm_analysis_port       -     @749 
        seq_item_port      uvm_seq_item_pull_port  -     @739 
      fifo_mon             uvm_fifo_monitor        -     @761 
      fifo_sqr             uvm_fifo_sequencer      -     @591 
        rsp_export         uvm_analysis_export     -     @600 
        seq_item_export    uvm_seq_item_pull_imp   -     @718 
        arbitration_queue  array                   0     -    
        lock_queue         array                   0     -    
        num_last_reqs      integral                32    'd1  
        num_last_rsps      integral                32    'd1  
--------------------------------------------------------------

In reply to Yash_wanth12345:

You can’t override sequence_items being generated by a sequence using an instance override. This is because the sequence_items don’t exist at any specific level of the hierarchy. You can only use the type override as you have done.

It’s recommended to create a new sequence using the new sequence_item and override the sequence if needed.

EDIT: You can use the contxt argument of the create() function to use the hierarchy of the sequencer. See my below comment.

In reply to Yash_wanth12345:

There are 2 Issues with your code ::

[ 1 ] The 1st string Argument to set_inst_overide_by_type is “relative_inst_path” . . You have passed Absolute Path !! ( Error 1 )

[ 2 ] The hierarchy of agent in 1st argument is Incorrect .

You start sequence on fifo_agt whereas in the string argument you have written fifo_agt1 ( Error 2 )

Change to the following in build_phase() of test ::


set_inst_override_by_type("fifo_env.fifo_agt.*",uvm_fifo_transaction::get_type(),child_fifo_transaction::get_type());

You would observe child_fifo_transaction being created by Factory !!

In reply to cgales:

I believe that’s incorrect .
There are papers explaining the same ( instance override ) for objects ( sequences / sequence_items ) .

Here’s a link from our forum :: LINK

In reply to ABD_91:

You are correct. You can add the extra arguments to the create() call to use the m_sequencer hierarchy for context. This will allow you to override using set_inst_override_by_type().


trans1 = uvm_fifo_transaction::type_id::create("trans1", null, m_sequencer.get_full_name());

Hi cgales and ABD_91,

Thank you very much both of you it is working.