I have following code ::
module top ;
class Proxy #( SIZE = 3 ) ;
local static string name = $sformatf("Proxy#(%0d)" , SIZE ) ;
static function string get_name() ;
return name ;
endfunction
endclass
class Main1 ;
typedef Proxy #( 3 ) typename ;
`ifdef STAT static `endif function string get() ;
return typename :: get_name() ;
endfunction
endclass
class Main2 ;
function void get() ;
$display(" Non-static get() function called with Null handle ");
endfunction
endclass
Main1 m1 ;
Main2 m2 ;
initial begin
m2.get() ;
$display( "%0s" , m1.get() ) ;
end
endmodule
Without using +define+STAT I Observe Null reference error with m1.get()
With +define+STAT m1.get() returns string “Proxy#(3)”
How is it that m2.get() works fine whereas m1.get() doesn’t ?
**As static property is assigned before initial block starts , shouldn't it work ?**