In reply to vickydhudashia:
BTW, since we are now using a nested foreach loop, it’s easer to write the other constraints that way as well. No need for out of bounds checking.
class A;
rand instruction_e list[] = new[20];
constraint q_c {
foreach (list[i]) {
foreach (list[j])
if(i<j) {
if (list[i]==ADD && list[j]==ADD) j-i >= 3;
if (list[i]==MUL && list[j]==MUL) j-i >= 4;
if (list[i]==SUB && list[j]==SUB)
list.sum() with (int'(item.index inside {[i+1:j-1]} && item != NOP)) >= 3;
}
}
}
endclass