I want uniq/ascending values until the tmp_num and rest of the values from the idx = 0 to tmp_num-1.
rand bit [7:0] uniq_dup_fol[];
rand bit [4:0] tmp_num;
constraint uniq_dup_c {
solve tmp_num before uniq_dup_fol;
uniq_dup_fol.size() == 16;
tmp_num inside {[uniq_dup_fol.size() - 6 : uniq_dup_fol.size() - 4]};
foreach (uniq_dup_fol[idx]) {
if(idx < tmp_num) {
if(idx < tmp_num - 1) {
uniq_dup_fol[idx] < uniq_dup_fol[idx + 1];
} else {
uniq_dup_fol[idx] > uniq_dup_fol[idx - 1];
}
} else {
uniq_dup_fol[idx] == get_num(tmp_num);
}
}
}
function bit[7:0]get_num(bit [4:0] tmp_num_l);
bit [4:0] cnt;
cnt = $urandom_range(1,tmp_num_l-1);
get_num = uniq_dup_fol[cnt];
$display("cnt = %0d uniq_dup_fol = %0h", cnt, uniq_dup_fol[cnt]);
return uniq_dup_fol[cnt];
endfunction : get_num
Results:
cnt = 5 uniq_dup_fol = 85
UVM_INFO sys_verif/verif/sys_trans_c.sv(76) @ 0: reporter [TB] -----------------------------------------
Name Type Size Value
-----------------------------------------
inst sys_trans_c - @2537
tmp_num integral 5 'ha
uniq_dup_fol da(integral) 16 -
[0] integral 8 'h3d
[1] integral 8 'h3f
[2] integral 8 'h44
[3] integral 8 'h51
[4] integral 8 'h54
... ... ... ...
[11] integral 8 'h85
[12] integral 8 'h85
[13] integral 8 'h85
[14] integral 8 'h85
[15] integral 8 'h85
rst integral 1 'h1
load integral 1 'h1
str integral 1 'h1
data integral 32 'h207
o_data integral 32 'h0
af integral 1 'h0
ae integral 1 'h0
full integral 1 'h0
empty integral 1 'h0
-----------------------------------------
UVM_INFO sys_verif/verif/sys_trans_c.sv(77) @ 0: reporter [TB] '{'h3d, 'h3f, 'h44, 'h51, 'h54, 'h56, 'h5b, 'h5c, 'h7a, 'ha8, 'h85, 'h85, 'h85, 'h85, 'h85, 'h85}