Hi,
I have seen the following situation in uart_env.sv from the uvm_ref_flow_1.2 package.
The configuration is registered with a field macro:
`uvm_component_utils_begin(uart_env)
`uvm_field_object(cfg, UVM_DEFAULT)
`uvm_field_int(checks_enable, UVM_DEFAULT)
`uvm_field_int(coverage_enable, UVM_DEFAULT)
`uvm_component_utils_end
The build phase calls super.build_phase, thus the automatic configuration:
function void uart_env::build_phase(uvm_phase phase);
super.build_phase(phase);
// Configure
if ( cfg == null)
if (!uvm_config_db#(uart_config)::get(this, "", "cfg", cfg)) begin
`uvm_info("NOCONFIG", "No uart_config, creating...", UVM_MEDIUM)
cfg = uart_config::type_id::create("cfg", this);
if (!cfg.randomize())
`uvm_error("RNDFAIL", "Could not randomize uart_config using default values")
`uvm_info(get_type_name(), {"Printing cfg:\n", cfg.sprint()}, UVM_MEDIUM)
end
If I use the config db, then the automatic configuration (apply_config_settings) called by the build phase of uvm_component should set “cfg”, right? Then why does this code, if cfg = null, query the config DB again? Am I misunderstanding how this works?
BR, Dominik