Runtime Fatal Error : p_sequencer can't be casting from a parameterized sequencer

Hi, Dear All,

I have a very interesting problem here, image a multiple lanes (changeable) communication system, since some relationship maybe exist across those lanes, in order to model it, I just use a parameterized driver/sequencer in a verification environment, which looks like as:

class driver #(parameter LANES = 4) extends uvm_driver #(transaction #(LANES));
class sequencer #(parameter LANES = 4) extends uvm_sequencer #(transaction #(LANES));

Simultaneously, I want to use following Macro in my sequence providing a handle pointed to the sequencer, as we know, called p_sequencer.

class pma_base_sequence #(parameter LANES = 4) extends uvm_sequence; 
  `uvm_declare_p_sequencer(sequencer #(LANES))

However, I got following runtime uvm_fatal error:

UVM_FATAL …/src/uvc/PMA/ @ 0: uvm_test_top.pma_agt.pma_seqr@@pma_base_seq [DCLPSQ] testbench_top.pma_base_sequence.m_set_p_sequencer uvm
est_top.pma_agt.pma_seqr.pma_base_seq Error casting p_sequencer, please verify that this sequence/sequence item is intended to execute on this type of sequencer

It looks like the casting from my parameterized sequencer above to specific p_sequencer failed, i.e. this statement failed:

$cast(p_sequencer, sequencer#(LANES))

I have no idea what’s going on here, does anyone knew it ? I really appreciate if you can help me, thanks in advance !


The issue seems like in your sequencer’s type. You should create your sequencer extends from uvm_sequencer. I am not sure why you extends from uvm_driver class.


In reply to :

Hi, Baser,

Thank you very much for your quick response, actually, here is a typo, I do make my sequencer inherits from uvm_sequencer.

As you see, the problem still exist.

BTW, if I didn’t use parameterized sequencer, it can works without this issue.

BR, WangYang

Is there a specific reason you are creating a specialized sequencer instead of using the generic uvm_sequencer? Also, is there a specific reason you are trying to declare p_sequencer?

For portability and reuse, it is recommended to just use the uvm_object_utils() macro in a sequence and not use the uvm_declare_p_sequencer() macro. Additionally, you should instantiate a parameterized uvm_sequencer in your agent instead of creating a new component.

In reply to cgales:


Really thanks for your response.

I just declare a model inside my sequencer, it could be thought as kind of reference model, the model itself is parameterized, to pass the parameter into the reference model, I have to declare the sequencer as parameterized sequencer.

class my_sequencer #(parameter LANE_COUNTS = 4) extends uvm_sequencer;

  lane_model #(LANE_COUNTS) model;

endclass : my_sequencer

My sequence here is trying to access the lane_model, then take difference actions base on that, that is why I want to declare a p_sequencer here.

task body();
  if (p_sequencer.model ......)


Hopefully, my explanation is clear to you. BTW, I do instantiate my_sequencer in the agent.

Additionally, could you please tell me why it is good for portability and reuse to not use the `uvm_declare_p_sequencer() Macro ?

When you utilize p_sequencer in a sequence, you are requiring that sequence to run on a specific sequencer type. By not using p_sequencer, your sequences are more portable and can be utilized on any sequencer that is type’d appropriately (i.e. creates the appropriate sequence_item).

If your lane_model is interface specific, then I would include it as part of the Agent’s configuration object. Your sequence would have a handle to the Agent’s configuration object that would be assigned when the sequence is created. The sequence can then make direct use of the lane_model from the configuration object.

In reply to cgales:


Your comments make a lot of sense, thanks very much.

I will change my sequence and try :)

BR, WangYang

Does anyone have an answer for the above issue?
Even I faced the same issue with my code.


In reply to pavan85v:

The answer as I posted above is to not use p_sequencer and to use a parameterized uvm_sequencer in your agent.

If you need the handle to the sequencer your sequence is running on, use m_sequencer.

In reply to caowangyang:
I do not understand why you are doing simple things so complicated. You can avoid any paramerization by putting your parameter into a package and importing this package in any place where needed.