How to use get_response within a virtual sequence?

Hi all,

In my virtual sequencer i have two different sequencer instantiations which works on two different sequence items.

I was able to get the response item using last_rsp function,

rsp = p_sequencer.sequencer1.last_rsp();

but it seems that it is not removing the response from the sequencer’s queue which is resulting in response queue overflow.

which is the good way to get the response within a virtual sequence?

  1. did you try the following code? if yes, what is the message.
    p_sequencer.sequencer1.get_response();

  2. Provides you alternative 2 solutions:

(1) you could declare a sequence with get_response of the the sub-sequencer, and then repalce do_item with do_sequence.

(2) if you do not need the response, you could also remove the following code in driver. then you do not need to get response anymore.
seq_item_port.item_done(rsp);

Hi,

You need to use get_response method inside the body of the specific sequence and for each `ovm_do request.

If you are not interested in response from driver then you can do send null response using “seq_item_port.item_done()”

Hope this helps you.

Regards,

Hi yhchou & vaibhav,

 when i tried => p_sequencer.sequencer1.get_response()

It is giving an error message that the get_response is not a class item.

get_response() is implemented in the ovm_sequence class.
So, we can use get_response only in those classes which are derived from the ovm_sequence as base class.

As the sequencer derives from the ovm_sequencer, it cannot have its implementation.

======

U have suggested to use do_sequence rather than do_item but i need to use the response for continuing further.

Is there any other approach?

Thanks & regards,
mpurna

Hi,

you could declare an attribute in sequece for passing the response. for example:

`ovm_do(seq);
result = seq.rs;

by doing this we could obtain the result no matter how many layer of sequences there are.

and thank you for informing me the reason why get_response() could not be invoke.

Thank you yhchou,
mpurna

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