Hi
In the following block of code:
// Somewhere in a driver - request and response items
bus_seq_item req_item;
bus_seq_item rsp_item;
task run_phase( uvm_phase phase );
forever begin
seq_item_port.get(req_item);
assert($cast(rsp_item, req_item.clone()); // This does not copy the id info
rsp_item.set_id_info(req_item); // This sets the rsp_item id to the req_item id
//
// Do the pin level transaction, populate the response fields
//
// Return the response:
seq_item_port.put(rsp_item);
//
end
endtask: run
I understand that we need to clone the response so that successive responses point to different objects. But why are we casting a clone of req_item into the rsp_item? What does req_item have to do with the response, apart from the id which is handled separately using set_id_info?
From what I understand, we could replace the above code with the following.
// Somewhere in a driver - request and response items
bus_seq_item req_item;
bus_seq_item rsp_item;
task run_phase( uvm_phase phase );
forever begin
seq_item_port.get(req_item);
//assert($cast(rsp_item, req_item.clone()); // This does not copy the id info
rsp_item.set_id_info(req_item); // This sets the rsp_item id to the req_item id
//
// Do the pin level transaction, populate the response fields
//
// Return the response:
seq_item_port.put(rsp_item.clone());
//
end
endtask: run
Please enlighten me about what is actually missed in the second piece of code.
Thank you