Why is the get_response function tied to the caller sequence type and not to the sequencer? It would be so easy to do:
//inside of sequence1 of type sequencer1 it would be good to use:
rsp = p_sequencer.sequencer2.get_response(rsp)
But that doesn’t work, as already said before.
In other words, why do we have in UVM the following code?:
virtual function void put_response(uvm_sequence_item response_item);
RSP response;
if (!$cast(response, response_item)) begin
uvm_report_fatal("PUTRSP", "Failure to cast response in put_response", UVM_NONE);
end
put_base_response(response_item);
endfunction
RSP type “response” depends on the current sequence type where the response method is called/inserted. That usually yields to cast errors when you want a response of a type which is not the type of the current sequence. This usually happens on sequences that call two different protocol types (one is used as default type for the RSP and the sequence and the other is not connected to the RSP).
Why is not possible to force and tell to the “put_response” function above the RSP (sequence item) type (so it is selected)? We can pass “TYPE objects” by argument in systemverilog.
As we have seen, a sequence that uses two different protocols must decide which protocols is used for the default response.
Of course, we can have a workaround with the solution proposed by yhchou creating explicitly a sequence of the same “get_response” type we want (the second protocol) and then assigning the response to the first sequence.
`uvm_do_on(seq,p_sequencer.second_sequencer);//seq is the sequence class with uses the correct type that performs the read/write action
result = seq.rs; //result has the type of the second_sequencer protocol
But, my question is why is this implemented like that from the methodology point of view? Why force the user to do this?
By the way, a good info about how to pass variables between sequences can be found:
https://verificationacademy.com/cookbook/sequences/generation
There is another and similar way to do this is by calling not the “get_response” method internally (of the new sequence seq) from the first sequence (which has a different “not compatible” type for that protocol you want the response).
//NOTE please be careful and don't forget to delete the intern "get_response" in the "seq" sequence if you had it from the solution of "yhchou". Calling two times "get_response" would hang the simulation waiting for a second response
//define a "seq" sequence class without the get_response(rs);
...
//use that "seq" sequence class in other sequence which has a wrong/different protocol type and use your virtual sequencer (p_sequencer) to point to the correct one
//note that seq is the sequence and not an item_sequence
`uvm_do_on_with(seq , p_sequencer.second_sequencer, {
start_byte_address == byte_address;
});
seq.get_response(result);
Again we see that the get_response function is very tied to the sequence where it is called (sequence type).