Item instantiation vs. item creation

I would like to understand the rule of item instantiation vs. the rule of item creation .

refmofel.sv file :


`uvm_analysis_imp_decl(_from_axi)
`uvm_analysis_imp_decl(_from_apb)

class refmodel extends uvm_component; 

   ram_item item;
   uvm_analysis_port #(ram_item) ram_analysis_port
   ...

   function void write_from_axi(axi_item axi_curr_item)
      item = ram_item::type_id::create("item");
      item.data = axi_curr_item.data;
      ram_analysis_port.write(item);
   endfunction : write_from_axi


   function void write_from_apb(apb_item apb_curr_item)
      item = ram_item::type_id::create("item");
      item.data =  apb_curr_item.data;
      ram_analysis_port.write(item);
   endfunction : write_from_apb


endclass

My question is on “item” of type ram_item.
If I instance 1 item and use it 2 times in 2 functions + create and send with write,
Is it OK to do that ?
or can cause issues ?

In reply to AL_verif:

Waht do you mean wrt to instantiation? If you consider an instance as compomemt, then you cannot instantiate an item because it is an object.

This will lead to serious issues, unless you can guarantee that
the two functions can never be called parallely for the same refmodel
instance.

I would move the ram_item declaration inside the functions.

In reply to logie:

OK. Thanks you!

In reply to logie:

But the each of the write functions are creating items separately … so why would this be a concern ?? Just a curious question ??