从仿真参数中直接set config到UVM component中
SIM_OPTION += +uvm_set_config_int=uvm_test_top,numTestRuns,10
SIM_OPTION += -uvm_set_config_string=uvm_test_top,test_seq_name,basic_test_seq
如果在对应的component中将相应域段加入到了uvm filed中,就会自动get到传入的参数,比如在xxx_test_base component中:
int numTestRuns;
`uvm_component_utils_begin(xxx_test_base)
`uvm_field_int(numTestRuns, UVM_ALL_ON)
`uvm_component_utils_end
这样,uvm_test_top就能自动get到仿真参数里指定的numTestRuns
如果要在component中手动get uvm_set_config_int指定的参数,需要像下面这样写:
uvm_config_db#(uvm_bitstream_t)::get(null, "uvm_test_top", "numTestRuns", numTestRuns);
相关的UVM源码
function void uvm_root::m_process_config(string cfg, bit is_int); uvm_bitstream_t v; string split_val[$]; uvm_root m_uvm_top; uvm_coreservice_t cs; cs = uvm_coreservice_t::get(); m_uvm_top = cs.get_root(); uvm_split_string(cfg, ",", split_val); if(split_val.size() == 1) begin uvm_report_error("UVM_CMDLINE_PROC", {"Invalid +uvm_set_config command\"", cfg, "\" missing field and value: component is \"", split_val[0], "\""}, UVM_NONE); return; end if(split_val.size() == 2) begin uvm_report_error("UVM_CMDLINE_PROC", {"Invalid +uvm_set_config command\"", cfg, "\" missing value: component is \"", split_val[0], "\" field is \"", split_val[1], "\""}, UVM_NONE); return; end if(split_val.size() > 3) begin uvm_report_error("UVM_CMDLINE_PROC", $sformatf("Invalid +uvm_set_config command\"%s\" : expected only 3 fields (component, field and value).", cfg), UVM_NONE); return; end if(is_int) begin if(split_val[2].len() > 2) begin string base, extval; base = split_val[2].substr(0,1); extval = split_val[2].substr(2,split_val[2].len()-1); case(base) "'b" : v = extval.atobin(); "0b" : v = extval.atobin(); "'o" : v = extval.atooct(); "'d" : v = extval.atoi(); "'h" : v = extval.atohex(); "'x" : v = extval.atohex(); "0x" : v = extval.atohex(); default : v = split_val[2].atoi(); endcase end else begin v = split_val[2].atoi(); end uvm_report_info("UVM_CMDLINE_PROC", {"Applying config setting from the command line: +uvm_set_config_int=", cfg}, UVM_NONE); uvm_config_int::set(m_uvm_top, split_val[0], split_val[1], v); end else begin uvm_report_info("UVM_CMDLINE_PROC", {"Applying config setting from the command line: +uvm_set_config_string=", cfg}, UVM_NONE); uvm_config_string::set(m_uvm_top, split_val[0], split_val[1], split_val[2]); end endfunction
uvm_config_db.svh
typedef uvm_config_db#(uvm_bitstream_t) uvm_config_int;