I have a requirement to create separate log files of class model extended from uvm object. As uvm object doesn’t inherit from report handler, I am trying to use creator handle for the same as shown below. However I am not getting desired results.
class my_obj extends uvm_object;
`uvm_object_utils(my_obj);
function new(string name = "");
super.new(name);
tID = get_type_name();
tID = tID.toupper();
endfunction
function void configure(uvm_component creator = null);
if(creator != null) begin
string hier_s;
string creator_s;
creator_s = creator.get_full_name();
hier_s = { creator_s, ".", get_full_name(), ".log" }
log = $fopen(hier_s, "w");
if(!log) begin
`uvm_fatal(tID, {hier_s, "can't open to write"});
end
creator.set_report_id_file(tID, log);
end
endfunction
function void display();
`uvm_info(tID, "this print goes to log file", UVM_HIGH);
endfunction
function void end_of_sim();
if(log) $fclose(log);
endfunction
local int log = -1;
protected string tID;
endclass
class my_comp extend uvm_component;
`uvm_component_utils(my_comp);
function new(string name = "", uvm_component parent = null);
super.new(name, parent);
endfunction
function void build_phase(uvm_phase phase);
super.build_phase(phase);
obj = my_obj::type_id::create("obj");
obj.configure(this);
endfunction
function void report_phase();
obj.end_of_sim();
endfunction
function void display();
obj.display();
endfunction
protected my_obj obj;
endclass
module try;
my_comp comp;
initial begin
comp = my_comp::type_id::create("comp", uvm_root::get());
comp.display();
end
endmodule
Here, comp.obj.log file is getting created but instead of display message directed to file it’s still coming on console.
Am I missing something here?