You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

SystemVerilog顶层模块能否设接口端口?层级接口使用报错求助

SystemVerilog顶层模块接口端口问题排查

问题

SystemVerilog顶层模块能不能用接口当端口?我定义了层级接口并用到顶层模块里,结果碰到了「Error-[SV-UIP] Unconnected interface port」错误,帮忙看看哪里错了。

示例代码

interface bank_inf (
                inout logic [20:0] data_io,
                inout logic qsb_io,
                inout logic ctrl_io);
endinterface

interface channel_inf #(parameter numbanks = 7)
        ( bank_inf banks[numbanks-1:0] );
endinterface


interface ss1_inf #(parameter numchannels = 8, parameter numbanks = 7)
        ( channel_inf channels[numchannels-1:0]);
endinterface

module die1 (ss1_inf ss);
endmodule
module die2 (ss1_inf ss);
endmodule

module top (
ss1_inf ss1,
ss1_inf ss2
                );
   die1 inst1(ss1);
   die2 inst2(ss1);
endmodule

报错信息

Error-[SV-UIP] Unconnected interface port
../test.v, 22
"ss1"
The port 'ss1' of top-level module 'top' whose type is interface 'ss1_inf'
is left unconnected. It is illegal to leave the interface ports unconnected.
Please make sure that all the interface ports are connected.

问题分析与解决办法

  • 顶层模块可以有接口端口,但顶层是仿真的最上层,没有上级模块给它的接口端口提供连接,所以这些端口不能悬空,必须连到实际的接口实例上。你现在的代码里,top作为顶层模块,它的ss1和ss2接口端口没有连接任何东西,所以报错。
  • 正确的做法是在顶层模块内部实例化完整的接口层级,然后把这些接口实例传给子模块。修改后的代码如下:
interface bank_inf (
                inout logic [20:0] data_io,
                inout logic qsb_io,
                inout logic ctrl_io);
endinterface

interface channel_inf #(parameter numbanks = 7)
        ( bank_inf banks[numbanks-1:0] );
endinterface

interface ss1_inf #(parameter numchannels = 8, parameter numbanks = 7)
        ( channel_inf channels[numchannels-1:0]);
endinterface

module die1 (ss1_inf ss);
endmodule
module die2 (ss1_inf ss);
endmodule

// 修改后的顶层模块
module top ();
   // 逐层实例化接口,构建完整的层级结构
   bank_inf bank_inst[6:0]();
   channel_inf channel_inst[7:0] (.banks(bank_inst));
   ss1_inf ss1_inst (.channels(channel_inst));
   // 如果ss2需要独立的接口,单独实例化另一组
   ss1_inf ss2_inst (.channels(channel_inst));

   die1 inst1(ss1_inst);
   die2 inst2(ss1_inst);
endmodule
  • 补充说明:
    1. 原顶层的接口端口被移除,改成在内部创建接口实例,这样就不存在端口悬空的问题了。
    2. 如果ss1和ss2需要对应不同的硬件通道,要为它们分别实例化独立的接口层级,不要共用同一组实例(根据你的实际设计需求调整)。
    3. 顶层模块的端口一般只留需要和外部仿真环境交互的信号(比如时钟、复位),接口实例都在顶层内部创建后传给子模块。

内容的提问来源于stack exchange,提问作者Sainath reddy kotla

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.20 03:15:42