For this i having the below code.
class packet;
rand bit [31:0] address;
rand int arr=0;
constraint c1 { $countones(address) ==1;}
function void post_randomize();
for (int i=32; i>arr;i--)
address[i] =1;
endfunction
endclass
module abc();
packet pkt;
initial begin
pkt=new();
//repeat(5) begin
pkt.randomize();
$displayb(pkt.address);
//end
end
endmodule
but my expectation when i call multiple times randomization for the first 32nd bit should be 1 and for second time randomize() call 31st bit should be 1 and so on like that.
But i am getting the solution as below 11111111111111111111 (32 times 1).
Can any one pls help me with this.
Thanks & Regards,
Manikanta K.