How to randomize shortint in class in range with positive and negative borders

Hello!

I have a class:


class harm_amp_c;
   rand shortint amp_0;
   rand shortint unsigned amp_1;
   
   
   int unsigned temp;
   rand int unsigned amp[2:7];
   rand shortint unsigned noise;
   
   real amp_r[8];
   real noise_r;
   
   constraint amp_range{
      //amp_0 inside {[shortint'(-32768):shortint'(32767)]};
      amp_1 inside {[shortint'(0):shortint'(32767)]};
      noise inside {[shortint'(0):shortint'(32767)]};
      foreach(amp[i]) amp[i] inside {[shortint'(0):shortint'(32767)]};
   }
   
   constraint overflow_check{
      if(amp_0 > 0)
         {
            int'(amp_0) + int'(noise) + int'(amp_1) + amp.sum() <= int'(32767);
         }
      else
         {
            int'(amp_0) - int'(noise) - int'(amp_1) - amp.sum() >= int'(-32768);
         }
   }
   
   constraint parasit_harm{
      int'(noise) + int'(amp.sum()) <= int'(temp);
   
   }
   
   
   function void post_randomize;
      noise_r = real'(noise);
      amp_r[0] = real'(amp_0);
      amp_r[1] = real'(amp_1);
      foreach(amp[i]) amp_r[i] = real'(amp[i]);
   endfunction 
   
endclass

And I want to randomize amp_1 value in range with probability of 50% negative number and 50% of positive number.

I tryed this code


assert(harm_amp.randomize(amp_0) with {/*amp_0[15] dist    {0 := 50, 
                                                                      1 := 50}; */
                                                   amp_0 inside {[shortint'(-harm_amp.amp_1/5) : shortint'(-1)]};});
                                                             //  [shortint'(0) : shortint'(harm_amp.amp_1/5)] := 50};}); // генерим нулевую гармонику    

But assertion fails.
How to write this code?

I solved this problem. There was an error of casting types in shortint’(-harm_amp.amp_1/5). Because amp_1 is unsigned shortint we need to cast it to shortint type directly as -shortint’(harm_amp.amp_1)/5