If I have the sequence items below what is the best way to copy a_txn data into b_txn? From what I recall, I can’t do $cast(b_txn,a_txn). Should I just do an pack and unpack?
class a_txn extends uvm_sequence_item;
   bit[7:0] data;
   function void do_copy(uvm_object rhs);
      a_txn RHS;
      assert($cast(RHS, rhs));
      super.do_copy(rhs);
      this.data = RHS.data;
   endfunction : do_copy
endclass : a_txn
class b_txn extends a_txn;
   data_type_t data_type;
   function void do_copy(uvm_object rhs);
      b_txn RHS;
      assert($cast(RHS, rhs));
      super.do_copy(rhs);
      this.data_type = RHS.data_type;
   endfunction : do_copy
endclass : a_txn
             
            
              
              
              
            
           
          
            
            
              In reply to DVCoder:
If you do not use any field automation macros in this class or any of its extensions, you can override copy() directly.
class a_txn extends uvm_sequence_item;
  function new(string name);
    super.new(name);
  endfunction
   bit[7:0] data;
  function void copy(a_txn rhs);
      super.copy(rhs);
      this.data = rhs.data;
   endfunction : copy
endclass : a_txn 
class b_txn extends a_txn;
  int data_type;
    function new(string name);
    super.new(name);
  endfunction
   int data_type;
  function void copy(b_txn rhs);
      super.copy(rhs);
      this.data_type = rhs.data_type;
   endfunction : copy
endclass : b_txn
module top;  
  a_txn a=new("a");
  b_txn b=new("b"); 
  initial begin
    a_txn ba;
    a.data = 7;
    ba =b;
    ba.copy(a);
    $display(b.data);
  end
endmodule
Otherwise you would need to create a separate do_copy_a() method that calls a_txn::do_copy() directly.