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 ?
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
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?