RE: [sv-bc] Serious issue with default expressions for task and function arguments

From: Mark Hartoog <Mark.Hartoog_at_.....>
Date: Thu Mar 03 2005 - 14:02:57 PST
> Obviously, one expects "p" in "foo" to be the parameter.  This
> is clear and is the case in virtually any language.  Why should
> the name binding of a default parameter value be any different?
> 
> The arguments over static versus dynamic name binding are decades
> old.  Is there something distinct about this context that leads
> one to disregard that history?

I have no objection to changing it to this, but this is not what 
the LRM currently says. You might want to think about the 
following case:

interface if();
int a;
function foo( input int x = a);
   return x;
endfunction

modport bus ( import function foo);
endinterface

module m(if.bus i);
int y;
initial y = i.foo();
endmodule

module top();
if i();
m u(i);
endmodule

I think the current LRM makes this illegal, and your proposal would make
this legal, but for this to be legal, does the modport 'bus' need to 
include 'a' as an input port so that the module calling the function 
'foo' can pass it as the default argument? 

We already have this issue in always_comb blocks. If the function foo had
no arguments, but just returned the value of 'a' and it was called from
an always_comb block, then that always_comb block has to be sensitive to 'a'.
It is unclear whether 'a' has to be an input port in the modport for this
to be legal.

Gordon Vreugdenhil wrote: 
> Mark Hartoog wrote:
> > In addition to the possibilities mentioned by Gord, you could also outlaw
> > the use of non-constant default values on all hierarchical or interface
> > function/task calls. You might still have some confusion for the case:
> > 
> > module A();
> > parameter p = 1;
> > function int foo(int x = p);
> >    return x;
> > endfunction
> > 
> > initial
> > begin
> >    int p = 2;
> >    $display(foo());
> > end
> > 
> > endmodule
> > 
> > Is this legal? If so, what value is displayed? 
> 
> 
> In my version of reality, of course it is legal.  The "p"
> in the default value binds to A.p.  The value displayed is "1".
> There is no confusion here just as there is no confusion if
> you have:
> 
>    module A();
>    parameter p = 1;
>    function int foo;
>       return p;
>    endfunction
> 
>    initial
>    begin
>       int p = 2;
>       $display(foo());
>    end
>    endmodule
> 
> 
> Obviously, one expects "p" in "foo" to be the parameter.  This
> is clear and is the case in virtually any language.  Why should
> the name binding of a default parameter value be any different?
> 
> The arguments over static versus dynamic name binding are decades
> old.  Is there something distinct about this context that leads
> one to disregard that history?
> 
> Gord.
> -- 
> --------------------------------------------------------------------
> Gordon Vreugdenhil,  Staff Engineer               503-685-0808
> Model Technology (Mentor Graphics)                gordonv@model.com
Received on Thu Mar 3 14:03:02 2005

This archive was generated by hypermail 2.1.8 : Thu Mar 03 2005 - 14:03:29 PST