Hi,
I am trying to write a constraint where if i have 6 numbers lets say in top_q = 10,11,12,13,14,15 then bot_q should not have the same element in the same index. Also same numbers cannot be repeated again. i tried with xor of (item^item==1), but that dint help. can somebody tell mewhat is wrong?
Examples:
top_q = 10,11,12,13,14,15
bot_q = 15,14,13,12,11,10
Below case is not allowed:
top_q = 10,11,12,13,14,15
bot_q = 15,11,12,14,13,10
class A;
rand int unsigned top_q[$];
rand int unsigned bot_q[$];
constraint top_q_c_size {top_q.size == 6; bot_q.size ==6;}
constraint top_q_c_value {foreach (top_q[i])
top_q[i] inside {[10:15]};
}
constraint bot_q_c_value {foreach (bot_q[i])
bot_q[i] inside {[10:15]};}
function new();
bot_q = top_q.find(item) with ((item^item)==1);
endfunction
endclass
module tb;
A a1;
initial begin
a1 = new();
if (!a1.randomize) $display ("Error");
$display ("%p",a1.top_q);
$display ("%p",a1.bot_q);
end
endmodule
Solution for my code :
'{'hb, 'he, 'ha, 'ha, 'hf, 'ha}
'{'hd, 'hd, 'ha, 'ha, 'ha, 'ha}