将接口绑定到顶部

问题描述

请在此处的 edaplayground 上找到我的代码https://www.edaplayground.com/x/EDVr

在顶部模块中,我正在实例化 dut,然后尝试将接口绑定到其上的信号。

module tb_top;
  dut dut1();
  bind dut basic basic_intf(.clk(clk),.reset(reset),.addr(addr),.addr_out(addr_out));
  initial begin
    run_test("base_test");
  end  
endmodule

interface basic(
  input clk,input reset,inout [7:0] addr,inout [7:0] addr_out);
  
  modport dut(
    input clk,input addr,output addr_out
  );
endinterface

// 在此处编码您的设计

module dut(input logic clk,input logic reset,input logic[7:0] addr,output logic[7:0] addr_out);
  
  always_ff @(posedge clk) begin
    if(reset)
      addr_out <= 'h00;
    else
      addr_out <= addr;
  end
  
endmodule

我得到的错误是: 引用:

Error-[VIHIOP] Variable in high conn of inout port
testbench.sv,144
dut,"clk"
This variable is not a net,it cannot be connected to an inout port.
Source info: : basic basic_intf( .clk (clk),.reset (reset),.addr (addr),.addr_out (addr_out));

如果我将这些信号声明为线,我将无法在驱动功能中使用

我该如何解决这个问题?

解决方法

您正在尝试实例化(通过绑定)一个接口,该接口具有连接到变量的 inout 端口,这些变量具有多个驱动程序。 (如果将变量连接到输入端口或输出端口,则该端口必须是唯一驱动它的东西。)addr 由输入端口和接口实例驱动; addr_out 由 always 块和接口实例驱动。