Change var to ref.

Swap use of [] and [*] for associative and dynamic arrays.

 

Section 4.6

Change the syntax statement as shown in red:

 

data_type array_name [];

 

 

Change the first example as shown in red:

 

bit [3:0] nibble[]; // Dynamic array of 4-bit vectors

integer mem[]; // Dynamic array of integers

Section 4.6.1

Change the first example as shown in red:

 

integer addr[]; // Declare the dynamic array.

Section 4.6.3

Change the first example as shown in red:

 

int ab [] = new[ N ]; // create a temporary array of size N

Section 4.7

Change the examples as shown in red:

 

int B[] = new[100]; // dynamic array of 100 elements

int C[] = new[8]; // dynamic array of 8 elements

 

int B[]; // empty dynamic array

int C[] = new[8]; // dynamic array of size 8

 

string p[];

Section 4.8

Change the examples as shown in red:

 

string b[] = new[4]; //ok: same type and size, requires run-time check

task foo( string arr[] );

Section 4.9

Change the definition of index_type before the example as shown in red:

 

The syntax to declare associative an associative array is:

data_type array_id [ index_type ];

 

where:

 

      data_type is the data type of the array elements. Can be any type allowed for fixed-size arrays.

      array_id is the name of the array being declared.

      index_type is the data-type to be used as an index or *. If * is specified then the array is indexed by any integral expression of arbitrary size. An index type restricts the indexing expressions to a particular type.

       

Examples of associative array declarations are:

 

integer i_array[*]; // associative array of integer (unspecified

// index)

Section 4.9.1

Change the Title and the first two lines as shown in red:

 

4.9.1 Wildcard index type

 

Example: int array_name [*];

 

Associative arrays that do not specify an wildcard index type have the following properties:

Section 4.10.1

Change the first example as shown in red:

 

int imem[*];

 

Section 4.10.4

Change syntax as shown in red:

 

function int first( ref index );

 

Section 4.10.5

Change syntax as shown in red:

 

function int last( ref index );

Section 4.10.6

Change syntax as shown in red:

 

function int next( ref index );

Section 4.10.7

Change syntax as shown in red:

 

function int prev( ref index );

 

Change the last example as shown in red:

 

string aa[*];

Section 7.3

Change the example as shown in red:

 

function integer pre_inc (ref integer a); // ++a

a += 1;

pre_inc = a;

endfunction

 

function integer post_inc (ref integer a); // a++

post_inc = a;

a += 1;

endfunction

Section 10.5.2

Change the section as shown in red:

 

Arguments passed by reference are not copied into the subroutine area, rather, a reference to the original argument is passed to the subroutine. The subroutine can then access the argument data indirectly via the reference. To indicate argument passing by reference, the argument declaration is preceded by the ref keyword. The general syntax is:

 

subroutine( ref type argument );

 

For example, the example above can be written as:

 

function int crc( ref char [1000:1] packet );

for( int j= 1; j <= 1000; j++ ) begin

crc ^= packet[j];

end

endfunction

 

Note that in the example, no change other than addition of the ref keyword is needed. The compiler knows that packet is now addressed via a reference, but users do not need to make these references explicit either in the callee or at the point of the call. That is, the call to either version of the crc function remains the same:

 

char packet[1000:1];

int k = crc( packet1 ); // pass by value or by reference: call is the same

 

When the argument is passed by reference, both the caller and the subroutine share the same representation of the argument, so any changes made to the argument either within the caller or the subroutine will be visible to each other.

 

Arguments passed by reference must match exactly, no promotion, conversion, or auto-casting is possible when passing arguments by reference. In particular, array arguments must match their type and all dimensions exactly. Fixed-size arrays cannot be mixed with dynamic arrays and vice-versa.

 

Passing an argument by reference is a unique parameter passing qualifier, different from input, output, or inout. Combining ref with any other qualifier is illegal. For example, the following declaration results in a compiler error:

 

task incr( ref input int a ); // incorrect: ref cannot be qualified

Section 11.17

Change the first and second example as shown in red:

 

byte payload [];

 

byte payload [];

Section 11.21

Change the stack example as shown in red:

 

class stack #(parameter type T = int;);

local T items[];

task push( T a ); ... endtask

task pop( ref T a ); ... endtask

endclass

Section 12.9

Change the third paragraph as shown in red:

 

The variables variable1,..., variableN can be any one of the integral data types (see section 3.3.1) or string. Each variable may be either a simple variable, or a ref parameter (variable passed by reference) or a member of an array, associative-array, or object (class) of the aforementioned types. Objects (handles) are not allowed.

Section 20.3

Change the example as shown in red:

 

rand bit[7:0] len;

rand integer data[];

constraint db { data.size == len );

Annex B

Add the keyword ref. Leave the keyword var for future extension.