Section 3.1

LRM-213

Change (changes in red and blue):

SystemVerilog 3.1 adds string, chandle and class data types, and enhances the Verilog event and SystemVerilog 3.0 enum data types. SystemVerilog 3.1 also extends the user defined types by providing support for object-oriented class.

Section 3.2

LRM-249

Change in Syntax 3-1 (changes in red and blue):

data_type_common_item data_type ::=

  integer_vector_type [ signing ] { packed_dimension }

| integer_atom_type [ signing ]

| type_identifier { packed_dimension }

| non_integer_type

| struct_union [ packed [ signing ] ] { struct_union_member { struct_union_member } }

{ packed_dimension }14

| enum [ enum_base_type ] { enum_name_declaration { , enum_name_declaration } }

| string

| chandle

| virtual [ interface ] interface_identifier

| [ class_scope | package_scope ] type_identifier { packed_dimension }

| class_type

| event

| ps_covergroup_identifier

 

data_type ::=

  data_type_common_item

| event

| class_scope_type_identifier

| covergroup_identifier

LRM-213

Change in Syntax 3-1 (changes in red and blue):

enum_base_type ::=

  integer_atom_type [ signing ]

| integer_vector_type [ signing ] [ packed_dimension ]

| type_identifier [ packed_dimension ]26

LRM-249

Change in Syntax 3-1 (changes in red and blue):

class_scope_type_identifier::=

class_scope [ :: type_identifier ]

 

class_scope ::=

class_identifier [ parameter_value_assignment ]

{ :: class_identifier [ parameter_value_assignment ] }

class_scope ::=

class_type ::

 

class_type ::=

ps_class_identifier [ parameter_value_assignment ]

{ :: class_identifier [ parameter_value_assignment ] }

LRM-241

Change in Syntax 3-1 (changes in red and blue):

integer_atom_type ::= byte | shortint | int | longint | integer | time

 

integer_vector_type ::= bit | logic | reg

 

non_integer_type ::= time | shortreal | real | realtime

LRM-249

Change in Syntax 3-1 (changes in red and blue):

simple_type ::= integer_type | non_integer_type | ps_type_identifier

LRM-246

Change in Syntax 3-1 (changes in red and blue):

struct_union_member29 ::=

{ attribute_instance } data_type { packed_dimension }

data_type_or_void list_of_variable_identifiers ;

| { attribute_instance } void list_of_variable_identifiers ;

 

            data_type_or_void ::= data_type | void

LRM-213

Change in Syntax 3-1 (changes in red and blue):

variable_decl_assignment ::=

  variable_identifier variable_dimension [ = expression ]

| variable_identifier dynamic_array_variable_identifier [ ] = new [ expression ] [ ( variable_identifier ) ] [ = dynamic_array_new ]

| class_variable_identifier = new [ ( list_of_arguments ) ] [ = class_new ]

| [ covergroup_variable_identifier ] = new [ ( list_of_arguments ) ]17

Section 3.3

LRM-213

Change in Table 3-1 (changes in red and blue):

4-state Verilog-2001 data type, at least 32 bit signed integer

Section 3.5

LRM-213

Change (changes in red and blue):

The void data type represents non-existent data. This type can be specified as the return type of functions, indicating no return value. This type can also be used for members of tagged unions (see Section 3.11)

Section 3.7

LRM-279

Change (changes in red and blue):

SystemVerilog includes a string data type, which is a variable size, dynamically allocated array of characters bytes. SystemVerilog also includes a number of special methods to work with strings.

LRM-213 LRM-279

Change (changes in red and blue):

Verilog supports string literals, but only at the lexical level. In Verilog, string literals behave like packed arrays of a width that is a multiple of 8 bits. A string literal assigned to a packed array is an integral variable of a different size is either truncated to the size of the array variable or padded with zeroes to the left as necessary.

LRM-279

Change (changes in red and blue):

In SystemVerilog string literals behave exactly the same as in Verilog. However, SystemVerilog also supports the string data type to which a string literal can be assigned. When using the string data type instead of a packed array an integral variable, strings can be of arbitrary length and no truncation occurs. Literal strings are implicitly converted to the string type when assigned to a string type or used in an expression involving string type operands.

LRM-213

