Set_type_override the sequence to sequence library has no effect

Hi,

I based on the uvm 1.1c version of uvm_sequence_library to create a light weight proj_seqlib, basically, to have a queue of sequence (same type, say proj_seq) defined like this:
uvm_object_wrapper seq_q[$];
Then I added in sequences into this queue with this syntax in the body:
seq_q.push_back(seq_1::get_type());
seq_q.push_back(seq_2::get_type());
After this, I randomly choose one of the sequence queue (using select_rand as pointer) and then cast it back to the proj_seq:
proj_seq seq;
if (!$cast(seq, seq_q[select_rand].create_object())
`uvm_fatal(…)
So that’s my light weight sequence lib.

Now, I have a seq_2a (extends from seq_2, with some constraints overwrites), and I plan to override the existing seq_2.
In the test, in new function or build phase, I set_type_override this sequence:
seq_2::type_id::set_type_override(seq_2a::get_type());

When I run the test by running the proj_seqlib, the seq_2 is not overridden by seq_2a.

May I know why and how to resolve this?

Thanks in advance.

The virtual method uvm_object_wrapper::create_object() is not a factory create; it just creates the object the wrapper type represents.

You need to use the factory’s create_object_by_type()

uvm_factory f = uvm_factory::get();
if (!$cast(seq, f.create_object_by_type( // return type uvm_object
                                        seq_q[select_rand], // type selected to create
                                        get_full_name(),    // path for override if desired
                                        "my_name")           // created object name
    ) ...

In reply to dave_59:

Thanks Dave! It works! :)