Mantis 1602

P1800-2008/D3a, 13.5.3

Clarify subroutine inout argument behavior with defaults,

Allow output argument defaults.

In Section 13.5.3

CHANGE

The syntax to declare a default argument in a subroutine is as follows:

subroutine( [ direction ] [ type ] argument = default_value );

 

The optional direction can be input, inout, or ref (output ports cannot specify defaults).

 

The default_value is an expression. The expression is evaluated in the scope containing the subroutine

declaration each time a call using the default is made. If the default_value is not used, the expression is

not evaluated. The use of default values shall only be allowed with the ANSI style declarations.

 

When the subroutine is called, arguments with default values can be omitted from the call, and the compiler

shall insert their corresponding values. Unspecified (or empty) arguments can be used as placeholders for

default arguments, allowing the use of nonconsecutive default arguments. If an unspecified argument is used

for an argument that does not have a default value, a compiler error shall be issued.

 

...

 

read( ); // error; k has no default value

 

 

TO

 

 

The syntax to declare a default argument in a subroutine is as follows:

subroutine( [ direction ] [ type ] argument = default_valueexpression );

 

The optional direction can be input, inout, output, or ref (output ports cannot specify defaults).

 

The default_value is an expression. The expression default_expression is evaluated in the scope containing the subroutine declaration each time a call using the default is made. If the default_value is not used, the expression is not evaluated. If the default is not used, the default expression is not evaluated. The use of defaults shall only be allowed with ANSI style declarations.

 

When the subroutine is called, arguments with default values defaults can be omitted from the call, and the compiler shall insert their corresponding values. Unspecified (or empty) arguments can be used as placeholders for default arguments, allowing the use of nonconsecutive default arguments. If an unspecified argument is used for an argument that does not have a default value, a compiler error shall be issued.

 

...

read( );        // error; k has no default value

read( 1, , 7 ); // error; k has no default value

 

The following example shows an output argument with a default expression.

 

module m;

logic a;

task t1 (output o = a) ; // default binds to m.a

...

endtask :a

task t2 (output o = b) ; // illegal, b cannot be resolved

...

endtask :b

endmodule :m

 

module n;

logic a;

initial t1(); // same as t1(m.a), not t1(n.a);

endmodule :n