Hi,
The packets stored in class object queue is not correct. I have added 2 objects in the queue, but when I read back the queue, both packets are second, not the First and Second. Anybody has come across this kind of issue?
---------- I have tried following code: -----------
class packet;
rand bit [15:0] sip;
rand bit [15:0] dip;
rand bit [15:0] sport;
endclass
module tb;
initial begin
packet p;
packet p2;
packet p3;
packet p_q[$];
int p_size = 2;
int i=0;
p2 = new();
p3 = new();
for(i=0; i<p_size; i++) begin
p2.sip = ('h701 + i);
p2.dip = ('h801 + i);
p2.sport = ('h901 + i);
p_q.push_back(p2);
$display("p2.sip = 'h%0h",p2.sip);
$display("p2.dip = 'h%0h",p2.dip);
$display("p2.sport = 'h%0h",p2.sport);
end
for(int i=0; i<p_size; i++) begin
$display("p_q[%0d].sip = 'h%0h",i,p_q[i].sip);
$display("p_q[%0d].dip = 'h%0h",i,p_q[i].dip);
$display("p_q[%0d].sport = 'h%0h",i,p_q[i].sport);
end
end
endmodule