Change (changes in red and blue):

Variables of type string can be indexed from 0 to N-1 (the last element of the array), and they can take on the special value “”, which is the empty string. Reading an element of a string yields a byte.

LRM-213 LRM-279

Change (changes in red and blue):

SystemVerilog provides a set of operators that can be used to manipulate combinations of string variables and string literals. The basic operators defined on the string string  data type are listed in Table 3-2, which follows.

 

A string literal can be assigned to a string, a character, or a packed array or an integral type. If their size differs the literal is right justified and either truncated on the left or zero filled on the left, as necessary. For example:

LRM-213 LRM-279

Change (changes in red and blue):

A string, string literal, or packed array integral value can be assigned to a string variable. The string variable shall grow or shrink to accommodate the packed array integral value. If the size (in bits) of the packed array integral value is not a multiple of 8, then the packed array is zero filled on the left.

LRM-279

Change (changes in red and blue):

a = {"Hi",b};       // OK

r = {"H",""};       // yields "H\0" "" is converted to 8’b0

b = {"H",""};       // yields "H" "" is the empty string

a[0] = "h";         // OK same as a[0] = "hi" )

LRM-279

Change in Table 3-2 (changes in red and blue):

Comparison. Relational operators return 1 if the corresponding condition is true using the lexicographical ordering of the two strings Str1 and Str2. The comparison behaves like the ANSI C strcmp function (or the compare compare string method) (with regard to the lexical ordering) and embedded null bytes are included. Both operands can be of type string, or one of them can be a string literal.

LRM-213

Change in Table 3-2 add new row before Str.method (changes in red and blue):

Str[index]

Indexing.  Returns a byte, the ASCII code at the given index.  Indexes range from 0 to N-1, where N is the number of characters in the string. If  given an index out of range, returns 0. Semantically equivalent to Str.getc(index), in section 3.7.3.

Str.method(...)

The dot (.) operator is used to invoke a specified method on strings.

Section 3.7.2

LRM-237

Change (changes in red and blue):

Note: str.putc(j, x) is identical semantically equivalent to str[j] = x.

Section 3.7.3

LRM-237

Change (changes in red and blue):

Note: x = str.getc(j) is identical semantically equivalent to x = str[j].

Section 3.7.6

LRM-279

Change (changes in red and blue):

    str.compare(s) compares str and s, as in the ANSI C strcmp function (with regard to lexical ordering and return value), with a compatible return value and embedded null bytes are included

Section 3.7.7

LRM-279

Change (changes in red and blue):

    str.icompare(s) compares str and s, like the ANSI C strcmp function (with regard to lexical ordering and return value), with a compatible return value, but the comparison is case insensitive and embedded null bytes are included.

Section 3.7.9

LRM-213

Change (changes in red and blue):

The string is converted until the first non-digit is encountered. The conversion scans all leading digits and underscore characters (_) and stops as soon as it encounters any other character, or the end of the string.  Returns zero if no digits were encountered.  It does not parse the full syntax for integer literals (sign, size, tick, base).

Section 3.7.10

LRM-213

Change (changes in red and blue):

str.atoreal() returns the real number corresponding to the ASCII decimal representation in str.

 

The conversion parses Verilog syntax for real constants.  The scan stops as soon as it encounters any character that does not conform to this syntax, or the end of the string.  Returns zero if no digits were encountered.

Section 3.9

LRM-213

Change (changes in red and blue):

User defined type identifiers have the same scoping rules as data identifiers, except that hierarchical reference to type identifiers shall not be allowed. References to type identifiers defined within an interfaces interface through ports are allowed provided they are locally re-defined before being used.

Section 3.10

LRM-249

Change in Syntax 3-3 (changes in red and blue):

data_type_common_item data_type ::=                                           // from Annex A.2.2.1

...

| enum [ enum_base_type ] { enum_name_declaration { , enum_name_declaration } }

LRM-213

Change in Syntax 3-3 (changes in red and blue):

enum_base_type ::=

  integer_atom_type [ signing ]

| integer_vector_type [ signing ] [ packed_dimension ]

| type_identifier [ packed_dimension ]26

LRM-213

Change (changes in red and blue):

// Syntax error: IDLE=2’b00, XX=2’bx <ERROR>, S1=2’b01??, S2=2’b10??

