# How can I optimise a 8b10b encoding for maximum alignment?

Imagine you encode an 8 bit symbol as a 10 bit symbol that is sent sequentially over a wire. The goal at the receiver is to detect the byte boundary.

Since there are 4 times more encoded symbols than source symbols, 3/4 encoded symbols are invalid. So the idea is that if you look at a buffer of received bits, if they are misaligned there will be encoded symbols that are invalid.

An aligned buffer has zero invalid symbols, but the reverse is not true. A misaligned buffer could accidentally be valid. So it's desirable to pick an encoding that is unlikely to be valid when shifted.

So I'm trying to figure out the probability that a given sequence of a given encoding is valid when shifted. And trying to optimize such an encoding.

As an example, 8b10b encoding is usually optimised for maximum transitions. So the best symbols are for example barrel rolled versions of '0101010101', and '0101011010'. But it's easy to see that '...01010101010101010101...' is valid at every possible index. So this is not at all useful for alignment.

It seems slightly better to have the fewest transitions, so '0000000000', '1111111111' and variations of '1111100000'. In this case '...00000000001111111111..." is only valid at 2/10 positions.

But maybe there is a better way? Barker code seems relevant, except it's not the autocorrelation that matters, but the correlation between all possible permutations of symbols sequences.