How to connect bi-directional signal

How and where to connect bi-directional signal?


interface sram_if # (parameter ADDR_WIDTH =10,DATA_WIDTH =32, STRB_WIDTH = DATA_WIDTH/8) (input bit clk );
   logic rst;
   logic en;
   logic we;
   logic [ADDR_WIDTH-1:0] addr;
   logic  [DATA_WIDTH-1:0] data;//bi directional
   logic [STRB_WIDTH-1:0] strb;
   logic region;
endinterface



module top;
  import uvm_pkg::*;
  `include "uvm_macros.svh"

  import sram_pkg::*;

  logic clk;
  logic rstn;

  initial begin
    clk = 0;
    forever begin
      #10 clk = ~clk;
    end
  end

  initial begin
    rstn = 0;
    repeat (5) @ (posedge clk);
    rstn = 1;
  end

  //CONNECT interface ports
  sram_if intf(clk );

  sram #(
    .ADDR_WIDTH(`ADDR_WIDTH),
    .DATA_WIDTH(`DATA_WIDTH)
  ) dut (
    .clk   (clk),
    .rstn  (intf.rst),
    .en    (intf.en),
    .we    (intf.we),
    .addr  (intf.addr),
    .data  (intf.data),
    .strb  (intf.strb),
    .region (intf.region)
  );

  initial begin
  clk <= 0;
  uvm_config_db#(virtual sram_if)::set(null,"*","sram_if",intf);
  run_test ("sram_base_test"); //start test
  end
endmodule

In reply to grey:

Please use code tags making your code easier to read. I have added them for you.

Again, without a complete example showing your issue, it’s difficult to make any recommendations.

Are you getting a syntax error? Unexpected behavior? Something else?

In reply to chr_sue:

What will happen if read operation?

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)].

In reply to grey:

You should read this article and see if you can determine what the issue is.