Section 3.10.2

LRM-213

Change in Table 3-3 (changes in red and blue):

Generates N labels named constants in the sequence: name0, name1, ..., nameN-1. N must be an integral constant

LRM-213

Change (changes in red and blue):

enum { register[1 2] = 1, register[2:4] = 10 } vr;

Section 3.10.4

LRM-213

Change (delete section header, merge into 3.10.3 and renumber 3.10.5) (changes in red and blue):

3.10.4 Enumerated types in comparison expressions

Section 3.10.5

LRM-213

Change (changes in red and blue):

From the previous declaration, blue has the numerical value 2. This example assigns a the value of 6 (2*3). Next,  and it assigns b a value of 4 (3+1).

 

An enum variable or identifier used as part of an expression is automatically cast to the base type of the enum declaration (either explicitly or using int as the default). An assignment to an enum variable from an expression other than an enum variable or identifier of the same type shall require a cast. Casting to an enum type shall cause a conversion of the expression to its base type without checking the validity of the value (unless a dynamic cast is used as described in Section 3.15).

Section 3.10.5.1

LRM-213

Change (changes in red and blue):

The first() method returns the value of the first member of the enumeration enum.

Section 3.10.5.2

LRM-213

Change (changes in red and blue):

The last() method returns the value of the last member of the enumeration enum.

Section 3.11

LRM-246

Change in Syntax 3-4 (changes in red and blue):

struct_union_member29 ::=

{ attribute_instance } data_type { packed_dimension }

data_type_or_void list_of_variable_identifiers ;

| { attribute_instance } void list_of_variable_identifiers ;

 

            data_type_or_void ::= data_type | void

LRM-213

Change indentation to match (changes in red and blue):

typedef union { int i; shortreal f; } num; // named union type

num n;

n.f = 0.0; // set n in floating point format

LRM-213

Change (changes in red and blue):

A packed union shall contain members that must be packed structures, or packed arrays or integer data types all of the same size (in contrast to an unpacked union, where the members can be different sizes). This ensures that you can read back a union member that was written as another member. A packed union can also be used as a whole with arithmetic and logical operators, and its behavior is determined by the signed or unsigned keyword, the latter being the default. If a packed union contains a 2-state member and a 4-state member, the entire union is 4 state. There is an implicit conversion from 4-state to 2-state when reading and from 2-state to 4-state when writing the 2-state bit member.

LRM-213

Change (changes in red and blue):

tag is 0 for Add, 1 for Jmp

Outer tag is 0 for Add, 1 for Jmp

Inner tag is 0 for JmpU, 1 for JmpC

Section 3.12

LRM-213

Change (changes in red and blue):

A class is a collection of data and a set of subroutines that operate on that data. The data in a class is are referred to as class properties, and its subroutines are called methods. The class properties and methods, taken together, define the contents and capabilities of a class instance or object.

LRM-216 LRM-249

Change in Syntax 3-5 (changes in red and blue):

class_declaration ::=

[ virtual ] class [ lifetime ] class_identifier [ parameter_port_list ]

[ extends class_identifier [ parameter_value_assignment ] ] [ ( list_of_arguments ) ] ];

[ extends class_type [ ( list_of_arguments ) ] ];

{ class_item }

endclass [ : class_identifier]

LRM-213

Change (changes in red and blue):

class Packet;

Section 3.14

LRM-249

Change in Syntax 3-6 (changes in red and blue):

simple_type ::= integer_type | non_integer_type | ps_type_identifier

LRM-214

Change (changes in red and blue):

A data type can be changed by using a cast ( ) operation. The expression to be cast must be enclosed in parenthesis parentheses or within concatenation or replication braces and is self-determined.

LRM-265

Change (note formatting as well) (changes in red and blue):

typedef struct {

bit isfloat;

union { int i; shortreal f; } n;  // anonymous type

} tagged_st;                             // named structure

 

typedef bit [$bits(tagged_st) - 1 : 0] tagbits; // tagged_st defined above

 

tagged_st a [7:0];                       // unpacked array of structures

 

tagbits t = tagbits’(a[3]);              // convert structure to array of bits

a[4] = tagged_st’(t);                    // convert array of bits back to structure