【发布时间】:2019-05-14 20:10:52
【问题描述】:
您好,假设我有这样的代码,参数 NUM_MASTERS 和 NUM_SLAVES 是在配置对象中定义的:
class abc extends uvm_scoreboard;
configuration cfg;
wrapper_class master[]; //i am instantiating a dynamic array of class objects, one each for all masters and another for slaves
wrapper_class slave[];
extern function new(string name = "abc", uvm_component parent = null);
extern function void build_phase(uvm_phase phase);
endclass
function abc::new(string name = "abc", uvm_component parent = null);
super.new(name, parent);
end
function void abc::build_phase(uvm_phase phase);
super.build_phase(phase);
uvm_config_db#(config_type)::get)this."*","configuration", cfg);
//this is where the error is happening
for(int i = 0; i < cfg.NUM_MASTERS : i++)
masters[i] = wrapper_class::type_id::create($sformatf("masters[%0d]",i),this);
for(int i = 0;i < cfg.NUM_SLAVES; i++)
slaves[i] =wrapper_class::type_id::create($sformatf("slaves[%0d]",i),this);
endfunction
谁能告诉我如何填充这些动态数组?我必须从构建阶段开始执行它们,因为只有这样我才能从 cfg 对象访问 NUM_MASTERS 和 NUM_SLAVES。非常感谢任何帮助/建议。谢谢。
【问题讨论】:
标签: arrays dynamic system-verilog uvm