Skip to content

Instantly share code, notes, and snippets.

@hube12
Created October 8, 2020 19:11
Show Gist options
  • Select an option

  • Save hube12/d0dbc2383648cba6cb8487c1e5c4c379 to your computer and use it in GitHub Desktop.

Select an option

Save hube12/d0dbc2383648cba6cb8487c1e5c4c379 to your computer and use it in GitHub Desktop.
import numpy as np
from pylfsr import LFSR
L = LFSR()
state = [1,1,1,1,1,0,0,0,0,0]
fpoly = [10,8,5,4]
L = LFSR(fpoly=fpoly,initstate =state, verbose=False)
L.info()
period=1023
for i in range(1,1024):
L.next()
if np.array_equal(L.state,state):
print("found at:",i)
period=min(period,i)
if i<=20:
print("State",i,L.state)
print("total period",period)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment