Generate a number which has sequence 11101

In reply to sriram.seshagiri:

Your constraint has 2 problems.

The first is
position
must include
position==0
. It turns out the constraint on
position
is unnecessary because the other constraint on value cannot be satisfied with
position
outside the range 0-27 (Both yours and my examples).

The other is the bits outside of the pattern range need to have random values. Using your constraint, those bits will always be 0. My constraint masks out those bits so the comparison always matches 0 for bits outside the pattern.