2018-02-14 01:04:52 +00:00
|
|
|
#!/usr/bin/python
|
|
|
|
|
2018-07-21 01:04:39 +00:00
|
|
|
MAXBITS=16
|
2018-02-14 01:04:52 +00:00
|
|
|
|
2018-07-21 01:04:39 +00:00
|
|
|
print("Period,nbits,feedback,mask")
|
|
|
|
|
|
|
|
for n in range(1,MAXBITS):
|
2018-02-14 01:04:52 +00:00
|
|
|
mask = (1<<n)-1
|
|
|
|
hibit = (1<<(n-1))
|
|
|
|
for i in range(0,1<<n):
|
|
|
|
for invert in [0,1]:
|
|
|
|
x = 1
|
|
|
|
seq = []
|
|
|
|
seen = set()
|
|
|
|
while x and not x in seen:
|
|
|
|
seq.append(x)
|
|
|
|
seen.add(x)
|
|
|
|
feedback = x & hibit
|
|
|
|
x = ((x << 1) & mask)
|
|
|
|
if invert:
|
|
|
|
if not feedback:
|
|
|
|
x ^= i
|
|
|
|
else:
|
|
|
|
if feedback:
|
|
|
|
x ^= i
|
|
|
|
if x:
|
|
|
|
seqindex = seq.index(x)
|
|
|
|
seqlen = len(seq) - seqindex
|
|
|
|
if seqlen>1:
|
2018-11-22 19:11:56 +00:00
|
|
|
print((seqlen, "#(%d,%d'%s,%d)" % (n,n,bin(i)[1:],invert), seqindex))
|