Reputation: 13
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?
Upvotes: 1
Views: 1110
Reputation: 42788
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 ]
Upvotes: 1