In reply to dave_59:
Hi Dave ,
For the below Code I have a class with static property “name” , in the Code below I never Call the Constructor using new , so how is the Class Constructed dynamically ?
module Static_Property_In_Parametrized_Class2;
class B #( type T = int , T w = 1 );
static string name = get();
// function string get(); // Error :: Class instance variable required to call non-static method 'get'
static function string get();
name = $sformatf("packet%0d",w);
$display($time, " Type_Parameter = %0s name == %0s",$typename(T),name);
endfunction
endclass
typedef B #( .T(bit[1:5]) , .w(3) ) w3;
w3 a1,a2;
B #(real,10.55) b1;
`ifdef T
B #( .T(bit[1:5]) , .w(3) ) a9;
`endif
initial begin
#10;
$display($time," After Delay ");
$display( B#(int,10)::name );
$display( B#()::name );
$display($time," %0s", a1.name );
end
Also the Output (With OR Without +define+T )of the above Code is as follows ::
# 0 Type_Parameter = real name == packet11
# 0 Type_Parameter = bit[1:5] name == packet3
# 0 Type_Parameter = int name == packet1
# 0 Type_Parameter = int name == packet10
# 10 After Delay
#
#
# 10
I have a few queries regarding the Output
Q1] How is it that I get " Type_Paramter = real " Before " Type_Parameter = bit[1:5] " ( without +define+T ),
Does it have to do Elaboration time ( typedef ) and Compilation time ( Class Handle b1 ) ?
Q2] " A static property is Never Created until the class becomes a concrete specialization "
I understand that I have created a concrete specialization using typedef w3 and b1 , a9 Since I instantiate the class variable
Do the statements $display( B#(int,10)::name ); $display( B#()::name );
create a Specialized Class as well ? Since I neither use a typedef Nor Declare a class Variable ( like a9 )
Q3] initial block Works Sequentially so shouldn’t I get the output of
" $display( B#(int,10)::name );$display( B#()::name ); " after Time = 10 ?
Q4] +define+T
Since a1 , a2 are Not Unique Parameters I don’t get Displays for it in the output , Same is the case with w3 since we already have a9 , But I expect " packet3 " at Time = 10 Using a1.name as Argument but its not the case