Section 7.11

LRM-169

Change (changes in red and blue):

            Swap 7.11 and 7.12 (7.11 Concatenation becomes 7.12 Concatenation and 7.12 static prefixes become 7.11 static prefixes)

LRM-169

Change (changes in red and blue):

Note that braces are also used for initializers of structures or unpacked arrays. Unlike in C, the expressions must match element for element and the braces must match the structures and array dimensions. Each element must match the type being initialized, so the following do not give size warnings:

 

bit unpackedbits [1:0] = {1,1}; // no size warning, bit can be set to 1

int unpackedints [1:0] = {1’b1,1’b1}; //no size warning, int can be set to 1’b1

 

A concatenation of unsized values shall be illegal, as in Verilog. However, an array initializer can use unsized values within the braces, such as {1,1}.

 

The replication operator (also called a multiple concatenation) form of braces can also be used for initializers . For example, {3{1}} represents the initializer {1, 1, 1}.

Section 7.13

LRM-169

Change (changes in red and blue):

Braces are also used for expressions to assign to unpacked arrays. Unlike in C, the expressions must match element for element, and the braces must match the array dimensions. The type of each element is matched against the type of the expression according to the same rules as for a scalar. Each expression item shall be evaluated in the context of an assignment to the type of the corresponding element in the array. This means that the following examples do not give size warnings, unlike the similar assignments above:

 

bit unpackedbits [1:0] = {1,1};     // no size warning as bit can be set to 1

int unpackedints [1:0] = {1’b1, 1’b1};     // no size warning as int can be

// set to 1’b1

 

The syntax of multiple concatenations can be used for unpacked array expressions as well. Each replication represents a single dimension.

 

unpackedbits = {2 {y}} ; // same as {y, y}

int n[1:2][1:3] = {2{{3{y}}}};    // same as {{y,y,y},{y,y,y}}

 

SystemVerilog determines the context of the braces by looking at the left hand side when used in the context of an assignment. If the left hand side is an used in the context of an assignment to an unpacked array, the braces represent an unpacked array literal or expression. Outside the context of an assignment on the right hand side to an aggregate type, an explicit cast must be used with the braces to distinguish it from a concatenation.

 

It can sometimes be useful to set array elements to a value without having to keep track of how many members there are. This can be done with the default keyword:

 

initial unpackedints = {default:2}; // sets elements to 2

 

For more arrays of structures, it is useful to specify one or more matching types type keys, as illustrated under structure expressions, below.

 

struct {int a; time b;} abkey[1:0];

abkey = {{a:1, b:2ns}, {int:5, time:$time}};

 

When the braces include a type, or default key, the braces shall not be interpreted as a concatenation for both packed and unpacked array types.

 

The rules for unpacked array matching are as follows:

 

      An index:value specifies an explicit value for a keyed element index. The value is evaluated in the context of an assignment to the indexed element and shall be castable to its type. It shall be an error to specify the same index more than once in a single array expression.

      For type:value, if the element or sub array type of the unpacked array exactly matches is equivalent  this type, then each element or sub array shall be set to the value. The value must be castable to the array element or sub array type. Otherwise, if the unpacked array is multidimensional, then there is a recursive descent into each sub array of the array using the rules in this section and the type and default specifiers keys. Otherwise, if the unpacked array is an array of structures, there is a recursive descent into each element of the array using the rules for structure expressions and the type and default specifiers keys. If more than one type matches the same element, the last value shall be used.

      For default:value, this key specifies the default value to use for each element of an unpacked array that has not been covered by the earlier rules in this section. The value is evaluated in the context of each assignment to an element covered by the default and  must be castable to the array element type.

 

Every element shall be covered by one of these rules.

 

If the type key, default key, or replication operator is used on an expression with side effects, the number times that expression evaluates is undefined.

Section 7.14

LRM-169

Change (changes in red and blue):

A structure expression (packed or unpacked) can be built from member expressions using braces and commas, with the members in declaration order. Each member expression shall be evaluated in the context of an assignment to the type of the corresponding member in the structure. It can also be built with the names of the members

LRM-169

Change (changes in red and blue):

SystemVerilog determines the context of the braces by looking at the left hand side when used in the context of an assignment. If the left hand side is used in the context of an assignment to an unpacked structure, the braces represent an unpacked structure literal or expression. Outside the context of an assignment on the right hand side to an aggregate type, an explicit cast must be used with the braces to distinguish it from a concatenation. When the braces include a label, type, or default key, the braces shall not be interpreted as a concatenation for both packed and unpacked structure types.

 

The matching rules are as follows:

 

      A member:value: specifies an explicit value for a named member of the structure. The named member must be at the top level of the structure—a member with the same name in some level of substructure shall not be set. The value must be castable to the member type and is evaluated in the context of an assignment to the named member, otherwise an error is generated.

 

      The type:value specifies an explicit value for a field in the structure which exactly matches is equivalent to the type and has not been set by a field name specifier key above. If the same key type key is mentioned more than once, the last value is used. The value is evaluated in the context of an assignment to the matching type.

 

      The default:value applies to members that are not matched by either member name or type key and are not either structures or unpacked arrays. The value is evaluated in the context of each assignment to a member by the default and must be castable to the member type, otherwise an error is generated. For unmatched structure members, the type and default specifiers are applied recursively according to the rules in this section to each member of the substructure. For unmatched unpacked array members, the type and default specifiers keys are applied to the array according to the rules for unpacked arrays.

 

Every member must be covered by one of these rules.

 

Of the type key, default key, or replication operator is used on an expression with side effects, the number of times that expression evaluates is undefined.

Section 7.16

LRM-198

Change (changes in red and blue):

Aggregate expressions can be copied in an assignment, through a port, or as an argument to a task or function. Aggregate expressions can also be compared with equality or inequality operators. To be copied or compared, the type of an aggregate expression must be equivalent assignment comptable. See Section 5.8.1 5.8.2 Equivalent Assignment Compatible types.