Queues in sequence items

Hello all,
I’m having problems using queues in a seq_item object.

Here’s the definition of my seq_item:


class axi4s_seq_item extends uvm_sequence_item;
    rand bit [6:0]      stream_len;
    rand bit [32-1:0]   stream_data [$];
    rand int            pre_wait;

    `uvm_object_utils_begin(axi4s_seq_item)
        `uvm_field_queue_int(stream_data, UVM_ALL_ON)
        `uvm_field_int(stream_len, UVM_ALL_ON)
        `uvm_field_int(pre_wait, UVM_ALL_ON)
    `uvm_object_utils_end

    function new(string name = "axi4s_seq_item");
        super.new(name);
    endfunction

    constraint size_c {
        stream_data.size() == stream_len;
        solve stream_len before stream_data;
    };

    constraint pre_wait_c {
        pre_wait inside {[1:10]};
    };
endclass

In my scoreboard, I get the transaction from the driver, so that I can update the reference model of the DUT. The run_phase of the scoreboard is:


   virtual task run_phase(uvm_phase phase);
        super.run_phase(phase);
        forever begin
            // Get transaction from driver
            driver_ap_fifo.get(txn);
            // Update reference model
            update_ref_model(txn);
        end
    endtask

    task update_ref_model(axi4s_seq_item new_txn);
        new_txn.print();
        $display(new_txn.stream_data.size());
        $display(new_txn.stream_len);
        for(int idx = 0; idx < new_txn.stream_data.size(); idx++) begin
            ref_model_ram.push_back(new_txn.stream_data[idx]);
            ref_model_row_count++;
        end
    endtask

The problem I am facing is the following: the call to new_txn.print() shows the correct contents of the transaction, for instance:


Name Type Size Value

req axi4s_seq_item - @677
stream_data da(integral) 4 -
[0] integral 32 'hf9e96ed3
[1] integral 32 'h1f1f2ded
[2] integral 32 'hcf64120a
[3] integral 32 'hf0e95892
stream_len integral 7 'h4
pre_wait integral 32 'h9
begin_time time 64 0
depth int 32 'd2
parent sequence (name) string 3 seq
parent sequence (full name) string 31 uvm_test_top.env.agent.seqr.seq
sequencer string 27 uvm_test_top.env.agent.seqr

but then when I try to display steram_data.size() I always get a 0, and by extension the loop does no iterations. On the contrary, the stream_len field is correctly printed in the $display.

What am I missing?

Many thanks
Best regards

S

In reply to scorbetta:

A queue is a construct which grows and shrinks with the data inside. There is no need to randomize/dtermine any size of the you. I’d recommedn to remove the constraint size _c. And you do not show how you are filling in the data in your queue.

In reply to chr_sue:

“and shrinks with the data inside”. This sentence rings me a bell, and indeed I was able to correct the bug in my code. Many thanks for pointing this out.

Cheers
S