Coverage for the value difference between associative arrays

Hello,

I have 2 associative arrays

    int   assoc_arr_1[string];
    int   assoc_arr_2[string];

the string index are same in the two arrays.

I want to cover for each index in the arrays, the difference between the 2 values is:

  1. positives
  2. negative
  3. thay are equal

means 3 bins for each index.

for example:

assoc_arr_1["index_1"] = 5;
assoc_arr_1["index_2"] = 2
assoc_arr_2["index_1"] = 5
assoc_arr_2["index_2"] = 3

in that case “index_1” cover equal_bin and “index_2” cover neg_bin.

I am looking for a nice way to write this coverage.
The string index has meaning, so if we can keep the coverpoint with the name, that will be great.

Thanks,

In reply to rraa:

Create an associative array of covergroups.

covergroup aa_difference_cg(string index);
  option.per_instance = 1;
  option.name = name;
  positives: coverpoint assoc_arr_1[name] > assoc_arr_2[name] {
     bin pos = {1};
  }
  negatives: coverpoint assoc_arr_1[name] < assoc_arr_2[name] {
     bin neg = {1};
  }
  equal: coverpoint assoc_arr_1[name] == assoc_arr_2[name] {
     bin equ = {1};
  }
endgroup

aa_difference_cg cg_array[string];

foreach(assoc_arr_1[name]) cg_array[name = new(name);

You need to make sure the entire cg_array is sampled either with another loop, or a sampling event.