Inout default value

Hi all,

I’ve a task with the following arg:

task cfgPhyTrafficFlows(inout int Arg);

How can I assign it a default value?

When I try

task cfgPhyTrafficFlows(inout int Arg = 0);

Questa complains with “Illegal value (0) for ref formal (Arg). Value must be assignable.”
However, in the IEEE Std 1800-2012 §15.5.3 it seems it is possible to assign a default value to an inout. Questa limitation?

Any idea?

Thanks in advance for your help.

Best regards,
Johan

In reply to Peak25500:

The problem is not with the presence of a default, but the fact that the default argument cannot be written to. Although it is not very clear from the text of the LRM, the example shows that a default argument for output, inout, and ref argument must be assignable. For an output or inout argument, the “value” needs to be written to upon exiting the task or function.

In reply to dave_59:

Hi Dave,

Thanks for your reply.
So if I understand well, the default value should be a variable declared in the context from where the task is called?
My idea was to use the default value for backward compatibility, since I added new features requiring new arguments to the task.
I guess the only solution is to override the task?

Johan

In reply to Peak25500:

No, the default “is evaluated in the scope containing the subroutine declaration”. So you can write:

int ArgDefault = 0;
task cfgPhyTrafficFlows(inout int Arg = ArgDefault);

In reply to dave_59:

Oh… Ok, my bad.
Thanks a lot Dave!

Best regards,
Johan