Cyclic counter with constant Hamming distance

233 Views Asked by At

For what "n" counts are there cyclic counters with constant Hamming distance "d"?

(In particular, what if "d" == 1?)

EDIT:

Let me show the problem through examples.

The 3-bit Gray counter is well known. Its 8 consecutive states are:

000
001
011
010
110
111
101
100

However, you can also create shorter Hamming-1 counters (6 state):

000
001
011
010
110
100

or (6 state):

000
001
011
111
110
100

or (4 state):

001
011
111
101

The questions are:

  • for any "n" states, how to tell if there is a cyclic counter with Hamming distance "d"?
  • how to systematically generate such a counter (or sequence of states).
1

There are 1 best solutions below

0
On

When $d=1$ and our states have $k$ bits, you can create cyclic counters of any length $n$ where $n$ is even and $n \le 2^k$.

(Odd lengths $n$ are not possible, because we always alternate between an odd number and an even number of 1s in any counter, so we must take an even number of steps to return to the start.)

To do this, start with a Gray counter of length $2^{k-1}$ using $k-1$ bits. For example, when $k=4$, we have

000 001 011 010 110 111 101 100

To get a cyclic counter of length $n$ using $k$ bits ($n=10$ in the example below) we take the first $\frac n2$ of these states, with a $0$ appended...

0000 0010 0110 0100 1100 ...

and then the same $\frac n2$ states, with a $1$ appended, in reverse order:

0000 0010 0110 0100 1100 1101 0101 0111 0011 0001

This is the cyclic counter we wanted.