In reply to cgales:
Thanks cgales for your reply.
Here is how these packets are written from the driver into the queue packet_queue_owr through the analysis port
// connection with scoreboard to send driven packets
ovm_analysis_port #(packet_obj) driver_obj2sb_port;
//...
task driver_obj::run();
//drive packet
//...
//write packet twice
repeat(2) driver_obj2sb_port.write(pkt_obj);
//...
// go to the next packet
seq_item_port.item_done();
endtask : run
Based on what you said (about using the same handle in different locations) and what I found on the forum, I added the following function write_obj to create, copy and write packets into the analysis port:
//============Function Write to scoreboard================//
function void driver_obj::write_obj(packet_obj pkt_orig);
packet_obj pkt_new; //...Object declared
pkt_new=new(); //...New Object created
pkt_new.copy(pkt_orig); //....Copied object
driver_obj2sb_port.write(pkt_new); //Object written
endfunction : write_obj
task driver_obj::run();
//
repeat(2) write_obj(pkt_obj);
endtask : run
This solved my problem.
What do you think? Is this a good practice to use all the time? even if I have to write the packet only once ?