我是 verilog 用户,不熟悉 systemverilog。
我在 systemverilog 中找到了在 DUT 和接口之间使用 modport 和实例化的内容。
但是我不明白为什么要使用modport以及如何在systemverilog中使用接口和DUT之间的互连?
小智 5
Modport 是模块端口的缩写。它们允许定义接口内信号的不同视图。在许多情况下,只需要两个 modport 或视图 - 一个用于接口的源端,一个用于接收器端。一个简单的例子如下:
interface simple_if ();
wire we;
wire wdata;
wire full;
// source-side view
modport src (
output we,
output wdata,
input full
);
// sink-side view
modport snk (
input we,
input wdata,
output full
);
endinterface
Run Code Online (Sandbox Code Playgroud)
该接口可用于将两个模块实例连接在一起,并且可以使用点符号在每个模块实例中指定要使用的视图或 modport。下面的示例使用上面的接口定义:
module top();
// first, instantiate the interface
simple_if simple_if ();
// source-side module instantiation
src_side_module u_src_side_module (
.clk (clk),
.rstl (rstl),
.if(simple_if.src) // .src specifies the modport
);
// sink-side module instantiation
snk_side_module u_snk_side_module (
.clk (clk),
.rstl (rstl),
.if(simple_if.snk) // .snk specifies the modport
);
endmodule
Run Code Online (Sandbox Code Playgroud)
其他一些注意事项:
或者,可以在指定 IO 的模块中指定 modport,如下所示:
模块 src_side_module ( 输入线 clk, 输入线 rstl, simple_if.src if ); ....
希望这可以帮助。