How to record the item with randomization every time

I have code as shown below.



    class my_item extends uvm_object;
        rand bit [31:0]  id;
    endclass
...
...
my_item m_data;
my_item record_data;

m_data.randomize();
record_data = m_data;
...
...
do begin
    m_data.randomize();    // dead loop here and I have no idea how to update
end while (m_data.id == record_data.id);


The record_data is also changed every time when m_data is randomized… what I want to do is just make sure the second time to randomize is not the same as the result from the first time of randomization…

Thank you for any help.

Why not create another “my_item” and store the randomization value in that for comparison ? If you need all values, you can consider an array of “my_item” ?

In reply to zz8318:

https://verificationacademy.com/forums/systemverilog/discrepancy-during-call-randomize#reply-88413

Hope this thread helps