forked from Nikeshbajaj/Linear_Feedback_Shift_Register
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexamples.py
More file actions
43 lines (26 loc) · 703 Bytes
/
Copy pathexamples.py
File metadata and controls
43 lines (26 loc) · 703 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import numpy as np
from pylfsr import LFSR
## Example 1 ## 5 bit LFSR with x^5 + x^2 + 1
L = LFSR()
L.info()
L.next()
L.runKCycle(10)
L.runFullCycle()
L.info()
tempseq = L.runKCycle(10000) # generate 10000 bits from current state
## Example 2 ## 5 bit LFSR with custum state and feedback polynomial
state = [0,0,0,1,0]
fpoly = [5,4,3,2]
L = LFSR(fpoly=fpoly,initstate =state, verbose=True)
L.info()
tempseq = L.runKCycle(10)
tempseq
L.set(fpoly=[5,3])
## Example 3 ## 23 bit LFSR with custum state and feedback polynomial
L = LFSR(fpoly=[23,19],initstate ='ones',verbose=True)
L.info()
L.runKCycle(10)
L.info()
seq = L.seq
L.changeFpoly(newfpoly =[23,21])
seq1 = L.runKCycle(20)