I want to generate 9 one hot numbers each with 9 bit length in system Verilog constraints . But the below code is generating all 0s. Any idea whats going wrong?
class unique_elements;
rand bit [8:0] my_var[9];
constraint my_var_c{
foreach(my_var[i])
{
$countones(my_var[i]) == 1;
}
unique{my_var};
}
function void display();
foreach(my_var[i])
$display("my_var = %p",my_var[i]);
endfunction
endclass
program unique_elements_randomization;
unique_elements pkt;
initial begin
pkt = new();
pkt.randomize();
pkt.display();
end
endprogram