In reply to cgales:
Hi cgales:
It’s correct that before component is created, the assignment can’t be done.
By the way, build_phase() will be called automatically when children use new() to create instance.
I thinks build_phase() is top-down phase, after making assignmet of agent config in env’s build_phase(), even finish involking env’s build_phase(), the children(agent)'s build_phase() is involked. So it has no effect that agents can use these values provided in the configuration object to configurate it’s structure etc.
class x_agent extends uvm_agent;
x_agent_config cfg;
x_coverage_collector collector;
...
function void build_phase (uvm_phase phase);
if (cfg.coverage_enable)
collector = x_coverage_collector::type_id::create("collector");
...
endfunction : build_phase
endclass : x_agent
The code above can work fine, is there any other reason please?
Thanks a lot!