Covergroup sample for an array

I am trying to do functional coverage for an array 32 bit . but every time it is hitting [0] position only.

 covergroup gt_en_cg (string name) with function sample(int unsigned gt_en);
        option.per_instance = 1; = name;
        gt_en_cp: coverpoint gt_en {
        //option.auto_bin_max = NUM_P;
        bins gt_en[NUM_P]= {[0:NUM_P-1]};
 function void sample();
 foreach (gt_en[i])

at the output i can check i am getting values for gt_en from [0] … [31].
but in cover points every time i am getting hits only for [0] position.
Please suggest me the correct way of doing this.

In reply to yoshiko:

This does not make any sense as all of your bin array elements hit the same value range [0:NUM_P-1].

Can you show us the declaration of cfg_obj.gt_en along with example values you expect to sample?

In reply to dave_59:

I am using following constraints to get the values of gt_en

class data_cfg#(tb_pkg::NUM_P);
 rand logic [NUM_P-1:0]   gt_en;
constraint c_gt_en_cfg { gt_en  inside {[0: 2**NUM_P -1 ]};
end class

 class do_cfg;

//created object of config class
 data_cfg#(31) cfg_obj; 

// created obj of coverage class
 data_cov cov_obj; 


task body();


//randomize gt_en 
 if ( !cfg_obj.randomize() )
 `uvm_fatal(get_name(),"Randommization failed!");

 //apply cfg to tb

//called sample function to use same values 
end task

Please let me know your valuable suggestions…