Response_handler

Hello everybody,

Can someone give me quick intro to what the “response handler” is and how you use it? Maybe also some small nice code snippet? What’s the benefit of using this instead of get_respons()?

Thank you and best regards,
Tudor

You can use the response_handler when there is no one-to-one correspondence between requests and responses. Another situation is when there is not enough information in the response to route it to the proper sequence.

In reply to dave_59:

Hi Dave,

What do you mean by " not enough information in the response to route it to the proper sequence"? Because I saw that response_handler() is a function inside ovm_sequence_base and that it gets called by the sequencer on a specific sequence upon receiving a response.

In reply to Tudor Timi:

Basically, I find that the response handler is the easiest way to decouple response handling from sequence item sending so that they each run in their own thread. Sure, you could accomplish the same thing with fork/join and get_response(), but the response handler is easier and cleaner.

You will want to do this if you don’t want to stop sending sequence items while responses are pending. Also, as Dave mentioned, if there is not a one-to-one correspondence between responses and sequence items.

If your use case is a very straightforward send item, get response before sending next item; then using a single thread with get_response() will be simpler and sufficient. However, I have yet to come across a case where I did not use the response handler.

In reply to jeff.schroeder:

i have a problem. in my sequence i have to wait till i got the response and i can’t get requests back to back.
i must use - wait(expected_responses == 0);
otherwise the response handler does not get the response and i get a message that the requests is killed or exit. i believe that after finish_item the ovm forgets from the last request.
mu code :

this_transfer.set_transaction_id(xact_id);
this_transfer.set_sequencer(get_sequencer());

    // send xaction
    //`ovm_send(this_transfer)
    finish_item(this_transfer);
    if (this_transfer.NeedRsp)
    begin
        expected_responses++;
        $display("start wait for expected_responses at %t",$time());
        wait(expected_responses == 0);
        $display("finish wait for expected_responses at %t",$time());
    end
   endtask // body