为什么在接口中使用端口?
SystemVerilog LRM (IEEE 1800-2017) 对接口中的端口进行了如下描述:
简单接口的一个限制是接口中声明的网络和变量仅用于连接到具有相同网络和变量的端口。要共享外部网络或变量(从接口外部建立连接以及与实例化该接口的所有模块端口形成公共连接),需要接口端口声明。接口端口列表中的网络或变量与接口内的其他网络或变量的区别在于,在实例化接口时,只有端口列表中的网络或变量才能通过名称或位置与外部连接。接口端口声明语法和语义与模块相同(参见23.2.2)。
第一句话到底说了什么?我没有看到限制。
在第二句中,外部信号的示例是什么?如何决定信号应该在接口内部声明还是作为接口的端口声明? LRM 中使用的文本不适合我。
The SystemVerilog LRM (IEEE 1800-2017) describes ports in interfaces as follows:
One limitation of simple interfaces is that the nets and variables declared within the interface are only used to connect to a port with the same nets and variables. To share an external net or variable, one that makes a connection from outside the interface as well as forming a common connection to all module ports that instantiate the interface, an interface port declaration is required. The difference between nets or variables in the interface port list and other nets or variables within the interface is that only those in the port list can be connected externally by name or position when the interface is instantiated. Interface port declaration syntax and semantics are the same as those of modules (see 23.2.2).
What is the first sentence saying exactly? I don't see the limitation.
In the second sentence, what is an example of an external signal? How do you decided whether a signal should be declared inside the interface or as a port to the interface? The text used in the LRM just doesn't click for me.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
该问题通过 simple_bus 示例显示,该示例遵循 IEEE 1800-2017 SystemVerilog LRM 部分你引用了。
接口
sb_intf1
和sb_intf2
有两个实例,每个实例创建一组唯一的内部信号(req、int、...)。如果clk
也被声明为内部信号,那么也会有两个时钟信号。示例中未显示生成时钟信号的代码。它可能位于top
模块或其他模块中。他们需要添加连续的分配,以便将生成的时钟信号发送到每个接口实例中的每个内部clk
。通过将共享信号放入接口的端口声明中,可以更轻松地连接公共信号。
The problem is shown with the simple_bus example that follows the section of the IEEE 1800-2017 SystemVerilog LRM you quoted.
There are two instances of the interface
sb_intf1
andsb_intf2
each creating a unique set of internal signals (req, int, ...). Ifclk
had also been declared as internal signal, there would also be two clock signals. What's not shown in the example is the code generating the clock signal. That could have been in thetop
module or another module. They would have needed to add continuous assignments to get the generated clock signal to each the internalclk
in each interface instance.By putting the shared signals in the interface in their port declarations, it makes it much easier to join the common signals.