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?
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.
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.
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
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.
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.