Q1.write constrains to generate 4x4 matrix?
Q2.write constraint make diagonal elements are 1 and other assign random number?
In reply to mgufran365:
These are not questions, they are chores.
In reply to dave_59:
actually sir this question ask in the interview .on that time i was not able to write
In reply to mgufran365:
- You can declare a 2D array in class.
- it is straightforward to constraint the diagonal to be 1
constraint diag { foreach (idata[i,j])
if ( i == j)
idata[i][j] == 1;
}
Hope this helps.
This will work to generate 4x4 matrix
class M4x4;
rand int array [][];
constraint ARRAY_SIZE {array.size == 4;
foreach(array[i]) array[i].size == 4;
}
endclass