Randomization of multiple seq items with related constraints

I have 3 sequence items, with a rand [7:0] id; in all 3 of them.

During a test run, I want all of them to be unique id values. Even though I have declared them as “randc” in each Sequence Item, it only avoid repetition of “id” for that particular sequence item. How can I add a constraint for them all to have unique values? id in sequence 1 should NEVER show up for sequence 2.
Please help.

In reply to UVM_learner6:

Like I just showed you here, you can make the
list
a static variable shared between the sequence items.

In reply to dave_59:

Hi Dave,

Thank you.
Where will this static variable need to be declared, so that all 3 sequence item classes can share the static list variable?

Each of these sequence items each have a corresponding sequence. They are called within fork join statements from the test case.

Thanks.

In reply to UVM_learner6:

Use a common base class, or if they are created by the same sequence, use an id variable there, or use the config_db. So many choices.

In reply to UVM_learner6:

you can try this too.

In reply to UVM_learner6:

I have 3 sequence items, with a rand [7:0] id; in all 3 of them.
During a test run, I want all of them to be unique id values. Even though I have declared them as “randc” in each Sequence Item, it only avoid repetition of “id” for that particular sequence item. How can I add a constraint for them all to have unique values? id in sequence 1 should NEVER show up for sequence 2.
Please help.

I tried something based on your question, and I wanted to share it with you.


module automatic test;
    class seq1;
        rand bit [7:0] port_id;

        constraint port_id_c {
            soft port_id inside {[1:100]};
        }
    endclass : seq1

    class seq2;
        rand bit [7:0] port_id;

        constraint port_id_c {
            soft port_id inside {[1:100]};
        }
    endclass : seq2

    class seq3;
        rand bit [7:0] port_id;

        constraint port_id_c {
            soft port_id inside {[1:100]};
        }
    endclass : seq3

    initial begin
        bit [7:0] port_ids[$];
        seq1 s1; seq2 s2; seq3 s3;
        s1 = new(); 
        s2 = new();
        s3 = new();

        repeat (10) begin
            while (port_ids.size() != 3) begin
                s1.randomize();
                s2.randomize();
                s3.randomize();
                if (!(s1.port_id inside {s2.port_id, s3.port_id}) || (s2.port_id inside {s1.port_id, s3.port_id}) 
                      || (s3.port_id inside {s2.port_id, s2.port_id})) begin
                    port_ids.push_back(s1.port_id);
                    port_ids.push_back(s2.port_id);
                    port_ids.push_back(s3.port_id);
                end
            end
            $display("The unique port_ids are %p", port_ids);
            //drive the port_ids
            //Then delete the queue for the next iteration
            port_ids = {};
        end

        //Now let'say you want to drive the seq1 = 3, seq2 = 4, seq3 = 5 to cover some corner condition
        //You will do
        s1.randomize() with {port_id == 3;};
        s2.randomize() with {port_id == 4;};
        s3.randomize() with {port_id == 5;};
        port_ids.push_back(s1.port_id);
        port_ids.push_back(s2.port_id);
        port_ids.push_back(s3.port_id);
        $display("The unique port_ids are %p", port_ids);
        //drive the ports based on ids.
        //Then detete the queue.
        port_ids = {};


        //Now let's say you want the port_ids to be between 101:255
        repeat (10) begin
            while (port_ids.size() != 3) begin
                s1.randomize() with {port_id inside {[101:255]};};
                s2.randomize() with {port_id inside {[101:255]};};
                s3.randomize() with {port_id inside {[101:255]};};
                if (!(s1.port_id inside {s2.port_id, s3.port_id}) || (s2.port_id inside {s1.port_id, s3.port_id}) 
                      || (s3.port_id inside {s2.port_id, s2.port_id})) begin
                    port_ids.push_back(s1.port_id);
                    port_ids.push_back(s2.port_id);
                    port_ids.push_back(s3.port_id);
                end
            end
            $display("The unique port_ids are %p", port_ids);
            //drive the port_ids
            //Then delete the queue for the next iteration
            port_ids = {};
        end
    end

endmodule : test

The outputs are as following:
The unique port_ids are '{'h4d, 'h3f, 'h5c}
The unique port_ids are '{'h3c, 'h4, 'h59}
The unique port_ids are '{'h4, 'h49, 'h34}
The unique port_ids are '{'h24, 'h39, 'h50}
The unique port_ids are '{'h12, 'h3f, 'h2f}
The unique port_ids are '{'h2e, 'h1c, 'h53}
The unique port_ids are '{'hc, 'h59, 'h2}
The unique port_ids are '{'h1f, 'h17, 'he}
The unique port_ids are '{'h30, 'h1f, 'h39}
The unique port_ids are '{'h4d, 'h4d, 'h5f}
The unique port_ids are '{'h3, 'h4, 'h5}
The unique port_ids are '{'hb2, 'hec, 'hc6}
The unique port_ids are '{'h9e, 'h73, 'h71}
The unique port_ids are '{'hce, 'h8d, 'h9c}
The unique port_ids are '{'h76, 'hba, 'hb1}
The unique port_ids are '{'hf1, 'hb5, 'hdf}
The unique port_ids are '{'hf5, 'hb5, 'h8a}
The unique port_ids are '{'he9, 'h6b, 'hd3}
The unique port_ids are '{'hdc, 'h91, 'hfb}
The unique port_ids are '{'hb9, 'hd9, 'hd4}
The unique port_ids are '{'he6, 'h88, 'hf7}

You can try this one…

Basically, you need to have a constraint like this in the parent sequence which has access to all the three sequences.
constraint uniq_cons {unique {seq_1.id, seq_2.id, seq_3.id};}

https://www.edaplayground.com/x/2nNZ

Code for what dave_59 suggested.