PyLFSR: Linear Feedback Shift Register

Verson: 1.0.7

Github Page | Discussion Forum | Github


https://static.pepy.tech/personalized-badge/pylfsr?period=total&units=international_system&left_color=black&right_color=orange&left_text=total-downloads PyPI - Downloads PyPI - Hist-of-code CircleCI Documentation Status PyPI https://img.shields.io/github/license/Nikeshbajaj/Linear_Feedback_Shift_Register PyPI Format PyPI Implementation PyPI Python Version GitHub Repo stars GitHub forks https://zenodo.org/badge/DOI/10.5281/zenodo.7501241.svg
https://raw.githubusercontent.com/nikeshbajaj/Linear_Feedback_Shift_Register/master/images/FibanacciLFSR_2.gif

Linear Feedback Shift Register - Documentation.

PyLFSR is an open source Python library to create Pseudo-Random Generator based on Linear Feedback Shift Registe. It is easy to use and create Pseudo-Random Generator, with custom configurations, such as A5/1, its enhacement, Geffe Genrator and many more. A generated sequence can be tested across different properties.

A simple example of generating 5-bit LFSR with feedback polynomial of p(x) = x5+ x3+1

import numpy as np
from pylfsr import LFSR

state = [0,0,0,1,0]
fpoly = [5,3]
L = LFSR(fpoly=fpoly,initstate =state)

# Generate K-bits
k=10
seq_k  = L.runKCycle(k)

print('10 bits')
print(L.arr2str(seq_k))
print('')


# Generate bits of one full period.
# Expected period of LFSR = 2^M-1, for M-bit LFSR).
seq_full  = L.runFullPeriod()

print('Full period of LFSR = 31-cycles')
print(L.arr2str(seq_full))

L.Viz()
10 bits
0100001001

Full period of LFSR = 31-cycles
01000010010110011111000110111010100001001
https://github.com/Nikeshbajaj/Linear_Feedback_Shift_Register/blob/master/images/L_p53_1.png?raw=true

NOTE on visualization: Feedback bit shown in figure (while visualizing), is feedback computed from previous state, NOT from current state. Check visualization section for more details



Galois LFSR


A simple example for Galois LFSR is:
import numpy as np
from pylfsr import LFSR

state = [1,1,0,1,1]
fpoly = [5,3]
L = LFSR(fpoly=fpoly,initstate =state,conf='galois')
L.next()
L.Viz()



Authors/Contacts:

Feedback/Contact/Contribute

If any doubt, confusion or feedback please contact me

  • n.bajaj[AT]qmul.ac.uk

  • n.bajaj[AT]imperial.ac.uk

  • nikkeshbajaj[AT]gmail[dot?]

Nikesh Bajaj: http://nikeshbajaj.in

Queen Mary University of London

Imperial Collage London



Github Page | Discussion Forum | Github