如何constraint一个二维动态数组
时间:10-02
整理:3721RD
点击:
请问一下,本来想定义一个动态二维数组array,然后两个维度的大小由A和B的结果定义。但是如下的代码会报错。
求解如何破解
求解如何破解
- rand bit A;
- rand bit B;
- int array [][];
- constraint c_A {A inside {0, 1}}
- constraint c_B {B inside {0, 1}}
- constraint c_arrary {array.size == A;
- foreach (array[i]) array[i].size == B;
- }
- class twoDarray;
- rand bit[31:0] array[][];
- rand bit[ 7:0] index1;
- rand bit[ 7:0] index2;
- constraint cons{
- index1 == 'h3;
- index2 == 'h2;
- solve index1 before array;
- solve index2 before array;
- array.size() == index1;
- foreach(array[i])
- array[i].size() == index2;
- }
- endclass