Dynamic array of interfaces in SV

混江龙づ霸主 提交于 2019-12-08 04:23:47

问题


In SV LRM 2012 they are saying that

interface_instantiation ::= interface_identifier [ parameter_value_assignment ] 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 }

Finally, it can found that

unpacked_dimension ::= [ constant_range ] | [ constant_expression ]

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?


回答1:


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

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.

// from A.2.1.3

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

// from A.2.2.1 ...

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



来源:https://stackoverflow.com/questions/40839419/dynamic-array-of-interfaces-in-sv

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!