Extending an already extended uvm_sequence_item class

Hi,

I have a base uvm_sequence_item-extended class called “instruction_packet”. I declare it like this:

class instruction_packet extends uvm_sequence_item;
  rand bit[31:0] data;
  rand bit[7:0] address;
  ...

  function new(string name = "instruction_packet");
    super.new(name);
  endfunction: new
  ...
endclass

I want to create a few new classes like “J64_instruction_packet” and “U64_instruction_packet” that extends this class and inherits its properties like this:

class J64_instruction_packet extends instruction_packet;
  rand bit[11:0] J_var;
  ...

  function new(string name = "J64_instruction_packet");
    super.new(name);
  endfunction: new
  ...
endclass

However, I cannot use this new class in my sequence:

class seq extends uvm_sequence#(J64_instruction_packet);

because it is not a ‘uvm_sequence_item’

Error is: "Dynamic cast failed. Casting of source class ‘uvm_pkg.uvm_sequence_item’ to destination class type ‘simprisc_uvm_includes.J64_instruction_packet’ failed due to type mismatch. Please ensure matching types for dynamic cast.

Is there a better approach?

Thank you!!

In reply to TheGreatNed:

You should have no issues using J64_instruction_packet in a sequence, as it is extended from instruction_packet, which is extended from uvm_sequence_item.

Your error indicates that you are trying to cast a sequence_item to J64_instruction_packet, which was not the original sequence_item type. You will have to post the code that is causing the error.

My apologies, I was only missing this line:

`uvm_object_utils(J64_instruction_packet)