In reply to dave_59:
Hi Deve,
I tried above set of codes, but I am getting compilation error or incorrect output values.
// code snippet //
constraint c5_rows_cols {
foreach(rows_cols[ii,jj])
rows_cols[ii][jj] inside {[1:100]};
(jj != 0 ) -> rows_cols[ii,jj-1] < rows_cols[ii,jj];
}
ncvlog: *E,EXPRBK (…/registers/register_rdwr_base_seq.sv,157|49): expecting a right bracket (‘]’) [4.2.1][4.2][4.2.2(IEEE)].
(`include file: …/registers/register_rdwr_base_seq.sv line 157, file: …/registers/reg_pkg.sv line 11)
(jj != 0 ) → rows_cols[ii,jj-1] < rows_cols[ii,jj];
In rows_cols[ii][jj] (rows_cols[width][height]
(i) how to apply constraint individually on width or height in order to get output = 2 4, 6,
- Also I tried to randomize 2d dynamic array using seprate rand variables.
class A,
rand bit [11:0] width;
rand bit [11:0] height;
constraint width_cst {
width inside {[0:100]};
}
constraint height_cst {
height inside {[0:200]};
}
constraint c4_rows_cols {
rows_cols.size() inside {[0: width ]};
foreach(rows_cols[ii])
rows_cols[ii].size inside {[0: height ]};
}
constraint c5_rows_cols {
foreach(rows_cols[ii,jj])
rows_cols[ii][jj] inside {[1:100]};
}
constraint c6_rows_cols {
foreach(rows_cols[i,j])
(j < height - 1 ) -> rows_cols[i][j] < rows_cols[i][j+1];
}
//post randomize
foreach(rows_cols[i,j])
$display("\t VALUE OF rows_cols [%0d][%0d]=%0d",i,j,rows_cols[i][j]);
$display("\t Value of rows_cols SIZE %d", rows_cols.size());
// simulation result
POST RANDOMIZE: width 75
POST RANDOMIZE: height 190
Value of rows_cols SIZE 16.
Nothing is printed for VALUE OF rows_cols.
Please let me know where is the mistake in my code.
Best Regards
Abhinav