How to connect bi-directional signal

In reply to cgales:

Thank you for adding tags.

I am having a dilemma on how to drive the data to DUT and what will happen if read operation.

Here is a part of driver class code

   virtual task drive_trans (sram_trans trans);
      vif.addr <= trans.addr;
      vif.we <= trans.we;
      vif.en <= 1;
      if (trans.we)
        vif.data <= trans.data;   //error occurred here
      @ (posedge vif.clk);
      vif.en <= 0;
   endtask
    vif.data <= trans.data;
      |

xmelab: *E,WANOTL (…/verif/sram_driver.sv,36|10): A net is not a legal lvalue in this context [9.3.1(IEEE)].