How to change the value of distributed weighted constrained random generation

if i have given the hard weighted value in my class during creating the class. but in future if i want to override the weighted value.
So how to make them generic or parameterized based ?

example "

class packet;
  rand bit [3:0] addr;

  constraint addr_range { addr dist { 2 := 5, 7 := 8, 10 := 12 }; }
endclass

now i want to make the 5,8, and 12 to be parameterized ?
Kindly suggest me the solution.

In reply to rupeshblr:

You can change 5, 8, and 12 to be parameters instead of literals. But a much easier solution is making them class variables so there are no class type compatibility issues.

class packet;
  rand bit [3:0] addr;
  int W1=5, W2=8, W3=12;
  constraint addr_range { addr dist { 2 := W1, 7 := W2, 10 := W3 }; }
endclass
class skew_packet extends packet;
function new;
  W1=12,W2=5,W3=8;
endfunction
endclass

In reply to dave_59:

Thank you @Dave

In reply to rupeshblr:

if want to deliver randomize test code to test vector team (who does not know the sv) who can change the value of w1,w2,w3 i.e trying to create the control knob or control file to achieve the above scenario (ms excel file to just feed the value of w1,w2 and w3) ?

In short i need the control knob or top level control file where i can just feed the value of w1, w2, and w3 ?

kindly suggest me if anything is possible to achieve the above scenario?

In reply to rupeshblr:

A package can be your control file

package knobs;
 parameter W1 = 5;
 parameter W2 = 8;
 parameter 31 = 12;
endpackage
 
...
 constraint addr_range { addr dist { 2 := knobs::W1, 7 := knobs::W2, 10 := knobs::W3 }; }

Also look at $value$plusargs.