Hi,
I got 2 questions about the parameterized class printed from factory:
1.Why does the factory Type Overrides print out ‘< unknown >’ for the parameterized class?
2.Why types - A#(1) & B#(A#(0),1) DO NOT get registered with the factory?
The source code:
import uvm_pkg::*;
`include "uvm_macros.svh"
class A#(bit[1:0] D=0) extends uvm_object;
`uvm_object_param_utils(A #(D))
function new(string name="A#(D)");
super.new(name);
endfunction // new
// get_type_name not implemented by macro for parameterized classes
const static string type_name = {"A #(",$sformatf("bit[1:0] D=%0d",D),")"};
virtual function string get_type_name();
return type_name;
endfunction
endclass // A
class B#(type T=int, bit[1:0] D) extends A #(D);
`uvm_object_param_utils(B #(T,D))
function new(string name="B#(T,D)");
super.new(name);
endfunction // new
//get_type_name not implemented by macro for parameterized classes
const static string type_name = {"B #(",$sformatf("%s, D=%0d",T::type_name,D),")"};
virtual function string get_type_name();
return type_name;
endfunction
endclass // B
class C extends uvm_object;
`uvm_object_utils(C)
function new(string name="C");
super.new(name);
endfunction // new
endclass // C
module tb;
A#(1) a1;
uvm_factory f = uvm_factory::get();
uvm_object_wrapper orig_type;
uvm_object_wrapper ovrd_type;
initial begin
orig_type = A#(1)::get_type();
ovrd_type = B#(A#(0),1)::get_type();
`uvm_info("tb", $sformatf("orig_type_name:%s, type_name:%s",orig_type.get_type_name(),A#(1)::type_name), UVM_MEDIUM)
`uvm_info("tb", $sformatf("ovrd_type_name:%s, type_name:%s",ovrd_type.get_type_name(),B#(A#(0),1)::type_name), UVM_MEDIUM)
f.set_type_override_by_type(.original_type(orig_type),.override_type(ovrd_type));
f.print();
a1 = A#(1)::type_id::create("A_H1");
a1.print();
end
endmodule //tb
================================================================================================================
KERNEL: #### Factory Configuration (*)
KERNEL:
KERNEL: No instance overrides are registered with this factory
KERNEL:
KERNEL: Type Overrides:
KERNEL:
KERNEL: Requested Type Override Type
KERNEL: -------------- -------------
KERNEL: ‘< unknown >’ ‘< unknown >’
KERNEL:
KERNEL: All types registered with the factory: 57 total
KERNEL: Type Name
KERNEL: ---------
KERNEL: C
KERNEL: (*) Types with no associated type name will be printed as
KERNEL:
KERNEL:
================================================================================================================
Please refer to factory print <unknown> - EDA Playground