One Hot encoding

In reply to victorl:

Actually, it only took 6 months to see the new 1800-2012 covergroup syntax implemented. The example now can be written as:

class my_coverage_class #(int WIDTH);
 
  // The bus that requires one hot encoding coverage
  bit [WIDTH-1:0] my_bus;

  // array to hold one-hot encodings
  bit [WIDTH-1:0] onehots[WIDTH];
  covergroup onehot_cg;
    coverpoint my_bus {
       bins selected[WIDTH] = onehots;
    }
   endgroup
   function new;
     foreach(onehots[i]) onehots[i] = 1'b1 <<i;
     onehot_cg = new;
   endfunction
endclass