Daniel, The segment you highlighted refers only to name binding - not to lifetime. So considering the following code: int a; class C; function void f1(int x=a); // ... endfunction endclass initial begin bit a; C c1 = new; c1.f1(); end The method call could be "conceptually" implemented as: initial begin bit a; C c1 = new; int temp = $unit::a; c1.f1( temp ); end Note that the argument binds to the variable in $unit- the "a" in the declaration - and not the "a" in the scope of the call. That is what that statement indicates. Arturo ________________________________ From: owner-sv-ec@eda.org [mailto:owner-sv-ec@eda.org] On Behalf Of danielm Sent: Friday, January 18, 2008 7:19 AM To: sv-ec@eda.org Subject: [sv-ec] dynamic vars should be forbidden as defaults LRM says that: 1800-2005: 12.4.3 Default argument values: "The default_value is an expression. The expression is evaluated in the scope containing the subroutine declaration each time a call using the default is made." The problem arises when we use that rule for dynamic|automatic variables - ie for class propeties: class C; int a; static int b; function f1(int x=a); endfunction function f2(int y=this); endfunction function f3(int z = b); endfunction endclass IMHO only the 3rd (f3)should be allowed - because defaults are assigned before the function call - so only statics are known at that moment. Similar case may be also spotted in example with no classes: module top; task automatic t(int a = 1, int b = a); $display(a,,b); endtask initial t; endmodule In above case a is an automatic variable and doesn;'t exists at the moment when defaults should be assigned. DANiel -- This message has been scanned for viruses and dangerous content by MailScanner <http://www.mailscanner.info/> , and is believed to be clean. -- This message has been scanned for viruses and dangerous content by MailScanner, and is believed to be clean.Received on Fri Jan 18 15:20:58 2008
This archive was generated by hypermail 2.1.8 : Fri Jan 18 2008 - 15:21:10 PST