在线咨询
eetop公众号 创芯大讲堂 创芯人才网
切换到宽版

EETOP 创芯网论坛 (原名:电子顶级开发网)

手机号码,快捷登录

手机号码,快捷登录

找回密码

  登录   注册  

快捷导航
搜帖子
查看: 14830|回复: 9

[求助] systemverilog interface bind

[复制链接]
发表于 2021-2-19 16:44:39 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有账号?注册

x
请问一下,如何在rtl的子模块bind一个interface
我的代码如下://接口文件
`ifndef MY_IF__SV
`define MY_IF__SV
interface my_bind_if(input clk);
   logic [7:0] in1;
   logic [7:0] in2;
   logic [8:0] out1;
endinterface
`endif

//top_tb文件
bind adder8 my_bind_if my_bind_if_inst(
   .in1(a_i),
   .clk(clk),
   .in2(b_i),
   .out1(c_o)
);

//rtl模块
module dut(clk,
           rst_n,
           rxd,
           rx_dv,
           txd,
           tx_en);
...
adder8 add_inst(
   .clk(clk),
        .a_i(rxd),
        .b_i(rxd),
        .c_o(result)
);

vcs仿真的报错信息为:
Error-[UPIMI-E] Undefined port in module instantiation
top_tb.sv, 25
  Port "in1" is not defined in interface 'my_bind_if' defined in "my_if.sv",
  10
  Interface instance: my_bind_if my_bind_if_inst( .in1 (a_i),  .clk (clk),  
  .in2 (b_i),  .out1 (c_o));

Error-[UPIMI-E] Undefined port in module instantiation
top_tb.sv, 25
  Port "in2" is not defined in interface 'my_bind_if' defined in "my_if.sv",
  10
  Interface instance: my_bind_if my_bind_if_inst( .in1 (a_i),  .clk (clk),  
  .in2 (b_i),  .out1 (c_o));

Error-[UPIMI-E] Undefined port in module instantiation
top_tb.sv, 25
  Port "out1" is not defined in interface 'my_bind_if' defined in "my_if.sv",
  10
  Interface instance: my_bind_if my_bind_if_inst( .in1 (a_i),  .clk (clk),  
  .in2 (b_i),  .out1 (c_o));


请问该如何解决呢
发表于 2021-2-19 17:43:04 | 显示全部楼层
interface my_bind_if(input clk, in1, in2, output out1);
    logic [7:0] in1;
    logic [7:0] in2;
    logic [8:0] out1;
endinterface
发表于 2021-2-19 17:46:17 | 显示全部楼层
相当于你的interface只定义了一个叫clk的port。我的理解是这样的,你改一下试试
 楼主| 发表于 2021-2-19 18:40:51 | 显示全部楼层
谢谢大佬,我已经解决这个问题了 但是有一个新的问题
//rtl源码
module adder8 (
        input clk,
        input [7:0] a_i,
        input [7:0] b_i,
        output [8:0] c_o
);
reg [8:0] c_o_tmp;
always @ (posedge clk) begin
        c_o_tmp <= a_i + b_i;
end
assign c_o = c_o_tmp;
endmodule
//interface 代码
interface my_bind_if(input clk, input [7:0] a_i, input [7:0] b_i,output [8:0] c_o);
        logic [8:0] c_o;
            logic [7:0] a_i;
            logic [7:0] b_i;
endinterface

以上述的情况进行vcs仿真verdi查看 发现c_o的波形不对了全程是xxx
而在interface中去掉output [8:0] c_o,则其波形则为正确的
请问这是什么原因呢?
发表于 2021-2-19 21:57:15 | 显示全部楼层


ezio1996 发表于 2021-2-19 18:40
谢谢大佬,我已经解决这个问题了 但是有一个新的问题
//rtl源码
module adder8 (


接口列表中只声明port方向,要不然就写成output logic[8:0] aaa的格式
发表于 2021-2-19 21:59:01 | 显示全部楼层
port列表中只声明port的方向,或者写成output logic[8:0] aaa的格式
发表于 2021-2-20 11:18:15 | 显示全部楼层
怎么感觉怪怪的,定义interface是在哪里用的???
 楼主| 发表于 2021-2-20 15:04:52 | 显示全部楼层
我是想尝试一下bind的用法,用bind观察子模块adder8 的端口信号,下面是下载top_tb.sv中的bind的写法

    bind adder8 my_bind_if my_bind_if_inst(.*);
module adder8 (
        input clk,
        input [7:0] a_i,
        input [7:0] b_i,
        output [8:0] c_o
);
reg [8:0] c_o_tmp;
always @ (posedge clk) begin
        c_o_tmp <= a_i + b_i;
end
assign c_o = c_o_tmp;
endmodule
//interface 代码
interface my_bind_if(input clk, input [7:0] a_i, input [7:0] b_i,output [8:0] c_o);
        logic [8:0] c_o;
            logic [7:0] a_i;
            logic [7:0] b_i;
endinterface
我换成了output logic  [8:0] c_o 仍然波形不对
感觉像是多驱动的问题。
这个问题等价于:那么如何用bind观察子模块的output 端口呢 input的端口用上述写法没有问题
请问各位大神该怎么修改呢?
谢谢大家
发表于 2021-2-20 16:51:49 | 显示全部楼层
你试一下将interface中全部定义成input
 楼主| 发表于 2021-2-20 17:51:51 | 显示全部楼层
@cwang123 谢谢大佬,确实这样就识别出了端口信号,请问一下这是为什么呢?
是不是因为bind观测端口信号,类型必须是input
如果是output的话,则等效于一个多驱动?
我进一步想请教一下 modport的接口可以进行bind吗?
比如说
interface my_bind_if(input clk);
            logic [8:0] c_o;
            logic [7:0] a_i;
            logic [7:0] b_i;
            modport DUT (input clk, input a_i, input b_i,output  c_o);
endinterface
在top_tb中我尝试了下面两种写法都不对
bind adder8 bind_if.DUT bind_if_inst(.*);

bind adder8 bind_if bind_if_inst(
.DUT.clk(clk),
.DUT.a_i(a_i),
.DUT.b_i(b_i),
.DUT.c_o(c_o)
);
这两种都提示
Error-[SE] Syntax error
  Following verilog source has syntax error :
  "top_tb.sv", 25: token is '.'
  bind adder8 my_bind_if.DUT my_bind_if_inst(.*);

Error-[SE] Syntax error
  Following verilog source has syntax error :
  "top_tb.sv", 26: token is '.'
  .DUT.clk(clk),
       ^
您需要登录后才可以回帖 登录 | 注册

本版积分规则

关闭

站长推荐 上一条 /2 下一条

小黑屋| 手机版| 关于我们| 联系我们| 在线咨询| 隐私声明| EETOP 创芯网
( 京ICP备:10050787号 京公网安备:11010502037710 )

GMT+8, 2024-9-22 23:22 , Processed in 0.023532 second(s), 7 queries , Gzip On, Redis On.

eetop公众号 创芯大讲堂 创芯人才网
快速回复 返回顶部 返回列表