Random_stimulus

Hi,

Can someone help me write logic to generate the stimulus with the power of 2.

Thanks,
Naren

Assuming you want numbers including 1 i.e 1 , 2 , 4 , 8 , 16 , 32 …


class Main ;

rand int unsigned A ;

// Only a single bit would be set !!
constraint POWER_OF_TWO { $countones(A) == 1'b1 ; ] 

endclass