Re: [sv-bc] Functions in nested modules (19.6)

From: Rishiyur S. Nikhil <nikhil_at_.....>
Date: Tue Feb 28 2006 - 07:36:15 PST
Ouch!  This is the classic example (couched here in SV terms) used to
demonstrate "unintended free variable capture" by dynamic scoping.

The implementor of module up_m in general does not know about what
function names are used inside down_m, which may even come from a
different package written by someone else.

Nikhil

Brad Pierce wrote:
> Which version of "f" does "down_inst" call in the skeleton below?
> 
> module container;
> 
>   function f; ... endfunction
> 
>   module up_m; ...
>        function f; ... endfunction
>        down_m down_inst(...);
>   endmodule
> 
>   module down_m; ...
>        ... f(...) ...
>   endmodule
> 
> endmodule
> 
> As I understand it, the function/task names are not resolved until after 
> the design has been elaborated, at which time they are resolved by 
> looking first in the calling instance, then in its parent and so on.
> So when I resolve the name "f" in "down_inst", should I find the version 
> that "down_m" sees in its lexical scope or the version that the parent 
> of "down_inst" sees in its lexical scope?
> 
> -- Brad
>  
>  
Received on Tue Feb 28 07:36:19 2006

This archive was generated by hypermail 2.1.8 : Tue Feb 28 2006 - 07:36:29 PST