UVM driver sequencer interaction with parameterized sequence item

I have a sequence item of the type :

class seq_item#(int PARAM_NAME) extends uvm_sequence_item;
`uvm_object_param_utils(seq_item#(PARAM_NAME))

The sequence item is created in the sequence as:


m_seq_item = seq_item#(PARAM_NAME):: type_id::create("name")

In the agent, the sequencer is declared and created as:

uvm_sequencer#(seq_item#(PARAM_NAME)))   m_sqr;
...
m_sqr = uvm_sequencer#(seq_item#(PARAM_NAME))::type_id::create("name", this);

The driver class definition is


class driver#(int PARAM_NAME) extends uvm_driver #(seq_item#(PARAM_NAME))

The driving loop is :

forever begin
  seq_item_port.get_next_item(req);

  do_transaction(); 
  // please note that the transaction is visible on the bus

  seq_item_port.item_done();
  $cast(rsp,req);
  rsp.set_id_info(req);
  seq_item_port.put_response(rsp)
end

LE:


typedef parameterized_sequence_with_very_long_name#(PARAM_NAME) my_sequence_type;
class my_test extends uvm_test;
  my_sequence_type m_seq;
...
  function void build_phase(uvm_phase phase);
    super.build_phase(phase)
    m_seq = my_sequence_type::type_id::create("name")
  endfunction
...
endclass

class parameterized_sequence_with_very_long_name#(PARAM_NAME) extends uvm_sequence;

I get a runtime fatal from the sequencer :
UVM_FATAL : <…> [PUTRSP] Failure to cast response in put_response.

Please support to find what I’m doing wrong.

Thank you

In reply to Brass:

Without an actual testcase, it’s difficult to provide accurate feedback.

However, you shouldn’t cast the req to rsp. You should clone() req and cast that to rsp to ensure that the original req won’t be reused. I would also call item_done() after the response is created just to ensure that req hasn’t been changed at some point outside of this task.


forever begin
  seq_item_port.get_next_item(req);
 
  do_transaction(); 
  // please note that the transaction is visible on the bus
 
  $cast(rsp,req.clone());
  rsp.set_id_info(req);
  seq_item_port.put_response(rsp)
  seq_item_port.item_done();
end

In reply to Brass:

How did you construct the rsp?

In reply to chr_sue:
Hi chr_sue

good question: I also used the PARAM_NAME

rsp = seq_item#(PARAM_NAME)::type_id::create("rsp",this);

In reply to cgales:

Hi cgales

and thank you for your answer.

I keyed in your suggestion but the result is the same.

In reply to Brass:

You can pass the rsp also using item_done like this

  $cast(rsp,req.clone());
  rsp.set_id_info(req);
  seq_item_port.item_done(rsp);

Because we do not see the whole story it is not easy to give you the right advice.
It is more guessing what we can do.

In reply to chr_sue:

Thank you for your suggestion . Unfortunately it doesn’t work either in my case.

The example is based on production code, so I was hoping for more of a theoretical approach, since I haven’t seen any documentation/online resource for this particular case.

In reply to Brass:

You left out the declaration of the sequence.

The code in uvm_sequence::put_response() is trying to $cast() between a uvm_sequence_item handle and the RSP type from your sequence declaration. Did you give a different RSP type than then REQ type?

In reply to chrisspear:

Hi chrisspear

and thank you for your reply.
My driver is defined as :

class driver#(int PARAM_NAME) extends uvm_driver #(seq_item#(PARAM_NAME))

As per uvm_driver class definition, the rsp type is implicitly the same as the req type:

class uvm_driver #(type REQ=uvm_sequence_item,type RSP=REQ) extends uvm_component;

I have,however, tried to create the rsp type explicitly inside the driver, as per your suggestion and also to declare the driver class as :

class driver#(int PARAM_NAME) extends uvm_driver #(seq_item#(PARAM_NAME), seq_item#(PARAM_NAME))

with no change in the outcome.

In reply to Brass:

The sequence item is created in the sequence as:

m_seq_item = seq_item#(PARAM_NAME):: type_id::create("name")

Could you share code for the sequence class specialization in the test i.e handle declaration of the sequence in the test using which you call task start

In reply to ABD_91:

Here is a working example with a parameterized sequence item. You can try to work forward from this to your situation.

In reply to ABD_91:
Hi ABD_91 and thank you


typedef parameterized_sequence_with_very_long_name#(PARAM_NAME) my_sequence_type;
class my_test extends uvm_test;
  my_sequence_type m_seq;
...
  function void build_phase(uvm_phase phase);
    super.build_phase(phase)
    m_seq = my_sequence_type::type_id::create("name")
  endfunction
...
endclass

class parameterized_sequence_with_very_long_name#(PARAM_NAME) extends uvm_sequence;

Also added to the initial post. thanks

In reply to chrisspear:

Hi chrispear

and thank you

it seems my sequece paramter list was void :

class parameterized_sequence_with_very_long_name#(PARAM_NAME) extends uvm_sequence#();

instead of

class parameterized_sequence_with_very_long_name#(PARAM_NAME) extends uvm_sequence#(PARAM_NAME);

Thank you all for contributing to solve this

In reply to Brass:

I cannot agree. I modified the code example from chrisspear wrt to the sequence definition to

class tx_sequence extends uvm_sequence;

It works also, but it should fail because this sequence has to produce seq_items.

In reply to chr_sue:

If you don’t specialize the uvm_sequence on line 22, then req is just uvm_sequence_item and you will get an elaboration error on line 33 for the req.data reference. You must have:

class tx_sequence extends uvm_sequence #(tx_item(P));

In reply to chrisspear:

This is exactly what I was expecting. But Questa-2022.4 is tolerting this.
It’s strange I know, but it is as it is.

In reply to chr_sue:

You must seeing be a disturbance in the matrix. I just tried Questa 2022.4_2 and it correctly gave an elaboration error for req.data and rsp.data, when uvm_sequence uses the default specialization uvm_sequence_item.

In reply to chrisspear:

The `uvm_info are only needed for displaying some information. If you are removing them it works in my environment.

In reply to chr_sue:

Of course. You removed the two references to tx_item members, data. Everything else is uvm_sequence_item members.