# sequencing binary numbers

Is there a method for sequencing 4-bit binary numbers, where no 4 consecutive bits are repeated anywhere else in the stream?

For example;

Is there a method that would work for 5 and 6 bit numbers?

Thanks for all the great feedback. Here is some info on how the sequence is used:

Pictured below is the data placed on a wheel. As it spins, the bit stream is shifted into a software register from right to left. After 3 shifts, I have a valid number. After the 4th shift, I have the next number and because of its unique position in the sequence, I can associate it to a position on the wheel. Granted it’s not an absolute position system on power up, but after 4 shifts the position is found.

I’ve expanded this to six bits, but the process was manual. I’m looking for help to make scaling-up a bit easier.

Thanks.

• I think you are talking about a De Bruijn sequence. – Harry Svensson Sep 11 '18 at 15:27
• it is unclear what you are asking .... what is the purpose of the bit sequence field? – jsotola Sep 11 '18 at 15:28
• I believe the question is to find the sequence of bits $b_i$ for $0 \le i < 2^n$ such that the sequence of $n$-bit numbers $x_i = ShiftLeft(x_{i-1}) + b_i$ (and $x_0=0$) has unique numbers only. – Eugene Sh. Sep 11 '18 at 15:57
• Is the purpose to avoid duplicate values in 2^N -1 sequence or create pseudo random values for BER tetsts. If latter, there are many PRSG simple designs. – Tony Stewart Sunnyskyguy EE75 Sep 11 '18 at 16:24
• Some bits in the sequence are obviously predetermined. Each sequence has to start with 000..0, continue with 000..1, and end with 100..0 as it has to be cyclic. The last fact is predetermining the last n inputs. Some other rules would apply as well, like that 111...1 can be only followed with 111..10. Other than that I can't formulate additional rules other than backtracking if encountering any of the special sequences above. – Eugene Sh. Sep 11 '18 at 17:12

Yes it is a De Bruijn Sequence and based on an algorithm J. Tuliani wrote for his Thesis titled "On Window Sequences and Position Locations" the software community created this Sequence Generator;

De Bruijn Sequence

Thanks

• Somewhat related to Gray, I agree, but I fail to see a unique recipe other than backtracking on the possible bit choices. Also the interesting question would be "how many such a sequences for n-bit numbers?". For two bits, it's only 1, as far as I can tell. If it is one for any n, then this sequence should have a name. – Eugene Sh. Sep 11 '18 at 16:31