Replace the paragraph in clause 4.11
Clause 3.8
discusses assigning initial values to a structure.
With the following paragraphs:
Members of a structure data type may be assigned individual default member values by using an initial assignment with the declaration of each member. The assigned expression must be a constant expression.
An example of initializing member of a structure type is:
typedef struct {
int addr = 1 + const;
int crc;
byte data [4] = ′{4′{1}};
} packet1;
The structure can then be instantiated.
packet1 p1; //initialization defined by the typedef.
//p1.crc will use the default value for an int
If an explicit initial value expression is used with the declaration of a variable, the initial assignment expression within the structure data type shall be ignored. Clause 3.8 discusses assigning initial values to a structure. For example:
packet1 pi = ′{1,2,′{2,3,4,5}}; //suppresses the typedef initialization
Members of unpacked structures containing a union as well as members of packed structures shall not be assigned individual default member values.
The initial assignment expression within a data type shall be ignored when using a data type to declare a net (See 6.5).
Add a bullet to the end of clause 13.3:
– An unpacked structure can be declared rand in which case all of that structure’s random members are solved
concurrently using one of the rules listed in this section. Unpacked structures shall not be declared randc. A member of a unpacked structure can be made random by having a rand or randc modifier in the declaration of its type. Members of unpacked structures containing a union as well as members of packed structures shall not be allowed to have a random modifier.
For example:
class packet;
typedef struct {
randc int addr = 1 + const;
int crc;
rand byte data [] = {1,2,3,4};
} header;
rand header h1;
endclass
packet p1=new;
Change the BNF in A.2.2.1:
struct_union_member27
::=
{ attribute_instance }
data_type_or_void list_of_member_identifiers ;
To:
struct_union_member27 ::=
{ attribute_instance } [random_qualifier] data_type_or_void list_of_variable_decl_assignments ;
Remove the production in A.2.3:
list_of_member_identifiers
::=
member_identifier
variable_dimension { ,
member_identifier
variable_dimension }
Change A.1.8 from:
property_qualifier7
::=
rand
| randc
|
class_item_qualifier
To:
property_qualifier7 ::=
random_qualifier
| class_item_qualifier
random_qualifier7 ::=
rand
| randc
Update the syntax box in 4.1 & 4.4