Functional coverage to check 4 hot bits in 16 bit register

Hi,

I need to add a coverpoint that to check 4 hot bits (hot bit is “1”, all others are “0”) in a 16 bit register.
I tried to constraint using systemfunction $countones, but have a problem with it as it does not work with VCS simulator.
Is there a workaround for this problem?

Thanks,
Roopa

In reply to roopanandakumaran:

You could write a function to check if the signal is one-hot encoded or not.

In reply to roopanandakumaran:

// Purpose: Have a 4 hot patterns without $countones
// Conclusion:
module top;

  // Class
  class myclass;

    rand bit four_hot_pattern[16];

    constraint c_four_hot_p {
                              four_hot_pattern.sum with (int'(item)) == 4;
                            }

    // It should have 4 hot patterns
    bit [15:0] my_reg;

    function void post_randomize();
      my_reg = {>>{four_hot_pattern}};
    endfunction : post_randomize
  endclass // myclass

  initial 
  begin
    myclass c;
    c = new();
    if(!c.randomize())
      $display("Randomize fail");
    else
      $display("Randomize Pass");

    $display("my)_reg = %b", c.my_reg);
  end
endmodule // top;