I have a question regarding when to call item_done() in uvm_driver when handling async reset.
txn item;
task process_thread();
forever begin
item = null;
seq_item_port.try_next_item(item);
if(item == null) begin
wait_cycle();
continue;
end
seq_item_port.item_done();
end
endtask
task clean_up_after_reset();
if (item != null)
seq_item_port.item_done();
endtask
According to SV LRM, it is possible thread get switched right after calling item_done() and before setting item to null. And this would result in calling item_done() twice, which would make uvm complain with uvm_error.
I feel to completely solve this issue I need an atomic operation that groups “calling item_done() + setting some kind of flag” together, so that I could clean up this mess after an async reset. Otherwise there seems no good way to tell if I need to call item_done() or not after async reset.
Any help is appreciated.