Here is my code to generate a tictactoe . I keep running into this error.
Error-[TCF-IOOO] Invalid operands of operator
testbench.sv, 18
“((item.index(1) == this.result_pos) ? item : 0)”
Invalid operands of operator ‘? :’.
for the line a.sum(item) with(item.index(1)==result_pos?item:0) == 3.
Is there some restriction on 2D array ?
class tictactoe;
rand int a[3][3];
typedef enum {X,O,DRAW} result;
rand result result1;
rand bit[1:0] result_pos;
constraint toe_c {
foreach(a[i,j]) {
a[i][j] inside {[-1:1]};
if(result1==DRAW) a[i][j]!=0;
}
solve result1,result_pos before a;
if (result1==DRAW) a.sum(item) with (item.sum()) ==0 ;
if (result1==X) {
a.sum(item) with (item.sum()) == 1;
(a.sum(item) with(item.index(1)==result_pos?item:0) == 3) || (a.sum(item) with ( item.index(1) == item.index(2)?item:0) ==3) || (a.sum(item) with(item.index(2)==result_pos?item:0) ==3) || (a.sum(item) with (item.index(2) == 2-item.index(1)?item:0) == 3);
}
if (result1==O) {
a.sum(item) with (item.sum()) == -1;
(a.sum(item) with(item.index(1)==result_pos?item:0) == -3) || (a.sum(item) with ( item.index(1) == item.index(2)?item:0) ==-3) || (a.sum(item) with(item.index(2)==result_pos?item:0) ==-3) || (a.sum(item) with (item.index(2) == 2-item.index(1)?item:0) == -3);
}
result_pos!=3;
}
endclass