I was trying a few codes involving dist and inside ::
// CODE I
rand int val ;
int a = 10 , b = 20 , c = 21 , d = 30 ; // Can be changed at run-time
constraint V1 { val inside { [a:b] } ; }
constraint V2 { val inside { [c:d] } ; }
The above code has constraint failure ( Since V1 and V2 both can’t be true at same time )
Although the intention is to keep val between 1 to 20 , it should be specified as comma separated values i.e val inside { [a:b] , [c:d] } ;
Similar issue exists if I write dist constraint as follows ::
// CODE II
int a = 10 , b = 20 , c = 21 , d = 30 ;
rand int val ;
constraint V1 { val dist { [a:b] :/ 10 } ; }
constraint V2 { val dist { [c:d] :/ 20 } ; }
// CODE III
rand int value;
int a[5], b[5];
function void pre_randomize() ;
a = {1, 11, 21, 31, 41};
b = {10, 20, 30, 40, 50};
endfunction
constraint c_value {
foreach (a[i])
value inside { [a[i]:b[i]] } ; // Error !!
}
Since the Constraint gets unrolled into 5 different Constraints , the randomization fails !!
// Gets Unrolled into semicolon separated Constraints ( i.e 5 constraints !! )
value inside { [1:10] } ; value inside { [11:20] }; value inside { [21:30] } ; value inside { [31:40] };
Now I am confused how does the following Constrained gets unrolled ?
rand int value;
int a[5], b[5];
int c[5];
function void pre_randomize() ;
a = {1, 11, 21, 31, 41};
b = {10, 20, 30, 40, 50};
c = {30, 15, 10, 15, 30};
endfunction
constraint c_value {
foreach (a[i])
value dist { [a[i]:b[i]] :/ c[i] }; // Error !!
}
[Q1] Randomization fails above . It seems like it gets unrolled into 5 semicolon separated constraints within c_value . Is my understanding correct ?
value inside { [1:10]:/ 30 } ; value inside { [11:20]:/ 15 }; value inside { [21:30]:/ 10 } ; value inside { [31:40]:/ 15 } ;
value inside { [41:50]:/ 30 } ;
How can I change it to comma separated constraint ?
i.e value inside { [1:10]:/ 30 , [11:20]:/ 15 , [21:30]:/ 10 , [31:40]:/ 15 } , [41:50]:/ 30 } ;