I have a parameterized class with a type - parameter .
Within the parameterized class I have a localparam which I need to initialize based on the type - parameter during specialization
module top_tb ;
class C #( type T = int ) ;
`ifndef M1
localparam STR = $sformatf( "C#(%0s)" , $typename( int ) ) ;
`else
localparam STR = $sformatf( "C#(%0s)" , $typename( type( T ) ) ) ;
`endif
function new() ;
$display(" STR is %0s " , STR );
endfunction
endclass
C #( int ) c_int ;
C #( bit signed [31:0] ) c_bits_31_0 ;
C #( bit [31:0] ) c_bit_31_0 ;
initial begin
c_int = new() ;
c_bits_31_0 = new() ;
c_bit_31_0 = new() ;
end
endmodule
I observe issue with it across simulators .
**ONLY 1 of the major 3 Simulators ( Running with Licensed ones at work ) run this code .
**
However I am not here to discuss simulator issues , I am here to ask if there is a way around the limitation of $typename ??
As per SV LRM Section 20.6.1 :: $typename can be used as elaboration time constant
So Code is Legal as per LRM .
From a strict LRM perspective $typename removes the sign i.e
$typename( bit signed [1:0] ) should give Output as bit [1:0]
$typename( bit [1:0] ) should give Output as bit [1:0]
How do I overcome this during initialization of the localparam ?
For the following ::
C #( bit signed [1:0] ) c_bits_1_0 ;
C #( bit [1:0] ) c_bit_1_0 ;
I want localparam to have different values as these are 2 different Specializations !!