sc_port 和 sc_export 之间的区别

Difference between sc_port and sc_export

有人能清楚直观地解释一下SystemC中sc_portsc_export的区别吗?什么时候使用端口,什么时候导出?

我已经阅读了手册的部分内容,但我仍然无法理解两者之间的主要概念差异。

来自 IEEE Standard for Standard SystemC® 语言参考手册

Class sc_export allows a module to provide an interface to its parent module. An export forwards interface method calls to the channel to which the export is bound. An export defines a set of services (as identified by the type of the export) that are provided by the module containing the export.

Providing an interface through an export is an alternative to a module simply implementing the interface. The use of an explicit export allows a single module instance to provide multiple interfaces in a structured manner.

If a module is to call a member function belonging to a channel instance within a child module, that call should be made through an export of the child module.

所有这一切的结果是,如果没有 sc_export,则需要在父模块中创建一个 sc_port 并将其连接到子模块的端口以公开子模块的端口作为父模块的端口。使用 sc_export 允许直接将子端口公开为父模块的端口。只需创建 sc_export 的实例并将其绑定到子端口。

有关完整说明和 class 规范,请参阅 IEEE Standard for Standard SystemC ® 语言参考手册的 5.13 部分

p.s。如果您不打算将代码转换为 VHDL,则无需使用 sc_export。 SystemC 只是标准的 C++,端口只是普通的 public 成员(你可以有一个 private 端口,但似乎没什么意义)所以你可以引用它并假装它是的成员它的父模块或任何其他可以访问它的模块。

SystemC 的要求是每个 portexport 必须 bound/connected 到 channel(未绑定端口除外,但让我们暂时忽略它们)。 channel 实例化的地方是区分 portsexports.

对于 exportchannel 实例必须位于具有 export[=44] 的同一模块中=],或位于其中的子模块内。

对于 portchannel 实例必须驻留在具有端口的模块之外。

想象一个模块 top_module 有两个子模块 senderreceiver 实例化在它里面有一个 data 连接 senderreceiver。如果您选择使发送方的输出数据类型为 sc_port<>,那么您将需要在 [=67= 中实例化通道,例如 sc_signal<> ] 和 bind 语句最好在 top_module 的构造函数中。但是,如果您选择使发送方的输出数据类型为 sc_export<>,那么您将需要在子模块 sender[ 中实例化通道=44=]。因为您本质上是将通道的功能“导出”到 sender.

之外的世界

这是我对端口和出口的直观理解。请对我的“必须”声明持保留态度,因为 Accellera 实施不强制执行此类规则,但更多地与绑定顺序(自上而下与自下而上)有关。

作为经验法则,我总是将导出用于输出,将端口用于我所有模块的输入。我的哲学是,“你驾驶它,你拥有它”。