SV 中的动态接口数组 [英] Dynamic array of interfaces in SV

查看:40
本文介绍了SV 中的动态接口数组的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在 SV LRM 2012 中,他们说

In SV LRM 2012 they are saying that

接口实例化::=interface_identifier [ parameter_value_assignment ]分层实例 { , 分层实例 } ;

interface_instantiation ::= interface_identifier [ parameter_value_assignment ] hierarchical_instance { , hierarchical_instance } ;

在搜索hierarchical_instance的含义时可以找到

When searching meaning of hierarchical_instance you can find

hierarchical_instance ::= name_of_instance ( [list_of_port_connections ] ) name_of_instance ::= instance_identifier{ unpacked_dimension }

hierarchical_instance ::= name_of_instance ( [ list_of_port_connections ] ) name_of_instance ::= instance_identifier { unpacked_dimension }

终于可以发现

unpacked_dimension ::= [ constant_range ] |[常量表达式]

unpacked_dimension ::= [ constant_range ] | [ constant_expression ]

我想阅读它,以便您的 SV 代码中不能有动态接口数组,对吗?但是当使用 VCS 和 Questa 模拟以下代码行时,它没有任何警告/错误:

I would like to read it so that you cannot have dynamic array of interfaces in your SV code, right? But when simulating the following code line both with VCS and Questa, it works without any warning/error:

virtual protocol_if ifs[];

为什么有效?你能帮我澄清一下吗?

Why it works? Could you clarify it to me?

推荐答案

声明实例数组和声明具有数组维度的变量是有区别的.

There is a difference between declaring an array of instances, and declaring a variable that has an array dimension.

您展示的 BNF 语法适用于 interface_instantiation,它对 module_instantiation 有类似的规则.这只是 generate-for 循环的快捷方式,它创建多个实例,实例名称类似于数组索引.它不是一个真正的数组,其中每个元素都是相同的副本.defparambind 等结构可以改变每个实例的特征,这就是为什么不允许使用变量来程序性地选择特定实例的原因.

The BNF syntax you show is for interface_instantiation, which has similar rules for module_instantiation. That is just a shortcut for a generate-for loop which creates multiple instances with instance names that resemble an array index. It's not a true array where each element is an identical copy. Constructs such as defparam, bind, and others can change the characteristics of each instance, which is why you are not allowed to use a variable to procedurally select a specific instance.

您展示的变量声明是针对虚拟接口的,它是一种数据类型.

The variable declaration you show is for a virtual interface, which is a data type.

//来自 A.2.1.3

// from A.2.1.3

data_declaration10 ::=[常量] [变量] [生命周期]data_type_or_implicit list_of_variable_decl_assignments ;|...

data_declaration10 ::= [ const ] [ var ] [ lifetime ] data_type_or_implicit list_of_variable_decl_assignments ; | ...

//来自 A.2.2.1 ...

// from A.2.2.1 ...

数据类型::= |虚拟 [接口]interface_identifier [ parameter_value_assignment ] [ .modport_identifier ]

data_type ::= | virtual [ interface ] interface_identifier [ parameter_value_assignment ] [ . modport_identifier ]

这篇关于SV 中的动态接口数组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