RE: [sv-bc] Mantis 1563: allow to pass macro arguments by name

From: Mark Hartoog <Mark.Hartoog_at_.....>
Date: Fri Aug 18 2006 - 09:56:39 PDT
I believe this could be a serious issue. Currently you can use 
macros to pass function/task/sequence/property actuals by 
name. I believe there are customers that are using this already,
and this enhancement would break their code.

function int foo(int a, int b);
endfunction

`define fun(x,y) foo(x,y)
 
`fun(.a(1), .b(2);


> -----Original Message-----
> From: owner-sv-bc@eda.org [mailto:owner-sv-bc@eda.org] On 
> Behalf Of Greg Jaxon
> Sent: Friday, August 18, 2006 8:45 AM
> To: Bresticker, Shalom
> Cc: SV_BC List
> Subject: Re: [sv-bc] Mantis 1563: allow to pass macro 
> arguments by name
> 
> Shalom,
> 
>     Just for completeness, I want to note that this is not 
> 100% backward compatible with existing systems.  For 
> instance, on a system without this feature the line
> 
> `fun( 2, .s("yes") ); // OK
> 
> is also legal and expands to
> 
> $display("%d %s", 2, .s("yes"));
> 
>     I doubt if that is a serious impediment to adopting the 
> change, but it needs to be noted.
> 
> Greg Jaxon
> 
> 
> Bresticker, Shalom wrote:
> > Fixed an error:
> > 
> > I have filed Mantis 1563, an enhancement request to pass macro 
> > arguments by name. For consistency, the language is similar 
> to that of 
> > 12.4.4 for tasks and functions.
> > 
> > In 23.2, INSERT
> > 
> > 23.2.1 Argument binding by name
> > 
> > SystemVerilog allows arguments to macros to be bound by 
> name as well 
> > as by position. This allows specifying the arguments in any 
> order and 
> > easily specifying the argument to be passed at the call. 
> For example:
> > 
> > `define fun(j, s)  $display("%d %s", j, s)
> > 
> > The fun macro can be called as follows:
> > 
> > `fun( .j(2), .s("yes") );
> > 
> > `fun( .s("yes"), .j(2) );
> > 
> > `fun( 2, "yes" );
> > 
> > If both positional and named arguments are specified in a 
> single macro 
> > call, then all the positional arguments must come before the named 
> > arguments. Then, using the same example as above:
> > 
> > `fun( .s("yes"), 2 ); // illegal
> > 
> > `fun( 2, .s("yes") ); // OK
> > 
> >  
> > 
> > Shalom
> > 
> > Shalom Bresticker
> > 
> > Intel Jerusalem LAD DA
> > 
> > +972 2 589-6852
> > 
> > +972 54 721-1033
> > 
> > I don't represent Intel
> > 
> >  
> > 
> 
> 
Received on Fri Aug 18 09:56:43 2006

This archive was generated by hypermail 2.1.8 : Fri Aug 18 2006 - 09:56:56 PDT