G

Rr

public
Guest Apr 07, 2025 Never 43
Clone
1
import numpy as np
2
from pylfsr import LFSR
3
state = [0,0,0,1,0]
4
fpoly = [5,3]
5
L = LFSR(fpoly=fpoly,initstate =state)
6
# Generate K-bits
7
k=10
8
seq_k = L.runKCycle(k)
9
print('10 bits')
10
print(L.arr2str(seq_k))
11
print('')
12
# Generate bits of one full period. LFSR = 2^M-1, for M-bit LFSR).
13
seq_full = L.runFullPeriod()
14
print('Full period of LFSR = 31-cycles')
15
print(L.arr2str(seq_full))
16
L.Viz()