One Hot encoding

In reply to dave_59:

Had to make a couple small modifications to Dave’s example:

`define WIDTH 5

covergroup onehot_cg(input integer position, ref bit [`WIDTH-1:0] vector);
  encoding: coverpoint ((1'b1<<position) & vector) != 0 {
    bins hit = { 1 };
  }
  option.per_instance = 1;
endgroup

class my_coverage_class;

  // The bus that requires one hot encoding coverage
  bit [`WIDTH-1:0] my_bus;

  onehot_cg cgi[`WIDTH];

  function new;
    foreach (cgi[i]) cgi[i] = new(i,my_bus);
  endfunction
  
endclass: my_coverage_class