Foreach usage in randomization constraints

In reply to dave_59:

Hi Dave,

Very good idea.
Another method using $dist_normal(seed, mean, std);
By given range related config, then val will be a bath-tub curve in this range.

class A;
 
   rand int norm;
   // range config
   int high = 100;
   int low = 0;
   int mean = 50;
   int std = 20;
   int val;
   
  constraint c { 
    norm == normal(mean);
  }
  
  function int normal(int mean);
    return $dist_normal($urandom(), mean, std);
  endfunction
  
  function void post_randomize();
    if (norm inside {[low:high]}) begin
      val = high - norm;
    end 
    // val within designed range will be bath-tub
  endfunction
  
endclass : A