How to pass dynamic data array to lower sequence

Hello, experts.

I have a question.

Is there a way to pass a dynamic data array to a lower sequence?

For instance, when a bus transaction consists of bus data with multiple clock lengths, it includes bus data in a dynamic data array within a nested sequence and passes this bus data to a lower sequence.

If there isn’t a way to do this, what would be the appropriate approach for handling such cases?

The example code is provided below.


class my_item extends uvm_sequence_item;
    rand logic [15:0] data;

    `uvm_object_utils_begin(my_item)
        `uvm_field_int(data, UVM_ALL_ON | UVM_NOPACK | UVM_HEX);
    `uvm_object_utils_end

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

class base_seq extends uvm_sequence #(my_item);
    `uvm_object_utils(base_seq)

    // control knobs
    rand bit [15:0] data [];
    
    function new(string name = "base_seq")
        super.new(name);
    endfunction : new
endclass : base_seq

class nested_seq extends base_seq;
    `uvm_object_utils(nested_seq)

    sub_seq1 sub_seq1;
    
    virtual task body();
        `uvm_do_with(sub_seq1, {sub_seq1.data == local::data;}) // --> error occurs!
    endtask : body
endclass : nested_seq

class sub_seq1 extends base_seq;
    `uvm_object_utils(sub_seq1)
    
    virtual task body();
        int i;
        data = new[10];
        for(i=0; i<10; i++) begin
            `uvm_do_with(req, {req.data == local::data[i];}) // maybe possible way...
        end
    endtask : body
endclass : sub_seq1


CAn you share the code for understanding?

In reply to YMNKY:

It would have helped to show the error message. I believe you need to write the constraint as

`uvm_do_with(sub_seq1, {sub_seq1.data.size == local::data.size;
                        foreach(sub_seq1.data[i]) sub_seq1.data[i] == local::data[i];})

In reply to dave_59:

Hi, dave.

The error message is like

Error-[IVCB-INTVAR] Non integral variable

The variable data is not an integral type.
Change the type of the variable or remove it from the constraint expression.




As you said, after applying it to the code, it works well without any errors.

Thank you for solving the problem.