Subject: Re: [sv-cc] another directC question - defaults for args, passing by name
From: Francoise Martinolle (fm@cadence.com)
Date: Wed Feb 12 2003 - 12:30:30 PST
Andrzej,
While looking more closely at the bnf for function prototype, I dont see
that the bnf allows to provide default values for the formal arguments of a
function prototype. It allows it
only for the function declaration.
function_prototype ::= function data_type ( list_of_function_proto_formals )
named_function_proto::= function data_type function_identifier (
list_of_function_proto_formals )
list_of_function_proto_formals ::=
[ { attribute_instance } function_proto_formal { , { attribute_instance }
function_proto_formal } ]
function_proto_formal ::=
input data_type [ variable_declaration_identifier ]
| inout data_type [ variable_declaration_identifier ]
| output data_type [ variable_declaration_identifier ]
| variable_declaration_identifier
and
variable_declaration_identifier ::= variable_identifier { unpacked_dimension }
variable_identifier ::= identifier
Therefore for a extern directC function declaration in the Verilog code,
you cannot
provide default values for formals.
Ex:
you cannot write:
extern myCfunction (int i = 0);
At 07:30 PM 2/11/2003 -0500, Andrzej Litwiniuk wrote:
> > > Please correct me if I'm wrong.
> >
> > You can skip arguments and use named arguments in general in SV, you
> > just can't mix the two after you use a named binding (I would rather not
> > mix them at all).
> >
> > SV Draft 2 covers this etc in section 10.5.3.
> >
> > Kev.
>
>Thanks Kevin & Francoise for pointing this!
>My appologies: I didn't know about those changes,
>
>Apparently DirectC needs proofreading against LRM 3.0.
>
>I was amazed - I'm kind of digressing now - by the sub-chapter 10.5.
>It uses the term "subroutine" while everywhere else it is function/task.
>
>Then, default values for arguments. Pls. notice the absence of any
>restrictions!
>So, I guess, literal aggregates (structs, arrays) are allowed for default
>values of arguments? And what about default values for arguments passed
>by reference ('var')?
>What it would mean to have: 'task foo(var int i = 10);' ?
>
>
>Well, it ain't my problem, sv-bc guys surely will take care of it.
>
>Talking about =our= problems, it shouldn't be a big deal to allow
>the default values for arguments of external functions.
>It shouldn't be permitted, however, for exported SV functions called from C.
>(Kevin may comment that it would be a different story had we built the
>interface
>upon C++.)
>
>I see, however, some issues with passing by name.
>
>Again, it shouldn't be permitted for exported SV functions called from C.
>
>For external functions the names of formal arguments are optional (while they
>are obligatory for native subroutines - let me enjoy this long forgotten
>term).
>It won't make any sense to have the names of formal arguments only for some
>of them and still use passing by name.
>We may propose all-or-none approach, or require that passing by name is
>allowed
>only if all formal args have names.
>
>There is a more serious issue with argument passing by reference ('var').
>I'm afraid we'll have to do something.
>Until now, the actual passing mode for DirectC was transparent to Verilog;
>it would matter only for the C code whether the argument is passed by value
>or by reference, and it would be automatically inferred from the type of
>value.
>
>One of requirements for DirectC was to keep it similar to native
>'subroutines'.
>Does it mean that DirectC should allow for explicit specification of argument
>passing by referense vs. by value?
>If so, then we may have to rework everything ...
>
>Andrzej
>
> > > > Francoise Martinolle wrote:
> > > > > I am digging more in the directC document and I found something
> which needs
> > > > > to be specified:
> > > > > directC functions which are called from within Verilog must have
> all the
> > > > > parameters specified on the call either by position or by name.
> We should
> > > > > not allow to skip to provide a parameter if a default value is
> provided in the function
> > > > > declaration for that argument.
> > > > >
> > > > > Francoise
> > >
> > >
> >
> >
This archive was generated by hypermail 2b28 : Wed Feb 12 2003 - 12:31:29 PST