weben
Newbie level 5
In my systemverilog testbench, I need to genrate a 32 bits sequence which randomly contains 5 to 27 bit "1". Can anyone help me to describe the constrant of this random bit-sequence? thanks a lot
Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
rand bit [31:0] value;
constraint random_bit_sequence {$countones(value) inside {[5:27]}; }
rand bit value[31:0];
constraint random_bit_sequence {value.sum() with (int'(item)) inside {[5:27]}; }
You can try
Code:rand bit value[31:0]; constraint random_bit_sequence {value.sum() with (int'(item)) inside {[5:27]}; }