Constraint Randomization Interview Question

In reply to Have_A_Doubt:

Because the constraint solver is going to iterate over v[i] before knowing what the range of int1 could be. if you rewrote the constraint as

constraint  VAL  { foreach( v*)  //  Iterates  from  31  to  0 .
                     if(  i < 23 && i == int1 ) 
                        v[ i+:10 ] ==  10'h0 ;  
                 }

The i<23 acts as a constraint guard and prevents references to invalid ranges. (LRM section [i]18.5.13 Constraint guards*)

1 Like