Clone uvm_sequence_item

When use clone function to copy a uvm_sequence_item to another, like:
$cast(item1, item2.clone());

It seems that sequence_id will not be copied. Is it right? What is the reason?
Does clone function will not copy class local variable? Or in uvm_sequence_item class m_sequence_id is not added into copy list?

Thanks
Ben

In reply to Ben:

The question is how do you override the do_copy method. If you do not this correctly certain fields might not be copied.
clone calls copy and to make your own copy you have to override do_copy.

In reply to chr_sue:

m_sequence_id is a internal local variable in base class uvm_sequence_item.
Do user still need to include it in copy function?

Thanks
Ben

In reply to Ben:

Could you please what you are overwriting? Because you cannot override the copy function, but do_copy.
Taking care for the base class members can be achieved by using super.do_copy.

In reply to chr_sue:

Actually no special copy requirment for extend class member variable, so I use field automation macro to add extend class member to copy list. And doesn’t override the do_copy function.

In uvm base class uvm_sequence_item, the sequence_id variable may not be included in copy list. So user meed to copy the id independently even call the copy or clone function before like below. Is it right?

        
void'($cast(rsp, req.clone()));
rsp.set_id_info(req); //need it

Anything wrong pls correct me.

In reply to Ben:

The UVM base classes do not copy any of their members (there might be an exception somewhere, but not in any of the ones involved here). The sequence_id is set by the sequencer upon starting on a sequencer, or by the set_id_info method as you have figured out.

In reply to dave_59:

Hi Dave

Thanks for your reply.
So from your meaning, the member variable in UVM library class is not included in copy list initially. If user want to copy them when call copy or clone function, they must override the do_copy function or add the base class variable member into field automation macro.

Is my understanding right?

Thanks
Ben

In reply to Ben:

Your understanding is correct except I strongly advise against wanting to do this.

In reply to dave_59:

Thanks.
Ok, understood.