mirror of
https://github.com/sehugg/8bitworkshop.git
synced 2024-11-22 14:33:51 +00:00
29 lines
813 B
Python
Executable File
29 lines
813 B
Python
Executable File
#!/usr/bin/python
|
|
|
|
print "Period,nbits,feedback,mask"
|
|
|
|
for n in range(1,18):
|
|
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:
|
|
print seqlen, "#(%d,%d'%s,%d)" % (n,n,bin(i)[1:],invert), seqindex
|