hi
I have doubt in following example related to queues. In this scenario, same transaction class randomized twice and pushed each randomization into two different queues (q1 and q2) of “c” (transaction) data type,respectively. When I popping from both queues, I am getting same address instead different addresses. I am bit confused on this, can anyone please clarify on this.
class c;
rand logic [3:0] addr;
endclass:c
module m;
c c1;
c txn1,txn2;
c q1[$],q2[$];
initial
begin
c1 = new();
//**** First Randomization *****
c1.randomize();
$display("First addr=%h",c1.addr); //addr = 4'hB
q1.push_back(c1);
//**** Second Randomization *****
c1.randomize();
$display("Second addr=%h ",c1.addr); //addr = 4'h3
q2.push_back(c1);
txn1 = q1.pop_front();
$display("queue1 addr=%h",txn1.addr); //Getting addr = 4'h3, **instead of addr = 4'hB**
txn2 = q2.pop_front();
$display("queue2 addr=%h ",txn2.addr); //addr = 4'h3
end
Thanks in advance,
Jagan Kudimi