Type conversion in class constraint

Hello!

I wrote class:


class Point;
   rand int  x;
   rand int  y;
  constraint range{
      x >= -32768;
      x <= 32767;
      y >= -32768;
      y <= 32767;
  }
  constraint crt{
              x**2 + y**2 <= AMP1**2;
              x**2 + y**2 >= AMP0**2;}
  constraint corner{
      x dist {-32768 :/ 10, [-32767:-1]:/ 100, 0:/ 10, [1:32766] :/ 100, 32767 :/ 10};
      y dist {-32768 :/ 10, [-32767:-1]:/ 100, 0:/ 10, [1:32766] :/ 100, 32767 :/ 10};
  }
endclass

Type of AMP0 and AMP1 variables is int.
I wrote covergroup:


amp_dist: coverpoint x**2 + y**2
   {
      bins amp_0 = {[0:214748364]}; // нормальное распределение
      bins amp_1 = {[214748364 + 1: 214748364*2]};
      bins amp_2 = {[214748364*2 + 1 : 214748364*3]};
      bins amp_3 = {[214748364*3 + 1 : 214748364*4]};
      bins amp_4 = {[214748364*4 + 1 : 32768**2]};
   }   

After run -all command I see in Questa console this

run -all
# ** Warning: (vsim-3881) ../vip/cordic_rec_to_polar_test.sv(65): Width conversion applied in bin 'amp_0' for Coverpoint 'amp_dist'. Value '32'h0ccccccc' changed to '16'h7fff (maximum)' value.
#    Time: 111 ns  Iteration: 2  Instance: /cordic_rec_to_polar_tb_top/test
# ** Warning: (vsim-3882) ../vip/cordic_rec_to_polar_test.sv(65): Out of bounds value range in bin 'amp_0' for Coverpoint 'amp_dist' converted to nearest valid bounded range of [16'h0000:16'h7fff].
#    Time: 111 ns  Iteration: 2  Instance: /cordic_rec_to_polar_tb_top/test
# ** Warning: (vsim-3881) ../vip/cordic_rec_to_polar_test.sv(66): Width conversion applied in bin 'amp_1' for Coverpoint 'amp_dist'. Value '32'h0ccccccd' changed to '16'h7fff (maximum)' value.
#    Time: 111 ns  Iteration: 2  Instance: /cordic_rec_to_polar_tb_top/test
# ** Warning: (vsim-3881) ../vip/cordic_rec_to_polar_test.sv(66): Width conversion applied in bin 'amp_1' for Coverpoint 'amp_dist'. Value '32'h19999998' changed to '16'h7fff (maximum)' value.
#    Time: 111 ns  Iteration: 2  Instance: /cordic_rec_to_polar_tb_top/test
# ** Warning: (vsim-8475) ../vip/cordic_rec_to_polar_test.sv(66): The invalid value range [32'h0ccccccd : 32'h19999998] is found in bin 'amp_1' of Coverpoint 'amp_dist'. It will be ignored.
#    Time: 111 ns  Iteration: 2  Instance: /cordic_rec_to_polar_tb_top/test
# ** Warning: (vsim-8549) After dropping the illegal, ignore or invalid values, the values list associated with scalar bin 'amp_1' in Coverpoint 'amp_dist' of Covergroup instance '\/cordic_rec_to_polar_tb_top/test/chid ' has converged to empty list. The bin will be taken out of coverage calculation.
#    Time: 111 ns  Iteration: 2  Instance: /cordic_rec_to_polar_tb_top/test
# ** Warning: (vsim-3881) ../vip/cordic_rec_to_polar_test.sv(67): Width conversion applied in bin 'amp_2' for Coverpoint 'amp_dist'. Value '32'h19999999' changed to '16'h7fff (maximum)' value.
#    Time: 111 ns  Iteration: 2  Instance: /cordic_rec_to_polar_tb_top/test
# ** Warning: (vsim-3881) ../vip/cordic_rec_to_polar_test.sv(67): Width conversion applied in bin 'amp_2' for Coverpoint 'amp_dist'. Value '32'h26666664' changed to '16'h7fff (maximum)' value.
#    Time: 111 ns  Iteration: 2  Instance: /cordic_rec_to_polar_tb_top/test
# ** Warning: (vsim-8475) ../vip/cordic_rec_to_polar_test.sv(67): The invalid value range [32'h19999999 : 32'h26666664] is found in bin 'amp_2' of Coverpoint 'amp_dist'. It will be ignored.
#    Time: 111 ns  Iteration: 2  Instance: /cordic_rec_to_polar_tb_top/test
# ** Warning: (vsim-8549) After dropping the illegal, ignore or invalid values, the values list associated with scalar bin 'amp_2' in Coverpoint 'amp_dist' of Covergroup instance '\/cordic_rec_to_polar_tb_top/test/chid ' has converged to empty list. The bin will be taken out of coverage calculation.
#    Time: 111 ns  Iteration: 2  Instance: /cordic_rec_to_polar_tb_top/test
# ** Warning: (vsim-3881) ../vip/cordic_rec_to_polar_test.sv(68): Width conversion applied in bin 'amp_3' for Coverpoint 'amp_dist'. Value '32'h26666665' changed to '16'h7fff (maximum)' value.
#    Time: 111 ns  Iteration: 2  Instance: /cordic_rec_to_polar_tb_top/test
# ** Warning: (vsim-3881) ../vip/cordic_rec_to_polar_test.sv(68): Width conversion applied in bin 'amp_3' for Coverpoint 'amp_dist'. Value '32'h33333330' changed to '16'h7fff (maximum)' value.
#    Time: 111 ns  Iteration: 2  Instance: /cordic_rec_to_polar_tb_top/test
# ** Warning: (vsim-8475) ../vip/cordic_rec_to_polar_test.sv(68): The invalid value range [32'h26666665 : 32'h33333330] is found in bin 'amp_3' of Coverpoint 'amp_dist'. It will be ignored.
#    Time: 111 ns  Iteration: 2  Instance: /cordic_rec_to_polar_tb_top/test
# ** Warning: (vsim-8549) After dropping the illegal, ignore or invalid values, the values list associated with scalar bin 'amp_3' in Coverpoint 'amp_dist' of Covergroup instance '\/cordic_rec_to_polar_tb_top/test/chid ' has converged to empty list. The bin will be taken out of coverage calculation.
#    Time: 111 ns  Iteration: 2  Instance: /cordic_rec_to_polar_tb_top/test
# ** Warning: (vsim-3881) ../vip/cordic_rec_to_polar_test.sv(69): Width conversion applied in bin 'amp_4' for Coverpoint 'amp_dist'. Value '32'h33333331' changed to '16'h7fff (maximum)' value.
#    Time: 111 ns  Iteration: 2  Instance: /cordic_rec_to_polar_tb_top/test
# ** Warning: (vsim-3881) ../vip/cordic_rec_to_polar_test.sv(69): Width conversion applied in bin 'amp_4' for Coverpoint 'amp_dist'. Value '32'h40000000' changed to '16'h7fff (maximum)' value.
#    Time: 111 ns  Iteration: 2  Instance: /cordic_rec_to_polar_tb_top/test
# ** Warning: (vsim-8475) ../vip/cordic_rec_to_polar_test.sv(69): The invalid value range [32'h33333331 : 32'h40000000] is found in bin 'amp_4' of Coverpoint 'amp_dist'. It will be ignored.
#    Time: 111 ns  Iteration: 2  Instance: /cordic_rec_to_polar_tb_top/test
# ** Warning: (vsim-8549) After dropping the illegal, ignore or invalid values, the values list associated with scalar bin 'amp_4' in Coverpoint 'amp_dist' of Covergroup instance '\/cordic_rec_to_polar_tb_top/test/chid ' has converged to empty list. The bin will be taken out of coverage calculation.

I think it is wrong type conversion.
I need to use shortint in class, but how to write valid code for covergroup and for constraint?
I tryed to use static conversation with int`() but it does not work.

In reply to IvanGrafskiy:
Cast to int worked for me, or at least it compiled

amp_dist: coverpoint int'(x**2 + y**2)

You need to explain what didn’t work for you.

In reply to dave_59:

Dave, thank you!

I solved this problem another way:

amp_dist: coverpoint int'(x)**2 + int'(y)**2