Hello,
Is it possible to have an associative array of covergroups? I am not sure whether it is the right way to phrase this question but posting my requirement below
- I intend to cover the clock ratios between different clocks in a design.
- The clock ratios between different clocks is available as an associative array (int clock_ratios[string]). The string index would be something like “clk1_x_clk2”.
- The clock ratios is an associative array because the number of clocks may vary depending on the design configuration.
What i intend to have
covergroup clk_ratios_cg with function sample(int clk_ratio);
RATIO: coverpoint clk_ratio {
bins low = {[1 : 5]};
bins med = {[6 : 19]};
bins high = {[20 : $]};
}
endgroup
class my_class extends my_base_class;
`uvm_component_utils(my_class)
int clk_ratios[string];
clk_ratios_cg ratio_cg[string]; // Can we do this?
virtual task monitor_clk_period(); // called in run_phase
foreach(config_item[i]) begin // config item from config db from the test top. The test top has some logic to figure out the number of clocks
automatic string clk_name = i;
fork begin
forever begin
calculate_clk_ratios(clk_name);
@clk[name].half_clk_period; //clk is an associaive array from my base class having some clock attributes
end
end
join_none
end
endtask
virtual function calculate_clk_ratios(string clk_name);
foreach(config_item[i]) begin
if(i == clk_name) continue; // No need of clk_ratio of clock to itself!!
else begin
clk_ratios[$sformatf("%s_x_%s", name, i)] = (clk[name].half_clk_period/clk[i].half_clk_period);
// Can we use sample function of clk_ratios_cg for each ratio_cg[$sformatf("%s_x_%s", name, i]
// But then do we need to new ratio_cg. new() cannot be done here
end
end
endfunction
endclass
From the above snippet, i want to cover the clk_ratio values in associative array clk_ratios[$sformatf(“%s_x_%s”, name, i] for the bins mentioned in clk_ratios_cg