uvm set_inst_override for a sequence

2019-09-03 15:17发布

I'm trying to override a sequence by instance. An example code will describe it best:

class my_vir_seq extends base_vir_seq;
    my_seq_c seq1, seq2;

    `uvm_object_utils_begin(my_vir_seq)
      `uvm_field_object(seq1,  UVM_ALL_ON)
      `uvm_field_object(seq2,  UVM_ALL_ON)
    `uvm_object_utils_end

    `uvm_declare_p_sequencer(v_seqr)

    function new(string name = "my_vir_seq");
      super.new(name); 
    endfunction // new 

    virtual task body();
        `uvm_do_on(seq1, p_sequencer.my_seqr)
        `uvm_do_on(seq2, p_sequencer.my_seqr)
    endtask // body
endclass

class my_err_vir_seq extends my_vir_seq;
    my_err_seq_c seq3;

    `uvm_object_utils_begin(my_err_vir_seq)
       `uvm_field_object(seq3,  UVM_ALL_ON)
    `uvm_object_utils_end

    `uvm_declare_p_sequencer(v_seqr)

    function new(string name = "my_err_vir_seq");
      super.new(name); 
      my_seq_c::type_id::set_inst_override(my_err_seq_c::get_type(), "sve.v_seqr.my_err_vir_seq.seq2" );
    endfunction // new 
endclass

My aim is to only override seq2 with seq3 (its type extends seq2's type). I don't get any errors, but the original sequence runs, What am I doing wrong?

Thanks in advance,

Izhar

1条回答
何必那么认真
2楼-- · 2019-09-03 15:25

Doing type overrides by instance is (I think) conceptually intended for instances of classes that derive from uvm_component, because they have a specific hierarchical path.

There is a trick to do it for sequences as well, using the sequencer's path as an argument to set_inst_override(...) (kind of what you tried). You need to do a few changes to your sequence to support this, though. When creating seq1 and seq2 you have to give them a context (shown only for seq2) so that the factory can find them:

// get_full_name() is the third argument
// - the second argument is empty, it's not a typo
seq2 = my_seq_c::type_id::create("seq2", , get_full_name());

After you created your sequence, you can start it using start(...):

seq2.start(p_sequencer.my_seqr, this);

The idea is from a DVCon 2013 paper that you can find here: DVCon 2013 paper

查看更多
登录 后发表回答