I have following code ( slightly modified ) from Rich Edelman’s paper “Does the Factory say Override”
`include "uvm_pkg.sv"
`include "uvm_macros.svh"
import uvm_pkg::*;
class base #( SIZE = 128 ) extends uvm_component ;
localparam type_name = $sformatf("base#(%0d_%0s)" , SIZE , ( ( ( SIZE << 24 ) > 0 ) ? "unsigned" : "signed" ) ) ; // [A]
typedef uvm_component_registry #( base #( SIZE ) , type_name ) type_base ;
function string get_type_name() ;
return type_name ;
endfunction
function new ( string name , uvm_component parent ) ;
super.new(name,parent);
endfunction
endclass
module String_Specialization_via_Sign ;
base #( 128 ) b1 ;
parameter int unsigned UINT32 = 128 ;
base #( UINT32 ) b2 ;
initial begin
$display(" b1 :: type_name is %0s " , base #( 128 ) :: type_name );
$display(" b2 :: type_name is %0s " , base #( UNINT32 ) :: type_name );
end
endmodule
I have a few questions ::
[Q1] Is [A] valid based on LRM ? Some Simulators throw Compilation Error .
I even observe that for the same simulator , it works with previous version but throws error with newer version
[Q2] Via Specializations b1 and b2 there exists Two Separate Registration in Type based factory .
So shouldn't there exist separate Registration in String based Factory as well ?
// As per the Original Code in Paper ::
Eg :: localparam type_name = $sformatf("base#(%0d)" , SIZE ) ; // Same String Registration for b1 and b2 !!
[Q3] The logic I have used above is hardcoded for Value as 128 .
Is there a generic logic through which I could know whether the value parameter is Signed OR Unsigned ?
Is there a System Function for the Same in Verilog / SystemVerilog ?